[Commits] Rev 3473: MDEV-3822 :10.0-serg fails on windows buildslaves in file:///H:/bzr/10.0-serg/

Vladislav Vaintroub wlad at montyprogram.com
Sun Nov 4 22:04:14 EET 2012


At file:///H:/bzr/10.0-serg/

------------------------------------------------------------
revno: 3473
revision-id: wlad at montyprogram.com-20121104200404-dlu9sfihd1fyg81v
parent: psergey at askmonty.org-20121104153232-z3q54rbvvqbmvgom
committer: Vladislav Vaintroub <wlad at montyprogram.com>
branch nick: 10.0-serg
timestamp: Sun 2012-11-04 21:04:04 +0100
message:
  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.
-------------- next part --------------
=== modified file 'include/violite.h'
--- a/include/violite.h	2012-11-03 11:28:51 +0000
+++ b/include/violite.h	2012-11-04 20:04:04 +0000
@@ -287,7 +287,6 @@
   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

=== modified file 'vio/viopipe.c'
--- a/vio/viopipe.c	2012-08-30 09:36:24 +0000
+++ b/vio/viopipe.c	2012-11-04 20:04:04 +0000
@@ -34,42 +34,38 @@
   *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 @@
   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 @@
     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 @@
   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);
 }
 



More information about the commits mailing list