+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
+Mon Jul 2 16:03:21 2001 Owen Taylor <otaylor@redhat.com>
+
+ * glib/giochannel.c (g_io_channel_get_buffer_condition): Fix.
+
+ * glib/giunix.c: Fix prepare/check/dispatch for watches.
+
+ * tests/unicode-normalize.c: #include <string.h>
+
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
*
* This function returns a #GIOCondition depending on the status of the
* internal buffers in the #GIOChannel. Only the flags %G_IO_IN and
- * %G_IO_OUT may be set.
+ * %G_IO_OUT will be set.
*
* Return value: A #GIOCondition
**/
GIOCondition
g_io_channel_get_buffer_condition (GIOChannel *channel)
{
- return (((channel->read_buf->len > 0) || (channel->encoded_read_buf->len > 0))
- ? G_IO_IN : 0) & ((channel->write_buf->len > 0) ? G_IO_OUT : 0);
+ return
+ ((channel->read_buf && channel->read_buf->len > 0) ? G_IO_IN : 0) |
+ ((channel->write_buf && channel->write_buf->len <= channel->buf_size) ? G_IO_OUT : 0);
}
/**
gint *timeout)
{
GIOUnixWatch *watch = (GIOUnixWatch *)source;
+ GIOCondition buffer_condition = g_io_channel_get_buffer_condition (watch->channel);
*timeout = -1;
- /* Only return TRUE if we're sure to match all conditions, otherwise
- * we need to check.
+ /* Only return TRUE here if _all_ bits in watch->condition will be set
*/
-
- watch->condition = g_io_channel_get_buffer_condition (watch->channel);
-
- return (watch->pollfd.revents & (G_IO_IN | G_IO_OUT)) == watch->condition;
-
+ return ((watch->condition & buffer_condition) == watch->condition);
}
static gboolean
g_io_unix_check (GSource *source)
{
GIOUnixWatch *watch = (GIOUnixWatch *)source;
+ GIOCondition buffer_condition = g_io_channel_get_buffer_condition (watch->channel);
+ GIOCondition poll_condition = watch->pollfd.revents;
- watch->condition &= g_io_channel_get_buffer_condition (watch->channel);
-
- return (watch->pollfd.revents & watch->condition);
+ return ((poll_condition | buffer_condition) & watch->condition);
}
static gboolean
{
GIOFunc func = (GIOFunc)callback;
GIOUnixWatch *watch = (GIOUnixWatch *)source;
+ GIOCondition buffer_condition = g_io_channel_get_buffer_condition (watch->channel);
if (!func)
{
}
return (*func) (watch->channel,
- watch->pollfd.revents & watch->condition,
+ (watch->pollfd.revents | buffer_condition) & watch->condition,
user_data);
}
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
gboolean success = TRUE;