dmlc/ps-lite

GetAvailablePort function

microwish opened this issue · 0 comments

src/network_utils.h:

Perhaps two issues on the function GetAvailablePort.

First of all, although it doesn't affect the expected behavior of the function GetAvailablePort, it might be better to return -1 instead of 0 if there is any error. After all, port 0 is reserved by TCP/IP suite.
If this function returns -1 instead of 0, CHECK() should also be replaced by CHECH_LT().

Second, necessary calls to close(sock) are missing when there are errors amid, so memory leak might happen in some corner cases.