mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-3822 :10.0-serg fails on windows buildslaves
Fix mismerged code from 5.6 (named-pipe related). viopipe.c, which was introduced in 5.6 is now copied almost identically into 10.0 The unused vio::pipe_overlapped is removed.
This commit is contained in:
parent
5e68c5ce7d
commit
cdb54f480d
2 changed files with 26 additions and 50 deletions
|
@ -287,7 +287,6 @@ struct st_vio
|
|||
HANDLE hPipe;
|
||||
OVERLAPPED overlapped;
|
||||
DWORD thread_id; /* Used on XP only by vio_shutdown() */
|
||||
OVERLAPPED pipe_overlapped;
|
||||
DWORD read_timeout_ms;
|
||||
DWORD write_timeout_ms;
|
||||
#endif
|
||||
|
|
|
@ -34,42 +34,38 @@ static void enable_iocp_notification(OVERLAPPED *overlapped)
|
|||
*handle = (HANDLE)((ULONG_PTR) *handle & ~1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Finish pending IO on pipe. Honor wait timeout
|
||||
*/
|
||||
|
||||
static size_t wait_overlapped_result(Vio *vio, int timeout)
|
||||
{
|
||||
size_t ret= (size_t) -1;
|
||||
DWORD transferred, wait_status, timeout_ms;
|
||||
DBUG_ENTER("wait_overlapped_result");
|
||||
|
||||
timeout_ms= timeout >= 0 ? timeout : INFINITE;
|
||||
|
||||
/* Wait for the overlapped operation to be completed. */
|
||||
wait_status= WaitForSingleObjectEx(vio->pipe_overlapped.hEvent, timeout_ms, TRUE);
|
||||
wait_status= WaitForSingleObject(vio->overlapped.hEvent, timeout_ms);
|
||||
|
||||
/*
|
||||
WaitForSingleObjects will normally return WAIT_OBJECT_O (success,
|
||||
IO completed) or WAIT_TIMEOUT.
|
||||
*/
|
||||
if (ret != WAIT_OBJECT_0)
|
||||
/* The operation might have completed, attempt to retrieve the result. */
|
||||
if (wait_status == WAIT_OBJECT_0)
|
||||
{
|
||||
/* If retrieval fails, a error code will have been set. */
|
||||
if (GetOverlappedResult(vio->hPipe, &vio->overlapped, &transferred, FALSE))
|
||||
ret= transferred;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Error or timeout, cancel the pending I/O operation. */
|
||||
CancelIo(vio->hPipe);
|
||||
DBUG_PRINT("error",("WaitForSingleObject() returned %d", ret));
|
||||
|
||||
/*
|
||||
If the wait timed out, set error code to indicate a
|
||||
timeout error. Otherwise, wait_status is WAIT_FAILED
|
||||
and extended error information was already set.
|
||||
*/
|
||||
if (wait_status == WAIT_TIMEOUT)
|
||||
SetLastError(SOCKET_ETIMEDOUT);
|
||||
DBUG_RETURN((size_t)-1);
|
||||
}
|
||||
|
||||
if (!GetOverlappedResult(vio->hPipe,&(vio->overlapped),&transferred, FALSE))
|
||||
{
|
||||
DBUG_PRINT("error",("GetOverlappedResult() returned last error %d",
|
||||
GetLastError()));
|
||||
DBUG_RETURN((size_t)-1);
|
||||
}
|
||||
DBUG_RETURN(transferred);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,10 +74,9 @@ size_t vio_read_pipe(Vio *vio, uchar *buf, size_t count)
|
|||
DWORD transferred;
|
||||
size_t ret= (size_t) -1;
|
||||
DBUG_ENTER("vio_read_pipe");
|
||||
DBUG_PRINT("enter", ("sd: %p buf: %p size: %d", vio->hPipe, buf,
|
||||
(int) count));
|
||||
|
||||
disable_iocp_notification(&vio->overlapped);
|
||||
|
||||
/* Attempt to read from the pipe (overlapped I/O). */
|
||||
if (ReadFile(vio->hPipe, buf, count, &transferred, &vio->overlapped))
|
||||
{
|
||||
|
@ -89,19 +84,11 @@ size_t vio_read_pipe(Vio *vio, uchar *buf, size_t count)
|
|||
ret= transferred;
|
||||
}
|
||||
/* Read operation is pending completion asynchronously? */
|
||||
else
|
||||
{
|
||||
if (GetLastError() != ERROR_IO_PENDING)
|
||||
{
|
||||
enable_iocp_notification(&vio->pipe_overlapped);
|
||||
DBUG_PRINT("error",("ReadFile() returned last error %d",
|
||||
GetLastError()));
|
||||
DBUG_RETURN((size_t)-1);
|
||||
}
|
||||
else if (GetLastError() == ERROR_IO_PENDING)
|
||||
ret= wait_overlapped_result(vio, vio->read_timeout);
|
||||
}
|
||||
|
||||
enable_iocp_notification(&vio->overlapped);
|
||||
DBUG_PRINT("exit", ("%d", (int) ret));
|
||||
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
|
@ -111,29 +98,19 @@ size_t vio_write_pipe(Vio *vio, const uchar *buf, size_t count)
|
|||
DWORD transferred;
|
||||
size_t ret= (size_t) -1;
|
||||
DBUG_ENTER("vio_write_pipe");
|
||||
DBUG_PRINT("enter", ("sd: %d buf: %p size: %d", vio->hPipe, buf,
|
||||
(int) count));
|
||||
|
||||
disable_iocp_notification(&vio->pipe_overlapped);
|
||||
disable_iocp_notification(&vio->overlapped);
|
||||
/* Attempt to write to the pipe (overlapped I/O). */
|
||||
if (WriteFile(vio->hPipe, buf, count, &transferred, &vio->overlapped))
|
||||
{
|
||||
/* The operation completed immediately. */
|
||||
ret= transferred;
|
||||
}
|
||||
else
|
||||
{
|
||||
enable_iocp_notification(&vio->pipe_overlapped);
|
||||
if (GetLastError() != ERROR_IO_PENDING)
|
||||
{
|
||||
DBUG_PRINT("vio_error",("WriteFile() returned last error %d",
|
||||
GetLastError()));
|
||||
DBUG_RETURN((size_t)-1);
|
||||
}
|
||||
/* Write operation is pending completion asynchronously? */
|
||||
else if (GetLastError() == ERROR_IO_PENDING)
|
||||
ret= wait_overlapped_result(vio, vio->write_timeout);
|
||||
}
|
||||
enable_iocp_notification(&vio->pipe_overlapped);
|
||||
DBUG_PRINT("exit", ("%d", (int) ret));
|
||||
|
||||
enable_iocp_notification(&vio->overlapped);
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue