dmlc / ps-lite

A lightweight parameter server interface

Home Page:http://ps-lite.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GetAvailablePort function

microwish opened this issue · 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.