mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
fix indentation
add space after comma add space after equal add comments in vio_close_shared_memory()
This commit is contained in:
parent
a3e73fc673
commit
4788b15201
5 changed files with 64 additions and 48 deletions
|
@ -39,17 +39,17 @@ enum enum_vio_type
|
|||
|
||||
Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost);
|
||||
#ifdef __WIN__
|
||||
Vio* vio_new_win32pipe(HANDLE hPipe);
|
||||
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_conn_closed);
|
||||
int vio_read_pipe(Vio *vio, gptr buf, int size);
|
||||
int vio_write_pipe(Vio *vio, const gptr buf, int size);
|
||||
int vio_close_pipe(Vio * vio);
|
||||
Vio* vio_new_win32pipe(HANDLE hPipe);
|
||||
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_conn_closed);
|
||||
int vio_read_pipe(Vio *vio, gptr buf, int size);
|
||||
int vio_write_pipe(Vio *vio, const gptr buf, int size);
|
||||
int vio_close_pipe(Vio * vio);
|
||||
#else
|
||||
#define HANDLE void *
|
||||
#endif /* __WIN__ */
|
||||
|
|
|
@ -525,9 +525,9 @@ err2:
|
|||
if (error_allow == 0)
|
||||
{
|
||||
net->vio= vio_new_win32shared_memory(net,handle_file_map,handle_map,
|
||||
event_server_wrote,
|
||||
event_server_wrote,
|
||||
event_server_read,event_client_wrote,
|
||||
event_client_read,event_conn_closed);
|
||||
event_client_read,event_conn_closed);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3853,31 +3853,31 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
|
|||
goto errorconn;
|
||||
}
|
||||
strmov(suffix_pos, "CLIENT_WROTE");
|
||||
if ((event_client_wrote= CreateEvent(0,FALSE,FALSE,tmp)) == 0)
|
||||
if ((event_client_wrote= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
|
||||
{
|
||||
errmsg= "Could not create client write event";
|
||||
goto errorconn;
|
||||
}
|
||||
strmov(suffix_pos, "CLIENT_READ");
|
||||
if ((event_client_read= CreateEvent(0,FALSE,FALSE,tmp)) == 0)
|
||||
if ((event_client_read= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
|
||||
{
|
||||
errmsg= "Could not create client read event";
|
||||
goto errorconn;
|
||||
}
|
||||
strmov(suffix_pos, "SERVER_READ");
|
||||
if ((event_server_read= CreateEvent(0,FALSE,FALSE,tmp)) == 0)
|
||||
if ((event_server_read= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
|
||||
{
|
||||
errmsg= "Could not create server read event";
|
||||
goto errorconn;
|
||||
}
|
||||
strmov(suffix_pos, "SERVER_WROTE");
|
||||
if ((event_server_wrote= CreateEvent(0,FALSE,FALSE,tmp)) == 0)
|
||||
if ((event_server_wrote= CreateEvent(0, FALSE, FALSE, tmp)) == 0)
|
||||
{
|
||||
errmsg= "Could not create server write event";
|
||||
goto errorconn;
|
||||
}
|
||||
strmov(suffix_pos, "CONNECTION_CLOSED");
|
||||
if ((event_conn_closed= CreateEvent(0,TRUE,FALSE,tmp)) == 0)
|
||||
if ((event_conn_closed= CreateEvent(0, TRUE , FALSE, tmp)) == 0)
|
||||
{
|
||||
errmsg= "Could not create closed connection event";
|
||||
goto errorconn;
|
||||
|
@ -3900,14 +3900,14 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
|
|||
goto errorconn;
|
||||
}
|
||||
if (!(thd->net.vio= vio_new_win32shared_memory(&thd->net,
|
||||
handle_client_file_map,
|
||||
handle_client_map,
|
||||
event_client_wrote,
|
||||
event_client_read,
|
||||
event_server_wrote,
|
||||
event_server_read,
|
||||
handle_client_file_map,
|
||||
handle_client_map,
|
||||
event_client_wrote,
|
||||
event_client_read,
|
||||
event_server_wrote,
|
||||
event_server_read,
|
||||
event_conn_closed)) ||
|
||||
my_net_init(&thd->net, thd->net.vio))
|
||||
my_net_init(&thd->net, thd->net.vio))
|
||||
{
|
||||
close_connection(thd, ER_OUT_OF_RESOURCES, 1);
|
||||
errmsg= 0;
|
||||
|
@ -3927,13 +3927,20 @@ errorconn:
|
|||
NullS);
|
||||
sql_perror(buff);
|
||||
}
|
||||
if (handle_client_file_map) CloseHandle(handle_client_file_map);
|
||||
if (handle_client_map) UnmapViewOfFile(handle_client_map);
|
||||
if (event_server_wrote) CloseHandle(event_server_wrote);
|
||||
if (event_server_read) CloseHandle(event_server_read);
|
||||
if (event_client_wrote) CloseHandle(event_client_wrote);
|
||||
if (event_client_read) CloseHandle(event_client_read);
|
||||
if (event_conn_closed) CloseHandle(event_conn_closed);
|
||||
if (handle_client_file_map)
|
||||
CloseHandle(handle_client_file_map);
|
||||
if (handle_client_map)
|
||||
UnmapViewOfFile(handle_client_map);
|
||||
if (event_server_wrote)
|
||||
CloseHandle(event_server_wrote);
|
||||
if (event_server_read)
|
||||
CloseHandle(event_server_read);
|
||||
if (event_client_wrote)
|
||||
CloseHandle(event_client_wrote);
|
||||
if (event_client_read)
|
||||
CloseHandle(event_client_read);
|
||||
if (event_conn_closed)
|
||||
CloseHandle(event_conn_closed);
|
||||
delete thd;
|
||||
}
|
||||
|
||||
|
|
22
vio/vio.c
22
vio/vio.c
|
@ -172,23 +172,23 @@ Vio *vio_new_win32pipe(HANDLE hPipe)
|
|||
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_conn_closed)
|
||||
HANDLE event_conn_closed)
|
||||
{
|
||||
Vio *vio;
|
||||
DBUG_ENTER("vio_new_win32shared_memory");
|
||||
if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME))))
|
||||
{
|
||||
vio_reset(vio, VIO_TYPE_SHARED_MEMORY, 0, 0, TRUE);
|
||||
vio->handle_file_map = handle_file_map;
|
||||
vio->handle_map = handle_map;
|
||||
vio->event_server_wrote = event_server_wrote;
|
||||
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;
|
||||
vio->handle_file_map= handle_file_map;
|
||||
vio->handle_map= handle_map;
|
||||
vio->event_server_wrote= event_server_wrote;
|
||||
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;
|
||||
strmov(vio->desc, "shared memory");
|
||||
}
|
||||
DBUG_RETURN(vio);
|
||||
|
|
|
@ -390,7 +390,7 @@ int vio_read_shared_memory(Vio * vio, gptr buf, int size)
|
|||
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,
|
||||
if (WaitForMultipleObjects(2, (HANDLE*)&events,FALSE,
|
||||
vio->net->read_timeout*1000) != WAIT_OBJECT_0)
|
||||
{
|
||||
DBUG_RETURN(-1);
|
||||
|
@ -440,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);
|
||||
};
|
||||
|
@ -467,10 +468,18 @@ int vio_close_shared_memory(Vio * vio)
|
|||
DBUG_ENTER("vio_close_shared_memory");
|
||||
if (vio->type != VIO_CLOSED)
|
||||
{
|
||||
/*
|
||||
Set event_conn_closed for notification of both client and server that
|
||||
connection is closed
|
||||
*/
|
||||
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);
|
||||
/*
|
||||
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));
|
||||
|
|
Loading…
Reference in a new issue