[wing/wip/nacho/poll-stream] Handle the overlap result



commit 9e72ea58bf9328cd8c19a4fc402bfeb2380ddb02
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Wed Nov 28 17:58:51 2018 +0100

    Handle the overlap result

 wing/winginputstream.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/wing/winginputstream.c b/wing/winginputstream.c
index 41a54eb..e571d19 100644
--- a/wing/winginputstream.c
+++ b/wing/winginputstream.c
@@ -144,6 +144,22 @@ read_internal (GInputStream  *stream,
   if (g_cancellable_set_error_if_cancelled (cancellable, error))
     return -1;
 
+  if (!blocking && g_pollable_input_stream_is_readable (G_POLLABLE_INPUT_STREAM (stream)))
+    {
+      gboolean result;
+
+      result = GetOverlappedResult (priv->overlap.hEvent, &priv->overlap, &nread, FALSE);
+      if (!result && GetLastError () == ERROR_IO_INCOMPLETE)
+        {
+          g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK,
+                               g_strerror (EAGAIN));
+          return -1;
+        }
+
+      retval = nread;
+      goto end;
+    }
+
   if (count > G_MAXINT)
     nbytes = G_MAXINT;
   else


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