summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorunknown <tsmith@maint2.mysql.com>2006-09-01 08:53:56 +0200
committerunknown <tsmith@maint2.mysql.com>2006-09-01 08:53:56 +0200
commit5bd9bf5572a2c7aa917cdeee2b116646953b2e69 (patch)
tree24b6f3aba8a9ade97a4fbce85a8c990afbe49db7 /vio
parent5992281da6978f747434963fde2d4b5836d4b5bd (diff)
parent5576ed8b1e7b12087f50056ca7eb397096be6b33 (diff)
downloadmariadb-git-5bd9bf5572a2c7aa917cdeee2b116646953b2e69.tar.gz
Merge maint2.mysql.com:/data/localhome/tsmith/bk/41
into maint2.mysql.com:/data/localhome/tsmith/bk/50 mysql-test/r/ctype_utf8.result: Auto merged mysql-test/t/ctype_utf8.test: Auto merged sql/net_serv.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_yacc.yy: Auto merged vio/viosocket.c: Auto merged client/mysql.cc: Manual merge. mysql-test/t/ctype_recoding.test: Manual merge. sql/sql_lex.h: SCCS merged sql/sql_table.cc: Manual merge. mysql-test/r/ctype_recoding.result: Manual merge
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) */
}