diff options
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio.c | 3 | ||||
-rw-r--r-- | vio/viosocket.c | 8 | ||||
-rw-r--r-- | vio/viossl.c | 9 |
3 files changed, 16 insertions, 4 deletions
diff --git a/vio/vio.c b/vio/vio.c index 67cb7ec95cd..bb97f195110 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -83,6 +83,7 @@ void vio_reset(Vio* vio, enum enum_vio_type type, DBUG_VOID_RETURN; } + /* Open the socket or TCP/IP connection and read the fnctl() status */ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) @@ -102,12 +103,14 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) #elif defined(HAVE_SYS_IOCTL_H) /* hpux */ /* Non blocking sockets doesn't work good on HPUX 11.0 */ (void) ioctl(sd,FIOSNBIO,0); + vio->fcntl_mode &= ~O_NONBLOCK; #endif #else /* !defined(__WIN__) && !defined(__EMX__) */ { /* set to blocking mode by default */ ulong arg=0, r; r = ioctlsocket(sd,FIONBIO,(void*) &arg, sizeof(arg)); + vio->fcntl_mode &= ~O_NONBLOCK; } #endif } diff --git a/vio/viosocket.c b/vio/viosocket.c index dc2bfaa6e0c..176af25b395 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -110,11 +110,15 @@ int vio_write(Vio * vio, const gptr buf, int size) } -int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode) +int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode, + my_bool *old_mode) { int r=0; DBUG_ENTER("vio_blocking"); - DBUG_PRINT("enter", ("set_blocking_mode: %d", (int) set_blocking_mode)); + + *old_mode= test(!(vio->fcntl_mode & O_NONBLOCK)); + DBUG_PRINT("enter", ("set_blocking_mode: %d old_mode: %d", + (int) set_blocking_mode, (int) *old_mode)); #if !defined(HAVE_OPENSSL) #if !defined(___WIN__) && !defined(__EMX__) diff --git a/vio/viossl.c b/vio/viossl.c index 6d85b119f20..7365bdc3daf 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -259,8 +259,10 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) char *str; char buf[1024]; X509* client_cert; + my_bool unused; DBUG_ENTER("sslaccept"); DBUG_PRINT("enter", ("sd=%d ptr=%p", vio->sd,ptr)); + vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); vio->ssl_=0; vio->open_=FALSE; @@ -272,7 +274,7 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) } DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); SSL_clear(vio->ssl_); - vio_blocking(vio, FALSE); + vio_blocking(vio, FALSE, &unused); SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); SSL_set_fd(vio->ssl_,vio->sd); SSL_set_accept_state(vio->ssl_); @@ -310,12 +312,15 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) DBUG_VOID_RETURN; } + void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) { char *str; X509* server_cert; + my_bool unused; DBUG_ENTER("sslconnect"); DBUG_PRINT("enter", ("sd=%d ptr=%p ctx: %p", vio->sd,ptr,ptr->ssl_context_)); + vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); vio->ssl_=0; vio->open_=FALSE; @@ -327,7 +332,7 @@ void sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) } DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); SSL_clear(vio->ssl_); - vio_blocking(vio, FALSE); + vio_blocking(vio, FALSE, &unused); SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); SSL_set_fd (vio->ssl_, vio->sd); SSL_set_connect_state(vio->ssl_); |