[glib] win32: handle ERROR_MORE_DATA



commit 4b5d762d5d73af90de49801ecc1da52d4cd86d6f
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Wed Aug 8 01:08:15 2012 +0200

    win32: handle ERROR_MORE_DATA
    
    If a named pipe is being read in message mode and the next message is
    longer than the nNumberOfBytesToRead parameter specifies, ReadFile
    returns FALSE and GetLastError returns ERROR_MORE_DATA.
    
    Since the API doesn't allow to return both a GError and the number of
    bytes read so far, it makes more sense to return nread, and let the
    client call GetLastError() himself to check if ERROR_MORE_DATA.
    
    The current alternative loses the nread information.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679288

 gio/gwin32inputstream.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gio/gwin32inputstream.c b/gio/gwin32inputstream.c
index 58b99e0..21af468 100644
--- a/gio/gwin32inputstream.c
+++ b/gio/gwin32inputstream.c
@@ -326,8 +326,17 @@ g_win32_input_stream_read (GInputStream  *stream,
         goto end;
 
       errsv = GetLastError ();
-      if (errsv == ERROR_HANDLE_EOF ||
-          errsv == ERROR_BROKEN_PIPE)
+      if (errsv == ERROR_MORE_DATA)
+        {
+          /* If a named pipe is being read in message mode and the
+           * next message is longer than the nNumberOfBytesToRead
+           * parameter specifies, ReadFile returns FALSE and
+           * GetLastError returns ERROR_MORE_DATA */
+          retval = nread;
+          goto end;
+        }
+      else if (errsv == ERROR_HANDLE_EOF ||
+               errsv == ERROR_BROKEN_PIPE)
         {
           /* TODO: the other end of a pipe may call the WriteFile
            * function with nNumberOfBytesToWrite set to zero. In this



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]