Below is the list of changes that have just been committed into a local
4.0 repository of tomash. When tomash does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-09-18 22:02:06+04:00, kroki@stripped +4 -0
BUG#9678: Client library hangs after network communication failure
(back-port to 4.0)
Socket timeouts in client library were used only on Windows.
Additionally, in 4.0 write operations erroneously set read timeout.
The solution is to use socket timeouts in client library on all
systems were they are supported, and to differentiate between read
and write timeouts.
No test case is provided because it is impossible to simulate network
failure in current test suite.
include/violite.h@stripped, 2006-09-18 22:02:04+04:00, kroki@stripped +3 -3
Add argument to vio_timeout() to determine which timeout should be set:
for read (false) or for write (true).
libmysqld/lib_vio.c@stripped, 2006-09-18 22:02:04+04:00, kroki@stripped +1 -0
Add argument to vio_timeout() to determine which timeout should be set:
for read (false) or for write (true).
sql/net_serv.cc@stripped, 2006-09-18 22:02:04+04:00, kroki@stripped +2 -2
Add argument to vio_timeout() to determine which timeout should be set:
for read (false) or for write (true).
vio/viosocket.c@stripped, 2006-09-18 22:02:04+04:00, kroki@stripped +20 -6
Add argument to vio_timeout() to determine which timeout should be set:
for read (false) or for write (true).
Implement socket timeouts on POSIX systems.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: kroki
# Host: moonlight.intranet
# Root: /home/tomash/src/mysql_ab/mysql-4.0
--- 1.33/include/violite.h 2006-09-18 22:02:09 +04:00
+++ 1.34/include/violite.h 2006-09-18 22:02:09 +04:00
@@ -77,7 +77,7 @@ my_bool vio_peer_addr(Vio* vio, char *bu
/* Remotes in_addr */
void vio_in_addr(Vio *vio, struct in_addr *in);
my_bool vio_poll_read(Vio *vio,uint timeout);
-void vio_timeout(Vio *vio,uint timeout);
+void vio_timeout(Vio *vio, uint which, uint timeout);
#ifdef HAVE_OPENSSL
#include <openssl/opensslv.h>
@@ -140,7 +140,7 @@ Vio *new_VioSSL(struct st_VioSSLAcceptor
#define vio_close(vio) ((vio)->vioclose)(vio)
#define vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt)
#define vio_in_addr(vio, in) (vio)->in_addr(vio, in)
-#define vio_timeout(vio, seconds) (vio)->timeout(vio, seconds)
+#define vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds)
#endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */
/* This enumerator is used in parser - should be always visible */
@@ -180,7 +180,7 @@ struct st_vio
my_bool (*should_retry)(Vio*);
my_bool (*was_interrupted)(Vio*);
int (*vioclose)(Vio*);
- void (*timeout)(Vio*, unsigned int timeout);
+ void (*timeout)(Vio*, unsigned int which, unsigned int timeout);
void *ssl_arg;
#endif /* HAVE_VIO */
};
--- 1.64/sql/net_serv.cc 2006-09-18 22:02:09 +04:00
+++ 1.65/sql/net_serv.cc 2006-09-18 22:02:09 +04:00
@@ -436,7 +436,7 @@ net_real_write(NET *net,const char *pack
thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff);
#else
alarmed=0;
- vio_timeout(net->vio, net->write_timeout);
+ vio_timeout(net->vio, 1, net->write_timeout);
#endif /* NO_ALARM */
pos=(char*) packet; end=pos+len;
@@ -627,7 +627,7 @@ my_real_read(NET *net, ulong *complen)
if (net_blocking)
thr_alarm(&alarmed,net->read_timeout,&alarm_buff);
#else
- vio_timeout(net->vio, net->read_timeout);
+ vio_timeout(net->vio, 0, net->read_timeout);
#endif /* NO_ALARM */
pos = net->buff + net->where_b; /* net->packet -4 */
--- 1.17/libmysqld/lib_vio.c 2006-09-18 22:02:09 +04:00
+++ 1.18/libmysqld/lib_vio.c 2006-09-18 22:02:09 +04:00
@@ -229,6 +229,7 @@ my_bool vio_poll_read(Vio *vio,uint time
void vio_timeout(Vio *vio __attribute__((unused)),
+ uint which __attribute__((unused)),
uint timeout __attribute__((unused)))
{
}
--- 1.22/vio/viosocket.c 2006-09-18 22:02:09 +04:00
+++ 1.23/vio/viosocket.c 2006-09-18 22:02:09 +04:00
@@ -345,12 +345,26 @@ my_bool vio_poll_read(Vio *vio,uint time
}
-void vio_timeout(Vio *vio __attribute__((unused)),
- uint timeout __attribute__((unused)))
+void vio_timeout(Vio *vio, uint which, uint timeout)
{
+#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO)
+
#ifdef __WIN__
- ulong wait_timeout= (ulong) timeout * 1000;
- (void) setsockopt(vio->sd, SOL_SOCKET, 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__ */
+
+ (void) setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO,
+ (char*) &wait_timeout, sizeof(wait_timeout));
+
+#endif /* defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) */
}
| Thread |
|---|
| • bk commit into 4.0 tree (kroki:1.2194) BUG#9678 | kroki | 18 Sep |