diff options
author | unknown <serg@sergbook.mysql.com> | 2004-12-31 15:26:24 +0100 |
---|---|---|
committer | unknown <serg@sergbook.mysql.com> | 2004-12-31 15:26:24 +0100 |
commit | b99bea6704299399c84bd8374ef7f248ff9570c5 (patch) | |
tree | 928b06c231edee4cb95ace87ed30e879e3dcb0fb /vio/viosocket.c | |
parent | bd23099be0b22845e8c97e2fb36ee3c6eb0e2491 (diff) | |
parent | 5eaf65ab4be77911eb03cceefac9ecea48c25f71 (diff) | |
download | mariadb-git-b99bea6704299399c84bd8374ef7f248ff9570c5.tar.gz |
manually merged
configure.in:
Auto merged
client/mysqldump.c:
Auto merged
innobase/buf/buf0rea.c:
Auto merged
innobase/dict/dict0load.c:
Auto merged
innobase/fil/fil0fil.c:
Auto merged
innobase/include/fil0fil.h:
Auto merged
innobase/include/row0mysql.h:
Auto merged
innobase/include/trx0trx.h:
Auto merged
innobase/os/os0file.c:
Auto merged
innobase/row/row0ins.c:
Auto merged
innobase/row/row0mysql.c:
Auto merged
innobase/row/row0sel.c:
Auto merged
innobase/srv/srv0start.c:
Auto merged
innobase/trx/trx0trx.c:
Auto merged
libmysqld/lib_sql.cc:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
mysql-test/r/alter_table.result:
Auto merged
mysql-test/r/ctype_ucs.result:
Auto merged
mysql-test/r/func_str.result:
Auto merged
mysql-test/r/grant.result:
Auto merged
mysql-test/r/grant_cache.result:
Auto merged
mysql-test/r/merge.result:
Auto merged
mysql-test/r/ndb_blob.result:
Auto merged
mysql-test/r/ps_1general.result:
Auto merged
mysql-test/r/subselect.result:
Auto merged
mysql-test/r/timezone2.result:
Auto merged
mysql-test/t/ctype_ucs.test:
Auto merged
mysql-test/t/grant.test:
Auto merged
mysql-test/t/merge.test:
Auto merged
mysql-test/t/multi_update.test:
Auto merged
mysql-test/t/mysqldump.test:
Auto merged
mysql-test/t/subselect.test:
Auto merged
ndb/src/ndbapi/NdbBlob.cpp:
Auto merged
ndb/src/ndbapi/NdbConnection.cpp:
Auto merged
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
Auto merged
ndb/src/ndbapi/NdbOperationDefine.cpp:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/ha_myisammrg.cc:
Auto merged
sql/ha_myisammrg.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_strfunc.cc:
Auto merged
sql/log.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql-common/client.c:
Auto merged
sql/sql_table.cc:
Auto merged
sql/strfunc.cc:
Auto merged
sql/unireg.cc:
Auto merged
vio/vio.c:
Auto merged
vio/viosocket.c:
Auto merged
Diffstat (limited to 'vio/viosocket.c')
-rw-r--r-- | vio/viosocket.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c index 2921eb7495e..de50dabba5f 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; @@ -429,7 +440,8 @@ int vio_write_shared_memory(Vio * vio, const gptr buf, int size) current_postion = buf; while (remain != 0) { - if (WaitForSingleObject(vio->event_server_read,vio->net->write_timeout*1000) != WAIT_OBJECT_0) + if (WaitForSingleObject(vio->event_server_read, vio->net->write_timeout*1000) + != WAIT_OBJECT_0) { DBUG_RETURN(-1); }; @@ -454,17 +466,29 @@ 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) */ + /* + Set event_conn_closed for notification of both client and server that + connection is closed + */ + SetEvent(vio->event_conn_closed); + /* + Close all handlers. UnmapViewOfFile and CloseHandle return non-zero + result if they are success. + */ + 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__ */ |