diff options
author | grichter@bk-internal.mysql.com <> | 2006-09-02 11:03:16 +0200 |
---|---|---|
committer | grichter@bk-internal.mysql.com <> | 2006-09-02 11:03:16 +0200 |
commit | 6993e3a3f7234817fab2c2813a82d8b0be97392b (patch) | |
tree | 1823c21585f5da58307333345b2b551e091405ed /vio | |
parent | 44a9d4c9fe68f24fce445b568f36489cdfe1c358 (diff) | |
parent | 0fd3e29042de9f354c45d5d332bc3d236ef45237 (diff) | |
download | mariadb-git-6993e3a3f7234817fab2c2813a82d8b0be97392b.tar.gz |
Merge bk-internal.mysql.com:/data0/bk/mysql-5.0
into bk-internal.mysql.com:/data0/bk/mysql-5.0-cmake
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 710f7a93607..1f348c3313d 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -379,16 +379,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) */ } |