From: leslie Date: Tue, 4 Aug 2009 13:29:58 +0000 (+0800) Subject: allow microsecond network timeouts X-Git-Tag: upstream/620~225 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=e330c7f9d342caeb3bb0c53836ca0347eafdae73;p=sasc-ng.git allow microsecond network timeouts --- diff --git a/network.c b/network.c index 702d9a6..5cd8621 100644 --- a/network.c +++ b/network.c @@ -336,7 +336,8 @@ int cNetSocket::Select(bool forRead, int timeout) fd_set fds; FD_ZERO(&fds); FD_SET(sd,&fds); struct timeval tv; - tv.tv_sec=timeout; tv.tv_usec=0; + if(timeout&MSTIMEOUT) { tv.tv_sec=0; tv.tv_usec=(timeout&~MSTIMEOUT)*1000; } + else { tv.tv_sec=timeout; tv.tv_usec=0; } int r=select(sd+1,forRead ? &fds:0,forRead ? 0:&fds,0,&tv); if(r>0) return 1; else if(r<0) { @@ -344,7 +345,7 @@ int cNetSocket::Select(bool forRead, int timeout) return -1; } else { - if(timeout>0 && !quietlog) PRINTF(L_CORE_NET,"socket: select timed out (%d secs)",timeout); + if(timeout>0 && !quietlog) PRINTF(L_CORE_NET,"socket: select timed out (%d %s)",timeout&~MSTIMEOUT,(timeout&MSTIMEOUT)?"ms":"secs"); return 0; } } diff --git a/network.h b/network.h index 5a01aac..c19d5c7 100644 --- a/network.h +++ b/network.h @@ -30,6 +30,8 @@ #define DEFAULT_READWRITE_TIMEOUT 3 #define DEFAULT_IDLE_TIMEOUT 120 +#define MSTIMEOUT 0x800000 + extern const char *netscript; extern int netTimeout;