diff options
author | unknown <wax@kishkin.ru> | 2004-12-14 19:24:19 +0500 |
---|---|---|
committer | unknown <wax@kishkin.ru> | 2004-12-14 19:24:19 +0500 |
commit | 79a0ed6232233f6c85c83fbee4e27e594a7149db (patch) | |
tree | 33fb11fbd7696108090cda9adc1e0eccfe052c1c /vio | |
parent | 820d68d9033ed566177a4ff9c2c4c1e98b0deb6e (diff) | |
download | mariadb-git-79a0ed6232233f6c85c83fbee4e27e594a7149db.tar.gz |
BUG#6056
(continue)
added event_conn_closed
replaced WaitForSingleObject on WaitForMultipleObjects
inserted a check in vio_close()
added SetEvent() for event_conn_closed
include/violite.h:
added event_conn_closed
sql-common/client.c:
added event_conn_closed
sql/mysqld.cc:
added event_conn_closed
vio/vio.c:
added event_conn_closed
vio/viosocket.c:
replaced WaitForSingleObject on WaitForMultipleObjects
inserted a check in vio_close()
added SetEvent() for event_conn_closed
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio.c | 4 | ||||
-rw-r--r-- | vio/viosocket.c | 31 |
2 files changed, 26 insertions, 9 deletions
diff --git a/vio/vio.c b/vio/vio.c index a356d8edeff..92d69dc5148 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -171,7 +171,8 @@ Vio *vio_new_win32pipe(HANDLE hPipe) #ifdef HAVE_SMEM Vio *vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, HANDLE handle_map, HANDLE event_server_wrote, HANDLE event_server_read, - HANDLE event_client_wrote, HANDLE event_client_read) + HANDLE event_client_wrote, HANDLE event_client_read, + HANDLE event_conn_closed) { Vio *vio; DBUG_ENTER("vio_new_win32shared_memory"); @@ -184,6 +185,7 @@ Vio *vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, HANDLE handle_m vio->event_server_read = event_server_read; vio->event_client_wrote = event_client_wrote; vio->event_client_read = event_client_read; + vio->event_conn_closed = event_conn_closed; vio->shared_memory_remain = 0; vio->shared_memory_pos = handle_map; vio->net = net; diff --git a/vio/viosocket.c b/vio/viosocket.c index 48a9058480a..caf9451df7a 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -381,10 +381,21 @@ int vio_read_shared_memory(Vio * vio, gptr buf, int size) { if (vio->shared_memory_remain == 0) { - if (WaitForSingleObject(vio->event_server_wrote,vio->net->read_timeout*1000) != WAIT_OBJECT_0) + HANDLE events[2]; + events[0]= vio->event_server_wrote; + events[1]= vio->event_conn_closed; + /* + WaitForMultipleObjects can return next values: + WAIT_OBJECT_0+0 - event from vio->event_server_wrote + WAIT_OBJECT_0+1 - event from vio->event_conn_closed. We can't read anything + WAIT_ABANDONED_0 and WAIT_TIMEOUT - fail. We can't read anything + */ + if (WaitForMultipleObjects(2,(HANDLE*)&events,FALSE, + vio->net->read_timeout*1000) != WAIT_OBJECT_0) { DBUG_RETURN(-1); }; + vio->shared_memory_pos = vio->handle_map; vio->shared_memory_remain = uint4korr((ulong*)vio->shared_memory_pos); vio->shared_memory_pos+=4; @@ -454,17 +465,21 @@ int vio_close_shared_memory(Vio * vio) { int r; DBUG_ENTER("vio_close_shared_memory"); - r=UnmapViewOfFile(vio->handle_map) || CloseHandle(vio->event_server_wrote) || - CloseHandle(vio->event_server_read) || CloseHandle(vio->event_client_wrote) || - CloseHandle(vio->event_client_read) || CloseHandle(vio->handle_file_map); - if (r) + if (vio->type != VIO_CLOSED) { - DBUG_PRINT("vio_error", ("close() failed, error: %d",r)); - /* FIXME: error handling (not critical for MySQL) */ + SetEvent(vio->event_conn_closed); + r=UnmapViewOfFile(vio->handle_map) || CloseHandle(vio->event_server_wrote) || + CloseHandle(vio->event_server_read) || CloseHandle(vio->event_client_wrote) || + CloseHandle(vio->event_client_read) || CloseHandle(vio->handle_file_map); + if (!r) + { + DBUG_PRINT("vio_error", ("close() failed, error: %d",r)); + /* FIXME: error handling (not critical for MySQL) */ + } } vio->type= VIO_CLOSED; vio->sd= -1; - DBUG_RETURN(r); + DBUG_RETURN(!r); } #endif /* HAVE_SMEM */ #endif /* __WIN__ */ |