Hi! On 06/16/2015 03:24 PM, Zeng Linggang wrote: > Signed-off-by: Zeng Linggang <zenglg...@cn.fujitsu.com> > --- > include/safe_macros.h | 29 ++++++++++++++++++ > lib/safe_macros.c | 83 > +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 112 insertions(+)
Good idea. Please use separate file for socket safe macros, look at how safe_stdin.h made. The name could be safe_sock.h, safe_net.h, etc. > + > +int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void), > + int socket, const struct sockaddr *address, > + socklen_t address_len) > +{ > + int rval; > + > + rval = bind(socket, address, address_len); > + > + if (rval < 0) { > + tst_brkm(TBROK | TERRNO, cleanup_fn, > + "%s:%d: bind(%d, %p, %d) failed", file, lineno, socket, > + address, address_len); > + } > + > + return rval; > +} bind() can return -1 if address is in use, e.g. it's in time_wait state. Usually, you should wait (~30 sec or more, it depends on rtt) on it until socket address will be available. If timeout exceeded, only then I would exit with TBROK. Please check for errno 'EADDRINUSE'. Thanks, Alexey ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list