X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fport.cc;h=01e0e88b34426e1f014db5fd43346903d004570e;hb=66dcfb211cc2ca7dc6630754a6fd68343569e29a;hp=17e03e494b6ca01f330db4adb6afe02d256055d4;hpb=25efe3485198149616820ab4e52d2f18f0abe5a7;p=awesomized%2Flibmemcached diff --git a/libtest/port.cc b/libtest/port.cc index 17e03e49..01e0e88b 100644 --- a/libtest/port.cc +++ b/libtest/port.cc @@ -120,7 +120,7 @@ in_port_t get_free_port() int retries= 1024; - while (retries--) + while (--retries) { int sd; if ((sd= socket(AF_INET, SOCK_STREAM, 0)) != -1) @@ -155,11 +155,21 @@ in_port_t get_free_port() } // We handle the case where if we max out retries, we still abort. - if (ret_port <= 1024) + if (retries == 0) + { + fatal_message("No port could be found, exhausted retry"); + } + + if (ret_port == 0) { fatal_message("No port could be found"); } + if (ret_port <= 1024) + { + fatal_message("No port could be found, though some where available below or at 1024"); + } + return ret_port; }