Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
78da7343
Commit
78da7343
authored
Nov 20, 2009
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#47571 : idle named pipe connection is unkillable
implement Davi's review suggestions (post-push fixes)
parent
349f48e1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
49 deletions
+60
-49
include/violite.h
include/violite.h
+2
-2
sql/mysqld.cc
sql/mysqld.cc
+11
-5
vio/vio.c
vio/vio.c
+18
-22
vio/viosocket.c
vio/viosocket.c
+29
-20
No files found.
include/violite.h
View file @
78da7343
...
@@ -224,8 +224,8 @@ struct st_vio
...
@@ -224,8 +224,8 @@ struct st_vio
#endif
/* HAVE_SMEM */
#endif
/* HAVE_SMEM */
#ifdef _WIN32
#ifdef _WIN32
OVERLAPPED
pipe_overlapped
;
OVERLAPPED
pipe_overlapped
;
DWORD
read_timeout_m
illi
s
;
DWORD
read_timeout_ms
;
DWORD
write_timeout_m
illi
s
;
DWORD
write_timeout_ms
;
#endif
#endif
};
};
#endif
/* vio_violite_h_ */
#endif
/* vio_violite_h_ */
sql/mysqld.cc
View file @
78da7343
...
@@ -5224,12 +5224,16 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
...
@@ -5224,12 +5224,16 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
pthread_handler_t
handle_connections_namedpipes
(
void
*
arg
)
pthread_handler_t
handle_connections_namedpipes
(
void
*
arg
)
{
{
HANDLE
hConnectedPipe
;
HANDLE
hConnectedPipe
;
OVERLAPPED
connectOverlapped
=
{
0
};
OVERLAPPED
connectOverlapped
=
{
0
};
THD
*
thd
;
THD
*
thd
;
my_thread_init
();
my_thread_init
();
DBUG_ENTER
(
"handle_connections_namedpipes"
);
DBUG_ENTER
(
"handle_connections_namedpipes"
);
connectOverlapped
.
hEvent
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
connectOverlapped
.
hEvent
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
if
(
!
connectOverlapped
.
hEvent
)
{
sql_print_error
(
"Can't create event, last error=%u"
,
GetLastError
());
unireg_abort
(
1
);
}
DBUG_PRINT
(
"general"
,(
"Waiting for named pipe connections."
));
DBUG_PRINT
(
"general"
,(
"Waiting for named pipe connections."
));
while
(
!
abort_loop
)
while
(
!
abort_loop
)
{
{
...
@@ -5252,7 +5256,8 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
...
@@ -5252,7 +5256,8 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
{
{
CloseHandle
(
hPipe
);
CloseHandle
(
hPipe
);
if
((
hPipe
=
CreateNamedPipe
(
pipe_name
,
if
((
hPipe
=
CreateNamedPipe
(
pipe_name
,
PIPE_ACCESS_DUPLEX
|
FILE_FLAG_OVERLAPPED
,
PIPE_ACCESS_DUPLEX
|
FILE_FLAG_OVERLAPPED
,
PIPE_TYPE_BYTE
|
PIPE_TYPE_BYTE
|
PIPE_READMODE_BYTE
|
PIPE_READMODE_BYTE
|
PIPE_WAIT
,
PIPE_WAIT
,
...
@@ -5272,7 +5277,8 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
...
@@ -5272,7 +5277,8 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
hConnectedPipe
=
hPipe
;
hConnectedPipe
=
hPipe
;
/* create new pipe for new connection */
/* create new pipe for new connection */
if
((
hPipe
=
CreateNamedPipe
(
pipe_name
,
if
((
hPipe
=
CreateNamedPipe
(
pipe_name
,
PIPE_ACCESS_DUPLEX
|
FILE_FLAG_OVERLAPPED
,
PIPE_ACCESS_DUPLEX
|
FILE_FLAG_OVERLAPPED
,
PIPE_TYPE_BYTE
|
PIPE_TYPE_BYTE
|
PIPE_READMODE_BYTE
|
PIPE_READMODE_BYTE
|
PIPE_WAIT
,
PIPE_WAIT
,
...
...
vio/vio.c
View file @
78da7343
...
@@ -62,10 +62,8 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
...
@@ -62,10 +62,8 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
vio
->
timeout
=
vio_win32_timeout
;
vio
->
timeout
=
vio_win32_timeout
;
/* Set default timeout */
/* Set default timeout */
vio
->
read_timeout_millis
=
INFINITE
;
vio
->
read_timeout_ms
=
INFINITE
;
vio
->
write_timeout_millis
=
INFINITE
;
vio
->
write_timeout_ms
=
INFINITE
;
memset
(
&
(
vio
->
pipe_overlapped
),
0
,
sizeof
(
OVERLAPPED
));
vio
->
pipe_overlapped
.
hEvent
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
vio
->
pipe_overlapped
.
hEvent
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -90,8 +88,8 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
...
@@ -90,8 +88,8 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
/* Currently, shared memory is on Windows only, hence the below is ok*/
/* Currently, shared memory is on Windows only, hence the below is ok*/
vio
->
timeout
=
vio_win32_timeout
;
vio
->
timeout
=
vio_win32_timeout
;
/* Set default timeout */
/* Set default timeout */
vio
->
read_timeout_m
illi
s
=
INFINITE
;
vio
->
read_timeout_ms
=
INFINITE
;
vio
->
write_timeout_m
illi
s
=
INFINITE
;
vio
->
write_timeout_ms
=
INFINITE
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
#endif
#endif
...
@@ -115,7 +113,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
...
@@ -115,7 +113,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
#endif
/* HAVE_OPENSSL */
#endif
/* HAVE_OPENSSL */
{
vio
->
viodelete
=
vio_delete
;
vio
->
viodelete
=
vio_delete
;
vio
->
vioerrno
=
vio_errno
;
vio
->
vioerrno
=
vio_errno
;
vio
->
read
=
(
flags
&
VIO_BUFFERED_READ
)
?
vio_read_buff
:
vio_read
;
vio
->
read
=
(
flags
&
VIO_BUFFERED_READ
)
?
vio_read_buff
:
vio_read
;
...
@@ -130,7 +127,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
...
@@ -130,7 +127,6 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
vio
->
vioblocking
=
vio_blocking
;
vio
->
vioblocking
=
vio_blocking
;
vio
->
is_blocking
=
vio_is_blocking
;
vio
->
is_blocking
=
vio_is_blocking
;
vio
->
timeout
=
vio_timeout
;
vio
->
timeout
=
vio_timeout
;
}
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
...
vio/viosocket.c
View file @
78da7343
...
@@ -415,14 +415,14 @@ void vio_timeout(Vio *vio, uint which, uint timeout)
...
@@ -415,14 +415,14 @@ void vio_timeout(Vio *vio, uint which, uint timeout)
/*
/*
Finish pending IO on pipe. Honor wait timeout
Finish pending IO on pipe. Honor wait timeout
*/
*/
static
int
pipe_complete_io
(
Vio
*
vio
,
char
*
buf
,
size_t
size
,
DWORD
timeout_milli
s
)
static
size_t
pipe_complete_io
(
Vio
*
vio
,
char
*
buf
,
size_t
size
,
DWORD
timeout_m
s
)
{
{
DWORD
length
;
DWORD
length
;
DWORD
ret
;
DWORD
ret
;
DBUG_ENTER
(
"pipe_complete_io"
);
DBUG_ENTER
(
"pipe_complete_io"
);
ret
=
WaitForSingleObject
(
vio
->
pipe_overlapped
.
hEvent
,
timeout_m
illi
s
);
ret
=
WaitForSingleObject
(
vio
->
pipe_overlapped
.
hEvent
,
timeout_ms
);
/*
/*
WaitForSingleObjects will normally return WAIT_OBJECT_O (success, IO completed)
WaitForSingleObjects will normally return WAIT_OBJECT_O (success, IO completed)
or WAIT_TIMEOUT.
or WAIT_TIMEOUT.
...
@@ -431,14 +431,14 @@ static int pipe_complete_io(Vio* vio, char* buf, size_t size, DWORD timeout_mill
...
@@ -431,14 +431,14 @@ static int pipe_complete_io(Vio* vio, char* buf, size_t size, DWORD timeout_mill
{
{
CancelIo
(
vio
->
hPipe
);
CancelIo
(
vio
->
hPipe
);
DBUG_PRINT
(
"error"
,(
"WaitForSingleObject() returned %d"
,
ret
));
DBUG_PRINT
(
"error"
,(
"WaitForSingleObject() returned %d"
,
ret
));
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
(
size_t
)
-
1
);
}
}
if
(
!
GetOverlappedResult
(
vio
->
hPipe
,
&
(
vio
->
pipe_overlapped
),
&
length
,
FALSE
))
if
(
!
GetOverlappedResult
(
vio
->
hPipe
,
&
(
vio
->
pipe_overlapped
),
&
length
,
FALSE
))
{
{
DBUG_PRINT
(
"error"
,(
"GetOverlappedResult() returned last error %d"
,
DBUG_PRINT
(
"error"
,(
"GetOverlappedResult() returned last error %d"
,
GetLastError
()));
GetLastError
()));
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
(
size_t
)
-
1
);
}
}
DBUG_RETURN
(
length
);
DBUG_RETURN
(
length
);
...
@@ -448,12 +448,17 @@ static int pipe_complete_io(Vio* vio, char* buf, size_t size, DWORD timeout_mill
...
@@ -448,12 +448,17 @@ static int pipe_complete_io(Vio* vio, char* buf, size_t size, DWORD timeout_mill
size_t
vio_read_pipe
(
Vio
*
vio
,
uchar
*
buf
,
size_t
size
)
size_t
vio_read_pipe
(
Vio
*
vio
,
uchar
*
buf
,
size_t
size
)
{
{
DWORD
bytes_read
;
DWORD
bytes_read
;
size_t
retval
;
DBUG_ENTER
(
"vio_read_pipe"
);
DBUG_ENTER
(
"vio_read_pipe"
);
DBUG_PRINT
(
"enter"
,
(
"sd: %d buf: 0x%lx size: %u"
,
vio
->
sd
,
(
long
)
buf
,
DBUG_PRINT
(
"enter"
,
(
"sd: %d buf: 0x%lx size: %u"
,
vio
->
sd
,
(
long
)
buf
,
(
uint
)
size
));
(
uint
)
size
));
if
(
!
ReadFile
(
vio
->
hPipe
,
buf
,
(
DWORD
)
size
,
&
bytes_read
,
if
(
ReadFile
(
vio
->
hPipe
,
buf
,
(
DWORD
)
size
,
&
bytes_read
,
&
(
vio
->
pipe_overlapped
)))
&
(
vio
->
pipe_overlapped
)))
{
retval
=
bytes_read
;
}
else
{
{
if
(
GetLastError
()
!=
ERROR_IO_PENDING
)
if
(
GetLastError
()
!=
ERROR_IO_PENDING
)
{
{
...
@@ -461,23 +466,28 @@ size_t vio_read_pipe(Vio * vio, uchar *buf, size_t size)
...
@@ -461,23 +466,28 @@ size_t vio_read_pipe(Vio * vio, uchar *buf, size_t size)
GetLastError
()));
GetLastError
()));
DBUG_RETURN
((
size_t
)
-
1
);
DBUG_RETURN
((
size_t
)
-
1
);
}
}
bytes_read
=
pipe_complete_io
(
vio
,
buf
,
size
,
vio
->
read_timeout_milli
s
);
retval
=
pipe_complete_io
(
vio
,
buf
,
size
,
vio
->
read_timeout_m
s
);
}
}
DBUG_PRINT
(
"exit"
,
(
"%
d"
,
bytes_read
));
DBUG_PRINT
(
"exit"
,
(
"%
lld"
,
(
longlong
)
retval
));
DBUG_RETURN
(
bytes_read
);
DBUG_RETURN
(
retval
);
}
}
size_t
vio_write_pipe
(
Vio
*
vio
,
const
uchar
*
buf
,
size_t
size
)
size_t
vio_write_pipe
(
Vio
*
vio
,
const
uchar
*
buf
,
size_t
size
)
{
{
DWORD
bytes_written
;
DWORD
bytes_written
;
size_t
retval
;
DBUG_ENTER
(
"vio_write_pipe"
);
DBUG_ENTER
(
"vio_write_pipe"
);
DBUG_PRINT
(
"enter"
,
(
"sd: %d buf: 0x%lx size: %u"
,
vio
->
sd
,
(
long
)
buf
,
DBUG_PRINT
(
"enter"
,
(
"sd: %d buf: 0x%lx size: %u"
,
vio
->
sd
,
(
long
)
buf
,
(
uint
)
size
));
(
uint
)
size
));
if
(
!
WriteFile
(
vio
->
hPipe
,
buf
,
(
DWORD
)
size
,
&
bytes_written
,
if
(
WriteFile
(
vio
->
hPipe
,
buf
,
(
DWORD
)
size
,
&
bytes_written
,
&
(
vio
->
pipe_overlapped
)))
&
(
vio
->
pipe_overlapped
)))
{
retval
=
bytes_written
;
}
else
{
{
if
(
GetLastError
()
!=
ERROR_IO_PENDING
)
if
(
GetLastError
()
!=
ERROR_IO_PENDING
)
{
{
...
@@ -485,12 +495,11 @@ size_t vio_write_pipe(Vio * vio, const uchar* buf, size_t size)
...
@@ -485,12 +495,11 @@ size_t vio_write_pipe(Vio * vio, const uchar* buf, size_t size)
GetLastError
()));
GetLastError
()));
DBUG_RETURN
((
size_t
)
-
1
);
DBUG_RETURN
((
size_t
)
-
1
);
}
}
bytes_written
=
pipe_complete_io
(
vio
,
(
char
*
)
buf
,
size
,
retval
=
pipe_complete_io
(
vio
,
(
char
*
)
buf
,
size
,
vio
->
write_timeout_ms
);
vio
->
write_timeout_millis
);
}
}
DBUG_PRINT
(
"exit"
,
(
"%
d"
,
bytes_written
));
DBUG_PRINT
(
"exit"
,
(
"%
lld"
,
(
longlong
)
retval
));
DBUG_RETURN
(
bytes_written
);
DBUG_RETURN
(
retval
);
}
}
...
@@ -515,21 +524,21 @@ int vio_close_pipe(Vio * vio)
...
@@ -515,21 +524,21 @@ int vio_close_pipe(Vio * vio)
void
vio_win32_timeout
(
Vio
*
vio
,
uint
which
,
uint
timeout_sec
)
void
vio_win32_timeout
(
Vio
*
vio
,
uint
which
,
uint
timeout_sec
)
{
{
DWORD
timeout_m
illi
s
;
DWORD
timeout_ms
;
/*
/*
Windows is measuring timeouts in milliseconds. Check for possible int
Windows is measuring timeouts in milliseconds. Check for possible int
overflow.
overflow.
*/
*/
if
(
timeout_sec
>
UINT_MAX
/
1000
)
if
(
timeout_sec
>
UINT_MAX
/
1000
)
timeout_m
illi
s
=
INFINITE
;
timeout_ms
=
INFINITE
;
else
else
timeout_m
illi
s
=
timeout_sec
*
1000
;
timeout_ms
=
timeout_sec
*
1000
;
/* which == 1 means "write", which == 0 means "read".*/
/* which == 1 means "write", which == 0 means "read".*/
if
(
which
)
if
(
which
)
vio
->
write_timeout_m
illis
=
timeout_milli
s
;
vio
->
write_timeout_m
s
=
timeout_m
s
;
else
else
vio
->
read_timeout_m
illis
=
timeout_milli
s
;
vio
->
read_timeout_m
s
=
timeout_m
s
;
}
}
...
@@ -564,7 +573,7 @@ size_t vio_read_shared_memory(Vio * vio, uchar* buf, size_t size)
...
@@ -564,7 +573,7 @@ size_t vio_read_shared_memory(Vio * vio, uchar* buf, size_t size)
WAIT_ABANDONED_0 and WAIT_TIMEOUT - fail. We can't read anything
WAIT_ABANDONED_0 and WAIT_TIMEOUT - fail. We can't read anything
*/
*/
if
(
WaitForMultipleObjects
(
array_elements
(
events
),
events
,
FALSE
,
if
(
WaitForMultipleObjects
(
array_elements
(
events
),
events
,
FALSE
,
vio
->
read_timeout_m
illi
s
)
!=
WAIT_OBJECT_0
)
vio
->
read_timeout_ms
)
!=
WAIT_OBJECT_0
)
{
{
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
};
};
...
@@ -621,7 +630,7 @@ size_t vio_write_shared_memory(Vio * vio, const uchar* buf, size_t size)
...
@@ -621,7 +630,7 @@ size_t vio_write_shared_memory(Vio * vio, const uchar* buf, size_t size)
while
(
remain
!=
0
)
while
(
remain
!=
0
)
{
{
if
(
WaitForMultipleObjects
(
array_elements
(
events
),
events
,
FALSE
,
if
(
WaitForMultipleObjects
(
array_elements
(
events
),
events
,
FALSE
,
vio
->
write_timeout_m
illi
s
)
!=
WAIT_OBJECT_0
)
vio
->
write_timeout_ms
)
!=
WAIT_OBJECT_0
)
{
{
DBUG_RETURN
((
size_t
)
-
1
);
DBUG_RETURN
((
size_t
)
-
1
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment