Hmm, the parameter to g_io_channel_win32_poll() should be a GPollFD array,

2000-08-27  Tor Lillqvist  <tml@iki.fi>

Hmm, the parameter to g_io_channel_win32_poll() should be
a GPollFD array, not GIOChannel. That way the caller can know which
channels cause the callback.
This commit is contained in:
Tor Lillqvist 2000-08-27 15:33:15 +00:00 committed by Tor Lillqvist
parent 3d0a1b3b22
commit 55cd16c993
12 changed files with 34 additions and 88 deletions

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -2,7 +2,7 @@
* giowin32.c (g_io_channel_win32_poll): New function, otherwise * giowin32.c (g_io_channel_win32_poll): New function, otherwise
like g_io_channel_win32_wait_for_condition(), but accept several like g_io_channel_win32_wait_for_condition(), but accept several
GIOChannels. GPollFDs.
(g_io_channel_win32_wait_for_condition): Call (g_io_channel_win32_wait_for_condition): Call
g_io_channel_win32_poll(). g_io_channel_win32_poll().

View File

@ -872,51 +872,18 @@ g_io_channel_win32_set_debug (GIOChannel *channel,
} }
gint gint
g_io_channel_win32_poll (GIOChannel **channels, g_io_channel_win32_poll (GPollFD *fds,
gint n_channels, gint n_fds,
GIOCondition condition, GIOCondition condition,
gint timeout) gint timeout)
{ {
GPollFD *pollfd;
GIOWin32Channel *win32_channel;
int i; int i;
int result; int result;
gboolean debug = FALSE; gboolean debug = FALSE;
g_return_val_if_fail (n_channels >= 0, 0); g_return_val_if_fail (n_fds >= 0, 0);
pollfd = g_new (GPollFD, n_channels); result = (*g_main_win32_get_poll_func ()) (fds, n_fds, timeout);
for (i = 0; i < n_channels; i++)
{
win32_channel = (GIOWin32Channel *) channels[i];
debug |= win32_channel->debug;
pollfd[i].fd = (gint) win32_channel->data_avail_event;
pollfd[i].events = condition;
}
if (debug)
{
g_print ("g_io_channel_win32_poll: ");
for (i = 0; i < n_channels; i++)
{
win32_channel = (GIOWin32Channel *) channels[i];
g_print ("fd:%d event:%#x ", win32_channel->fd, pollfd[i].fd);
}
g_print ("condition:%s%s%s%s timeout:%d\n",
(condition & G_IO_ERR) ? " ERR" : "",
(condition & G_IO_HUP) ? " HUP" : "",
(condition & G_IO_IN) ? " IN" : "",
(condition & G_IO_PRI) ? " PRI" : "",
timeout);
}
result = (*g_main_win32_get_poll_func ()) (pollfd, n_channels, timeout);
if (debug)
g_print ("g_io_channel_win32_poll: done:%d\n", result);
g_free (pollfd);
return result; return result;
} }
@ -926,7 +893,13 @@ g_io_channel_win32_wait_for_condition (GIOChannel *channel,
GIOCondition condition, GIOCondition condition,
gint timeout) gint timeout)
{ {
return g_io_channel_win32_poll (&channel, 1, condition, timeout); GPollFD pollfd;
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
pollfd.fd = (gint) win32_channel->data_avail_event;
pollfd.events = condition;
return g_io_channel_win32_poll (&pollfd, 1, condition, timeout);
} }
/* This variable and the functions below are present just to be /* This variable and the functions below are present just to be

4
glib.h
View File

@ -2925,8 +2925,8 @@ gint g_io_channel_unix_get_fd (GIOChannel *channel);
* On Unix you would do a select() on the file descriptors of the channels. * On Unix you would do a select() on the file descriptors of the channels.
* This should probably be available for all platforms? * This should probably be available for all platforms?
*/ */
gint g_io_channel_win32_poll (GIOChannel **channels, gint g_io_channel_win32_poll (GPollFD *fds,
gint n_channels, gint n_fds,
GIOCondition condition, GIOCondition condition,
gint timeout); gint timeout);

View File

@ -872,51 +872,18 @@ g_io_channel_win32_set_debug (GIOChannel *channel,
} }
gint gint
g_io_channel_win32_poll (GIOChannel **channels, g_io_channel_win32_poll (GPollFD *fds,
gint n_channels, gint n_fds,
GIOCondition condition, GIOCondition condition,
gint timeout) gint timeout)
{ {
GPollFD *pollfd;
GIOWin32Channel *win32_channel;
int i; int i;
int result; int result;
gboolean debug = FALSE; gboolean debug = FALSE;
g_return_val_if_fail (n_channels >= 0, 0); g_return_val_if_fail (n_fds >= 0, 0);
pollfd = g_new (GPollFD, n_channels); result = (*g_main_win32_get_poll_func ()) (fds, n_fds, timeout);
for (i = 0; i < n_channels; i++)
{
win32_channel = (GIOWin32Channel *) channels[i];
debug |= win32_channel->debug;
pollfd[i].fd = (gint) win32_channel->data_avail_event;
pollfd[i].events = condition;
}
if (debug)
{
g_print ("g_io_channel_win32_poll: ");
for (i = 0; i < n_channels; i++)
{
win32_channel = (GIOWin32Channel *) channels[i];
g_print ("fd:%d event:%#x ", win32_channel->fd, pollfd[i].fd);
}
g_print ("condition:%s%s%s%s timeout:%d\n",
(condition & G_IO_ERR) ? " ERR" : "",
(condition & G_IO_HUP) ? " HUP" : "",
(condition & G_IO_IN) ? " IN" : "",
(condition & G_IO_PRI) ? " PRI" : "",
timeout);
}
result = (*g_main_win32_get_poll_func ()) (pollfd, n_channels, timeout);
if (debug)
g_print ("g_io_channel_win32_poll: done:%d\n", result);
g_free (pollfd);
return result; return result;
} }
@ -926,7 +893,13 @@ g_io_channel_win32_wait_for_condition (GIOChannel *channel,
GIOCondition condition, GIOCondition condition,
gint timeout) gint timeout)
{ {
return g_io_channel_win32_poll (&channel, 1, condition, timeout); GPollFD pollfd;
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
pollfd.fd = (gint) win32_channel->data_avail_event;
pollfd.events = condition;
return g_io_channel_win32_poll (&pollfd, 1, condition, timeout);
} }
/* This variable and the functions below are present just to be /* This variable and the functions below are present just to be

View File

@ -2925,8 +2925,8 @@ gint g_io_channel_unix_get_fd (GIOChannel *channel);
* On Unix you would do a select() on the file descriptors of the channels. * On Unix you would do a select() on the file descriptors of the channels.
* This should probably be available for all platforms? * This should probably be available for all platforms?
*/ */
gint g_io_channel_win32_poll (GIOChannel **channels, gint g_io_channel_win32_poll (GPollFD *fds,
gint n_channels, gint n_fds,
GIOCondition condition, GIOCondition condition,
gint timeout); gint timeout);