diff options
author | cmiller@zippy.cornsilk.net <> | 2006-09-05 16:46:55 -0400 |
---|---|---|
committer | cmiller@zippy.cornsilk.net <> | 2006-09-05 16:46:55 -0400 |
commit | 7ca1a49437756a9a3eafaff049b398e8c9f1a490 (patch) | |
tree | 6a8ae78c604f958c767ebba4f559c2e8a4315b93 /vio | |
parent | 954256c324e50e47929c94eaf72667ba69200a69 (diff) | |
parent | c746c08af9287e43b8517307e32be258e0c6f1f1 (diff) | |
download | mariadb-git-7ca1a49437756a9a3eafaff049b398e8c9f1a490.tar.gz |
Merge zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-maint
Diffstat (limited to 'vio')
-rw-r--r-- | vio/viosocket.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c index 78901fedb69..0d472be7901 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -378,16 +378,30 @@ my_bool vio_poll_read(Vio *vio,uint timeout) } -void vio_timeout(Vio *vio __attribute__((unused)), - uint which __attribute__((unused)), - uint timeout __attribute__((unused))) +void vio_timeout(Vio *vio, uint which, uint timeout) { +/* TODO: some action should be taken if socket timeouts are not supported. */ +#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) + #ifdef __WIN__ - ulong wait_timeout= (ulong) timeout * 1000; - (void) setsockopt(vio->sd, SOL_SOCKET, - which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout, - sizeof(wait_timeout)); -#endif /* __WIN__ */ + + /* Windows expects time in milliseconds as int. */ + int wait_timeout= (int) timeout * 1000; + +#else /* ! __WIN__ */ + + /* POSIX specifies time as struct timeval. */ + struct timeval wait_timeout; + wait_timeout.tv_sec= timeout; + wait_timeout.tv_usec= 0; + +#endif /* ! __WIN__ */ + + /* TODO: return value should be checked. */ + (void) setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO, + (char*) &wait_timeout, sizeof(wait_timeout)); + +#endif /* defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) */ } |