Commit 565f25a6 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-4.1/

into serg.mylan:/usr/home/serg/Abk/mysql-4.1
parents 52f1f012 85f57d22
...@@ -39,16 +39,17 @@ enum enum_vio_type ...@@ -39,16 +39,17 @@ enum enum_vio_type
Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost); Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost);
#ifdef __WIN__ #ifdef __WIN__
Vio* vio_new_win32pipe(HANDLE hPipe); Vio* vio_new_win32pipe(HANDLE hPipe);
Vio* vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, Vio* vio_new_win32shared_memory(NET *net,HANDLE handle_file_map,
HANDLE handle_map, HANDLE handle_map,
HANDLE event_server_wrote, HANDLE event_server_wrote,
HANDLE event_server_read, HANDLE event_server_read,
HANDLE event_client_wrote, HANDLE event_client_wrote,
HANDLE event_client_read); HANDLE event_client_read,
int vio_read_pipe(Vio *vio, gptr buf, int size); HANDLE event_conn_closed);
int vio_write_pipe(Vio *vio, const gptr buf, int size); int vio_read_pipe(Vio *vio, gptr buf, int size);
int vio_close_pipe(Vio * vio); int vio_write_pipe(Vio *vio, const gptr buf, int size);
int vio_close_pipe(Vio * vio);
#else #else
#define HANDLE void * #define HANDLE void *
#endif /* __WIN__ */ #endif /* __WIN__ */
...@@ -197,6 +198,7 @@ struct st_vio ...@@ -197,6 +198,7 @@ struct st_vio
HANDLE event_server_read; HANDLE event_server_read;
HANDLE event_client_wrote; HANDLE event_client_wrote;
HANDLE event_client_read; HANDLE event_client_read;
HANDLE event_conn_closed;
long shared_memory_remain; long shared_memory_remain;
char *shared_memory_pos; char *shared_memory_pos;
NET *net; NET *net;
......
...@@ -596,7 +596,8 @@ MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password= ...@@ -596,7 +596,8 @@ MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT"
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR TESTS_BINDIR export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES
export CLIENT_BINDIR TESTS_BINDIR CHARSETSDIR
export NDB_TOOLS_DIR export NDB_TOOLS_DIR
MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \ MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
......
...@@ -147,9 +147,9 @@ drop database mysqldump_test_db; ...@@ -147,9 +147,9 @@ drop database mysqldump_test_db;
CREATE TABLE t1 (a CHAR(10)); CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES (_latin1 ''); INSERT INTO t1 VALUES (_latin1 '');
--exec $MYSQL_DUMP --skip-comments test t1 --exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments test t1
--exec $MYSQL_DUMP --skip-comments --compatible=mysql323 test t1 --exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --compatible=mysql323 test t1
--exec $MYSQL_DUMP --skip-comments --compatible=mysql323 --default-character-set=cp850 test t1 --exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --compatible=mysql323 --default-character-set=cp850 test t1
--exec $MYSQL_DUMP --skip-comments --default-character-set=cp850 --compatible=mysql323 test t1 --exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=cp850 --compatible=mysql323 test t1
--exec $MYSQL_DUMP --skip-comments --default-character-set=utf8 --compatible=mysql323 test t1 --exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 test t1
DROP TABLE t1; DROP TABLE t1;
...@@ -396,6 +396,7 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) ...@@ -396,6 +396,7 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
HANDLE event_server_read = NULL; HANDLE event_server_read = NULL;
HANDLE event_client_wrote = NULL; HANDLE event_client_wrote = NULL;
HANDLE event_client_read = NULL; HANDLE event_client_read = NULL;
HANDLE event_conn_closed = NULL;
HANDLE handle_file_map = NULL; HANDLE handle_file_map = NULL;
ulong connect_number; ulong connect_number;
char connect_number_char[22], *p; char connect_number_char[22], *p;
...@@ -508,6 +509,13 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) ...@@ -508,6 +509,13 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
error_allow = CR_SHARED_MEMORY_EVENT_ERROR; error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2; goto err2;
} }
strmov(suffix_pos, "CONNECTION_CLOSED");
if ((event_conn_closed = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
{
error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
goto err2;
}
/* /*
Set event that server should send data Set event that server should send data
*/ */
...@@ -517,9 +525,9 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) ...@@ -517,9 +525,9 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
if (error_allow == 0) if (error_allow == 0)
{ {
net->vio= vio_new_win32shared_memory(net,handle_file_map,handle_map, 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_server_read,event_client_wrote,
event_client_read); event_client_read,event_conn_closed);
} }
else else
{ {
...@@ -532,6 +540,8 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) ...@@ -532,6 +540,8 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
CloseHandle(event_client_read); CloseHandle(event_client_read);
if (event_client_wrote) if (event_client_wrote)
CloseHandle(event_client_wrote); CloseHandle(event_client_wrote);
if (event_conn_closed)
CloseHandle(event_conn_closed);
if (handle_map) if (handle_map)
UnmapViewOfFile(handle_map); UnmapViewOfFile(handle_map);
if (handle_file_map) if (handle_file_map)
......
...@@ -3822,6 +3822,7 @@ pthread_handler_decl(handle_connections_shared_memory,arg) ...@@ -3822,6 +3822,7 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
HANDLE event_client_read= 0; // for transfer data server <-> client HANDLE event_client_read= 0; // for transfer data server <-> client
HANDLE event_server_wrote= 0; HANDLE event_server_wrote= 0;
HANDLE event_server_read= 0; HANDLE event_server_read= 0;
HANDLE event_conn_closed= 0;
THD *thd= 0; THD *thd= 0;
p= int10_to_str(connect_number, connect_number_char, 10); p= int10_to_str(connect_number, connect_number_char, 10);
...@@ -3852,29 +3853,35 @@ pthread_handler_decl(handle_connections_shared_memory,arg) ...@@ -3852,29 +3853,35 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
goto errorconn; goto errorconn;
} }
strmov(suffix_pos, "CLIENT_WROTE"); 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"; errmsg= "Could not create client write event";
goto errorconn; goto errorconn;
} }
strmov(suffix_pos, "CLIENT_READ"); 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"; errmsg= "Could not create client read event";
goto errorconn; goto errorconn;
} }
strmov(suffix_pos, "SERVER_READ"); 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"; errmsg= "Could not create server read event";
goto errorconn; goto errorconn;
} }
strmov(suffix_pos, "SERVER_WROTE"); 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"; errmsg= "Could not create server write event";
goto errorconn; goto errorconn;
} }
strmov(suffix_pos, "CONNECTION_CLOSED");
if ((event_conn_closed= CreateEvent(0, TRUE , FALSE, tmp)) == 0)
{
errmsg= "Could not create closed connection event";
goto errorconn;
}
if (abort_loop) if (abort_loop)
goto errorconn; goto errorconn;
if (!(thd= new THD)) if (!(thd= new THD))
...@@ -3893,13 +3900,14 @@ pthread_handler_decl(handle_connections_shared_memory,arg) ...@@ -3893,13 +3900,14 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
goto errorconn; goto errorconn;
} }
if (!(thd->net.vio= vio_new_win32shared_memory(&thd->net, if (!(thd->net.vio= vio_new_win32shared_memory(&thd->net,
handle_client_file_map, handle_client_file_map,
handle_client_map, handle_client_map,
event_client_wrote, event_client_wrote,
event_client_read, event_client_read,
event_server_wrote, event_server_wrote,
event_server_read)) || event_server_read,
my_net_init(&thd->net, thd->net.vio)) event_conn_closed)) ||
my_net_init(&thd->net, thd->net.vio))
{ {
close_connection(thd, ER_OUT_OF_RESOURCES, 1); close_connection(thd, ER_OUT_OF_RESOURCES, 1);
errmsg= 0; errmsg= 0;
...@@ -3919,12 +3927,20 @@ pthread_handler_decl(handle_connections_shared_memory,arg) ...@@ -3919,12 +3927,20 @@ pthread_handler_decl(handle_connections_shared_memory,arg)
NullS); NullS);
sql_perror(buff); sql_perror(buff);
} }
if (handle_client_file_map) CloseHandle(handle_client_file_map); if (handle_client_file_map)
if (handle_client_map) UnmapViewOfFile(handle_client_map); CloseHandle(handle_client_file_map);
if (event_server_wrote) CloseHandle(event_server_wrote); if (handle_client_map)
if (event_server_read) CloseHandle(event_server_read); UnmapViewOfFile(handle_client_map);
if (event_client_wrote) CloseHandle(event_client_wrote); if (event_server_wrote)
if (event_client_read) CloseHandle(event_client_read); 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; delete thd;
} }
......
...@@ -171,22 +171,24 @@ Vio *vio_new_win32pipe(HANDLE hPipe) ...@@ -171,22 +171,24 @@ Vio *vio_new_win32pipe(HANDLE hPipe)
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
Vio *vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, HANDLE handle_map, Vio *vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, HANDLE handle_map,
HANDLE event_server_wrote, HANDLE event_server_read, 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; Vio *vio;
DBUG_ENTER("vio_new_win32shared_memory"); DBUG_ENTER("vio_new_win32shared_memory");
if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME)))) if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME))))
{ {
vio_reset(vio, VIO_TYPE_SHARED_MEMORY, 0, 0, TRUE); vio_reset(vio, VIO_TYPE_SHARED_MEMORY, 0, 0, TRUE);
vio->handle_file_map = handle_file_map; vio->handle_file_map= handle_file_map;
vio->handle_map = handle_map; vio->handle_map= handle_map;
vio->event_server_wrote = event_server_wrote; vio->event_server_wrote= event_server_wrote;
vio->event_server_read = event_server_read; vio->event_server_read= event_server_read;
vio->event_client_wrote = event_client_wrote; vio->event_client_wrote= event_client_wrote;
vio->event_client_read = event_client_read; vio->event_client_read= event_client_read;
vio->shared_memory_remain = 0; vio->event_conn_closed= event_conn_closed;
vio->shared_memory_pos = handle_map; vio->shared_memory_remain= 0;
vio->net = net; vio->shared_memory_pos= handle_map;
vio->net= net;
strmov(vio->desc, "shared memory"); strmov(vio->desc, "shared memory");
} }
DBUG_RETURN(vio); DBUG_RETURN(vio);
......
...@@ -381,10 +381,21 @@ int vio_read_shared_memory(Vio * vio, gptr buf, int size) ...@@ -381,10 +381,21 @@ int vio_read_shared_memory(Vio * vio, gptr buf, int size)
{ {
if (vio->shared_memory_remain == 0) 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); DBUG_RETURN(-1);
}; };
vio->shared_memory_pos = vio->handle_map; vio->shared_memory_pos = vio->handle_map;
vio->shared_memory_remain = uint4korr((ulong*)vio->shared_memory_pos); vio->shared_memory_remain = uint4korr((ulong*)vio->shared_memory_pos);
vio->shared_memory_pos+=4; vio->shared_memory_pos+=4;
...@@ -429,7 +440,8 @@ int vio_write_shared_memory(Vio * vio, const gptr buf, int size) ...@@ -429,7 +440,8 @@ int vio_write_shared_memory(Vio * vio, const gptr buf, int size)
current_postion = buf; current_postion = buf;
while (remain != 0) 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); DBUG_RETURN(-1);
}; };
...@@ -454,17 +466,29 @@ int vio_close_shared_memory(Vio * vio) ...@@ -454,17 +466,29 @@ int vio_close_shared_memory(Vio * vio)
{ {
int r; int r;
DBUG_ENTER("vio_close_shared_memory"); DBUG_ENTER("vio_close_shared_memory");
r=UnmapViewOfFile(vio->handle_map) || CloseHandle(vio->event_server_wrote) || if (vio->type != VIO_CLOSED)
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) */ 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->type= VIO_CLOSED;
vio->sd= -1; vio->sd= -1;
DBUG_RETURN(r); DBUG_RETURN(!r);
} }
#endif /* HAVE_SMEM */ #endif /* HAVE_SMEM */
#endif /* __WIN__ */ #endif /* __WIN__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment