diff options
author | unknown <jimw@mysql.com> | 2005-10-11 09:12:12 -0700 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-10-11 09:12:12 -0700 |
commit | ad5f91e7f8d235d5d1faefcf613b7148e2ac02a7 (patch) | |
tree | 4607d81d45be27a727b93a40191ed4853e10f8ef /vio | |
parent | 619f70a64c67795309f3023ba34f3be97a54ba9c (diff) | |
download | mariadb-git-ad5f91e7f8d235d5d1faefcf613b7148e2ac02a7.tar.gz |
Fix wait_timeout (and kill) handling on Mac OS X by cleaning up how
signal handlers are set up, the blocking flags for sockets are set,
and which thread-related functions are used. (Bug #8731)
configure.in:
Fix flags for Darwin 6 and later. Simplify Darwin 7-9 blocks to simply
be a catch-all for *darwin* so that future Darwin releases get the
latest flags.
include/config-win.h:
Define my_sigset() instead of sigset().
include/my_pthread.h:
Define my_sigset() instead of trying to monkey with sigset(), and favor
an implementation based on sigaction().
mysys/my_pthread.c:
Remove pthread_signal(), which is identical to the new my_sigset() macro.
mysys/thr_alarm.c:
Use my_sigset() instead of sigset().
sql/mysqld.cc:
Use my_sigset() instead of signal() and sigset(), remove unnecessary
definition of sigset on __amiga__. Remove unused THREAD_SPECIFIC_SIGPIPE
code.
A future improvement would be to re-assess the use of sigaction() here
and convert its usage to use my_sigset().
vio/vio.c:
Always call fcntl() to initialize flags of socket in initialization to
avoid problems on systems that don't report the flags on a socket
correctly right after it has been returned from accept(), such as
FreeBSD, Mac OS X, and possibly other BSD-derived systems.
vio/viosocket.c:
If fcntl() fails in vio_blocking(), restore the flags stored in the
vio struct.
mysql-test/r/wait_timeout.result:
New BitKeeper file ``mysql-test/r/wait_timeout.result''
mysql-test/t/wait_timeout-master.opt:
New BitKeeper file ``mysql-test/t/wait_timeout-master.opt''
mysql-test/t/wait_timeout.test:
New BitKeeper file ``mysql-test/t/wait_timeout.test''
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio.c | 16 | ||||
-rw-r--r-- | vio/viosocket.c | 9 |
2 files changed, 20 insertions, 5 deletions
diff --git a/vio/vio.c b/vio/vio.c index 45572b93ed6..f60a53d2f04 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -136,10 +136,18 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) vio->sd); #if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(NO_FCNTL_NONBLOCK) -#if defined(__FreeBSD__) - fcntl(sd, F_SETFL, vio->fcntl_mode); /* Yahoo! FreeBSD patch */ -#endif - vio->fcntl_mode = fcntl(sd, F_GETFL); + /* + We call fcntl() to set the flags and then immediately read them back + to make sure that we and the system are in agreement on the state of + things. + + An example of why we need to do this is FreeBSD (and apparently some + other BSD-derived systems, like Mac OS X), where the system sometimes + reports that the socket is set for non-blocking when it really will + block. + */ + fcntl(sd, F_SETFL, vio->fcntl_mode); + vio->fcntl_mode= fcntl(sd, F_GETFL); #elif defined(HAVE_SYS_IOCTL_H) /* hpux */ /* Non blocking sockets doesn't work good on HPUX 11.0 */ (void) ioctl(sd,FIOSNBIO,0); diff --git a/vio/viosocket.c b/vio/viosocket.c index 5213390e2e6..8d4c2387632 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -92,7 +92,14 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode, else vio->fcntl_mode |= O_NONBLOCK; /* set bit */ if (old_fcntl != vio->fcntl_mode) - r = fcntl(vio->sd, F_SETFL, vio->fcntl_mode); + { + r= fcntl(vio->sd, F_SETFL, vio->fcntl_mode); + if (r == -1) + { + DBUG_PRINT("info", ("fcntl failed, errno %d", errno)); + vio->fcntl_mode= old_fcntl; + } + } } #else r= set_blocking_mode ? 0 : 1; |