summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorunknown <grichter@bk-internal.mysql.com>2006-09-02 11:03:16 +0200
committerunknown <grichter@bk-internal.mysql.com>2006-09-02 11:03:16 +0200
commit50456f81c431ec70d6f126534fb891b5e818cf12 (patch)
tree1823c21585f5da58307333345b2b551e091405ed /vio
parent73ca6fc5ea1c0a389b8c7eb00f81179b40097b8d (diff)
parent9c9a27d91a1528412e4d0c9dbfb022385f81575c (diff)
downloadmariadb-git-50456f81c431ec70d6f126534fb891b5e818cf12.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.c30
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) */
}