summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorunknown <jani@ua141d10.elisa.omakaista.fi>2005-10-13 18:23:53 +0300
committerunknown <jani@ua141d10.elisa.omakaista.fi>2005-10-13 18:23:53 +0300
commit1e14067736bbff615f63e83129d64a17ad668390 (patch)
tree110201972d71b85d5c8e4bf068770a1ffd6fca61 /vio
parent99ed34376fde520a135756480334090db2a609a5 (diff)
parent0d8977475630b214e2c4eecb1a33330cf9f7283b (diff)
downloadmariadb-git-1e14067736bbff615f63e83129d64a17ad668390.tar.gz
Merge ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-4.1-tmp
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0 configure.in: Auto merged include/config-win.h: Auto merged include/m_string.h: Auto merged include/my_pthread.h: Auto merged myisam/mi_search.c: Auto merged mysql-test/r/cast.result: Auto merged mysql-test/t/cast.test: Auto merged mysql-test/t/select.test: Auto merged mysys/my_pthread.c: Auto merged mysys/thr_alarm.c: Auto merged netware/pack_isam.def: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged strings/ctype-big5.c: Auto merged strings/ctype-tis620.c: Auto merged strings/xml.c: Auto merged vio/vio.c: Auto merged vio/viosocket.c: Auto merged mysql-test/r/select.result: Merged from 4.1. netware/BUILD/mwenv: Merged from 4.1. scripts/make_binary_distribution.sh: Merged from 4.1. sql/mysqld.cc: Merged from 4.1. sql/sql_show.cc: Merged from 4.1. strings/my_strtoll10.c: Merged from 4.1.
Diffstat (limited to 'vio')
-rw-r--r--vio/vio.c16
-rw-r--r--vio/viosocket.c9
2 files changed, 20 insertions, 5 deletions
diff --git a/vio/vio.c b/vio/vio.c
index e444c634c96..d1e723f292d 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -149,10 +149,18 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, uint flags)
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 ea45d7ce5a7..5e0ed20b039 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -138,7 +138,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;