[gnio] Handle WOULD_BLOCK when writing



commit 67ec6bd7a4627d3bd7b5da29b308ca839236b73d
Author: Alexander Larsson <alexl redhat com>
Date:   Tue May 5 10:24:38 2009 +0200

    Handle WOULD_BLOCK when writing
    
    On win32 we can get WOULD_BLOCK even if we signal for write, so we need
    to at least handle this to make non-blocking work.
---
 test/server.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/test/server.c b/test/server.c
index 9a05f4b..68499b4 100644
--- a/test/server.c
+++ b/test/server.c
@@ -209,11 +209,24 @@ main (int argc,
 
 	  if (size < 0)
 	    {
-	      g_printerr ("Error sending to socket: %s\n",
-			  error->message);
-	      return 1;
+	      if (g_error_matches (error,
+				   G_IO_ERROR,
+				   G_IO_ERROR_WOULD_BLOCK))
+		{
+		  g_error_free (error);
+		  error = NULL;
+		  continue;
+		}
+	      else
+		{
+		  g_printerr ("Error sending to socket: %s\n",
+			      error->message);
+		  return 1;
+		}
 	    }
 
+	  g_print ("sent %" G_GSSIZE_FORMAT " bytes of data\n", size);
+
 	  if (size == 0)
 	    {
 	      g_printerr ("Unexpected short write\n");



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