aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-05-13 12:29:53 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-05-13 12:29:53 +0200
commitfc2ee0f84c1746cb17c448ee75c4206dca548325 (patch)
treec9067ffbdbf83505e0cb78863ea16a732a271887
parentb642f38161474516c8e9fda1a9942d45a4ea9f22 (diff)
It works, it works! \o/
-rw-r--r--protocols/Makefile1
-rw-r--r--protocols/events.h2
-rw-r--r--protocols/events_glib.c21
-rw-r--r--protocols/events_libevent.c9
4 files changed, 29 insertions, 4 deletions
diff --git a/protocols/Makefile b/protocols/Makefile
index aad1ecfe..4f61d6e4 100644
--- a/protocols/Makefile
+++ b/protocols/Makefile
@@ -10,6 +10,7 @@
# [SH] Program variables
objects = events_libevent.o http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)
+#objects = events_glib.o http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)
# [SH] The next two lines should contain the directory name (in $(subdirs))
# and the name of the object file, which should be linked into
diff --git a/protocols/events.h b/protocols/events.h
index e8ac5a17..dcd45abe 100644
--- a/protocols/events.h
+++ b/protocols/events.h
@@ -48,6 +48,8 @@ typedef gboolean (*b_event_handler)(gpointer data, gint fd, b_input_condition co
#define GAIM_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
#define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL)
+#define event_debug( x... ) printf( x )
+
G_MODULE_EXPORT void b_main_init();
G_MODULE_EXPORT void b_main_run();
G_MODULE_EXPORT void b_main_quit();
diff --git a/protocols/events_glib.c b/protocols/events_glib.c
index 5a72b13c..01265fd8 100644
--- a/protocols/events_glib.c
+++ b/protocols/events_glib.c
@@ -72,17 +72,26 @@ static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpoin
{
GaimIOClosure *closure = data;
b_input_condition gaim_cond = 0;
+ gboolean st;
if (condition & GAIM_READ_COND)
gaim_cond |= GAIM_INPUT_READ;
if (condition & GAIM_WRITE_COND)
gaim_cond |= GAIM_INPUT_WRITE;
+
+ event_debug( "gaim_io_invoke( %d, %d, 0x%x )\n", g_io_channel_unix_get_fd(source), condition, data );
- return closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond);
+ st = closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond);
+
+ if( !st )
+ event_debug( "Returned FALSE, cancelling.\n" );
+
+ return st;
}
static void gaim_io_destroy(gpointer data)
{
+ event_debug( "gaim_io_destroy( 0x%x )\n", data );
g_free(data);
}
@@ -104,17 +113,25 @@ gint b_input_add(gint source, b_input_condition condition, b_event_handler funct
closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
gaim_io_invoke, closure, gaim_io_destroy);
+ event_debug( "b_input_add( %d, %d, 0x%x, 0x%x ) = %d (0x%x)\n", source, condition, function, data, closure->result, closure );
+
g_io_channel_unref(channel);
return closure->result;
}
gint b_timeout_add(gint timeout, b_event_handler func, gpointer data)
{
- return g_timeout_add(timeout, func, data);
+ gint st = g_timeout_add(timeout, func, data);
+
+ event_debug( "b_timeout_add( %d, %d, %d ) = %d\n", timeout, func, data, st );
+
+ return st;
}
void b_event_remove(gint tag)
{
+ event_debug( "g_source_remove( %d )\n", tag );
+
if (tag > 0)
g_source_remove(tag);
}
diff --git a/protocols/events_libevent.c b/protocols/events_libevent.c
index b9464093..bcfb3b45 100644
--- a/protocols/events_libevent.c
+++ b/protocols/events_libevent.c
@@ -71,6 +71,7 @@ static void b_event_passthrough( int fd, short event, void *data )
{
struct b_event_data *b_ev = data;
b_input_condition cond = 0;
+ int id;
if( fd >= 0 )
{
@@ -82,10 +83,14 @@ static void b_event_passthrough( int fd, short event, void *data )
event_debug( "b_event_passthrough( %d, %d, 0x%x ) (%d)\n", fd, event, (int) data, b_ev->id );
+ /* Since the called function might cancel this handler already
+ (which free()s b_ev, we have to remember the ID here. */
+ id = b_ev->id;
+
if( !b_ev->function( b_ev->data, fd, cond ) )
{
event_debug( "Handler returned FALSE: " );
- b_event_remove( b_ev->id );
+ b_event_remove( id );
}
}
@@ -150,7 +155,7 @@ void b_event_remove( gint id )
}
else
{
- event_debug( "Invalid?\n" );
+ event_debug( "Double remove?\n" );
}
}