diff options
author | unknown <msvensson@shellback.(none)> | 2006-09-08 16:01:51 +0200 |
---|---|---|
committer | unknown <msvensson@shellback.(none)> | 2006-09-08 16:01:51 +0200 |
commit | d0a978e9c8f744a3390156ba6e392b94c7ab4276 (patch) | |
tree | a7bde93b6228fde10cba8e6d529c8faa18dfe094 /vio | |
parent | 925802234f39039728f3c4f6ea1417ace02935c5 (diff) | |
parent | 960af9f6fe09a05ecf911203b097c4fed1920169 (diff) | |
download | mariadb-git-d0a978e9c8f744a3390156ba6e392b94c7ab4276.tar.gz |
Merge shellback.(none):/home/msvensson/mysql/mysql-5.1
into shellback.(none):/home/msvensson/mysql/mysql-5.1-new-maint
sql/ha_innodb.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/log.cc:
Auto merged
sql/mysqld.cc:
Auto merged
sql/sql_show.cc:
Auto merged
storage/csv/ha_tina.cc:
Auto merged
mysql-test/mysql-test-run.pl:
Merge
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) */ } |