Some more debugging output. (g_io_channel_win32_poll): Remove unused vars.
[platform/upstream/glib.git] / giowin32.c
index 68fee3b..560d714 100644 (file)
@@ -201,6 +201,10 @@ reader_thread (void *parameter)
       nbytes = MIN ((channel->rdp + BUFFER_SIZE - channel->wrp - 1) % BUFFER_SIZE,
                    BUFFER_SIZE - channel->wrp);
 
+      if (channel->debug)
+       g_print ("thread %#x: calling reader for %d bytes\n",
+                channel->thread_id, nbytes);
+
       UNLOCK (channel->mutex);
 
       nbytes = (*channel->reader) (channel->fd, buffer, nbytes);
@@ -872,29 +876,38 @@ g_io_channel_win32_set_debug (GIOChannel *channel,
 }
 
 gint
-g_io_channel_win32_wait_for_condition (GIOChannel  *channel,
-                                      GIOCondition condition,
-                                      gint         timeout)
+g_io_channel_win32_poll (GPollFD *fds,
+                        gint     n_fds,
+                        gint     timeout)
 {
-  GPollFD pollfd;
-  GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
   int result;
 
-  pollfd.fd = (gint) win32_channel->data_avail_event;
-  pollfd.events = condition;
-
-  if (win32_channel->debug)
-    g_print ("g_io_channel_win32_wait_for_condition: fd:%d event:%#x timeout:%d\n",
-            win32_channel->fd, pollfd.fd, timeout);
+  g_return_val_if_fail (n_fds >= 0, 0);
 
-  result = (*g_main_win32_get_poll_func ()) (&pollfd, 1, timeout);
-
-  if (win32_channel->debug)
-    g_print ("g_io_channel_win32_wait_for_condition: done:%d\n", result);
+  result = (*g_main_win32_get_poll_func ()) (fds, n_fds, timeout);
 
   return result;
 }
 
+void
+g_io_channel_win32_make_pollfd (GIOChannel   *channel,
+                               GIOCondition  condition,
+                               GPollFD      *fd)
+{
+  GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
+
+  if (win32_channel->data_avail_event == NULL)
+    create_events (win32_channel);
+  
+  fd->fd = (gint) win32_channel->data_avail_event;
+  fd->events = condition;
+
+  if (win32_channel->thread_id == 0)
+    if (win32_channel->type == G_IO_FILE_DESC)
+      create_reader_thread (win32_channel, fd_reader);
+    else if (win32_channel->type == G_IO_STREAM_SOCKET)
+      create_reader_thread (win32_channel, sock_reader);
+}
 
 /* This variable and the functions below are present just to be 
  * binary compatible with old clients... But note that in GIMP, the