[gnet-dev] Win32 message processing bugfix



I had this GNet/win32 patch lying around on my system. I made it against
CVS over a month ago, so the bug may already have been fixed.

It fixes a problem that lead to name lookup results not being processed
when you triggered more than one lookup in a short time interval. The
callback now processes all pending windows messages when it's invoked.

The indenting might be a bit weird, but I found two different styles in
the source already there, and wasn't sure which to go with. Hope it's
useful anyway.

-- 
Hans Petter
? gnet-win32-process-msgs.patch
Index: src/gnet-private.c
===================================================================
RCS file: /cvs/gnome/gnet/src/gnet-private.c,v
retrieving revision 1.25
diff -u -p -r1.25 gnet-private.c
--- src/gnet-private.c	13 May 2003 05:29:55 -0000	1.25
+++ src/gnet-private.c	21 Jun 2003 21:59:27 -0000
@@ -184,43 +184,41 @@ gnet_MainCallBack(GIOChannel *iochannel,
   int i;
 
   /*Take the msg off the message queue */
-  i = PeekMessage (&msg, gnet_hWnd, 0, 0, PM_REMOVE); 
-  if (!i)
-    return 1; /* you have a buggy version of glib that is calling this func when it shouldn't*/
-
-  switch (msg.message) 
+  while ((i = PeekMessage (&msg, gnet_hWnd, 0, 0, PM_REMOVE)))
     {
-    case IA_NEW_MSG:
+    switch (msg.message) 
       {
-	WaitForSingleObject(gnet_Mutex, INFINITE);
-	data = g_hash_table_lookup(gnet_hash, (gpointer)msg.wParam);
-	g_hash_table_remove(gnet_hash, (gpointer)msg.wParam);
-	ReleaseMutex(gnet_Mutex);
+      case IA_NEW_MSG:
+        {
+	  WaitForSingleObject(gnet_Mutex, INFINITE);
+	  data = g_hash_table_lookup(gnet_hash, (gpointer)msg.wParam);
+	  g_hash_table_remove(gnet_hash, (gpointer)msg.wParam);
+	  ReleaseMutex(gnet_Mutex);
 		
-	IAstate = (GInetAddrNewListState*) data;
-	IAstate->errorcode = WSAGETASYNCERROR(msg.lParam); /* NULL if OK */
+	  IAstate = (GInetAddrNewListState*) data;
+	  IAstate->errorcode = WSAGETASYNCERROR(msg.lParam); /* NULL if OK */
 
-	/* Now call the callback function */
-	gnet_inetaddr_new_list_async_cb(NULL, G_IO_IN, (gpointer)IAstate);
+	  /* Now call the callback function */
+	  gnet_inetaddr_new_list_async_cb(NULL, G_IO_IN, (gpointer)IAstate);
 
-	break;
-      }
-    case GET_NAME_MSG:
-      {
-	WaitForSingleObject(gnet_Mutex, INFINITE);
-	data = g_hash_table_lookup(gnet_hash, (gpointer)msg.wParam);
-	g_hash_table_remove(gnet_hash, (gpointer)msg.wParam);
-	ReleaseMutex(gnet_Mutex);
+	  break;
+        }
+      case GET_NAME_MSG:
+        {
+	  WaitForSingleObject(gnet_Mutex, INFINITE);
+	  data = g_hash_table_lookup(gnet_hash, (gpointer)msg.wParam);
+	  g_hash_table_remove(gnet_hash, (gpointer)msg.wParam);
+	  ReleaseMutex(gnet_Mutex);
 
-	IARstate = (GInetAddrReverseAsyncState*) data;
-	IARstate->errorcode = WSAGETASYNCERROR(msg.lParam); /* NULL if OK */
+	  IARstate = (GInetAddrReverseAsyncState*) data;
+	  IARstate->errorcode = WSAGETASYNCERROR(msg.lParam); /* NULL if OK */
 			
-	/* Now call the callback function */
-	gnet_inetaddr_get_name_async_cb(NULL, G_IO_IN, (gpointer)IARstate);
-	break;
+	  /* Now call the callback function */
+	  gnet_inetaddr_get_name_async_cb(NULL, G_IO_IN, (gpointer)IARstate);
+	  break;
+        }
       }
     }
-
   return 1;
 }
 


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