diff options
author | tsmith@maint2.mysql.com <> | 2006-09-01 08:53:56 +0200 |
---|---|---|
committer | tsmith@maint2.mysql.com <> | 2006-09-01 08:53:56 +0200 |
commit | e2f40aa6d0430a6d3ceff907dee64a73ed40ad3a (patch) | |
tree | 24b6f3aba8a9ade97a4fbce85a8c990afbe49db7 /vio | |
parent | 9111a9c5c1f8d7184ad4df54f2e8e8dd83cf5c98 (diff) | |
parent | 907f5db856b1bbbc9c96e7808fb3c04560208af3 (diff) | |
download | mariadb-git-e2f40aa6d0430a6d3ceff907dee64a73ed40ad3a.tar.gz |
Merge maint2.mysql.com:/data/localhome/tsmith/bk/41
into maint2.mysql.com:/data/localhome/tsmith/bk/50
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) */ } |