# HG changeset patch # User Eric Warmenhoven # Date 959195570 0 # Node ID e159ba2486fc026c308731f84c8e07b54ba62339 # Parent 1eeece1c7b7b1387aa0280542370b5571faaa29c [gaim-migrate @ 269] Got rid of aim_select but it still uses 100% of the CPU. committer: Tailor Script diff -r 1eeece1c7b7b -r e159ba2486fc libfaim/CHANGES.gaim --- a/libfaim/CHANGES.gaim Wed May 24 10:07:01 2000 +0000 +++ b/libfaim/CHANGES.gaim Wed May 24 19:12:50 2000 +0000 @@ -1,3 +1,9 @@ + +Wed May 24 19:10:19 UTC 2000 EWarmenhoven + - Got rid of aim_select. Good. But it still uses 100% of the CPU. Bad. + The reason is because oscar_callback gets called whenever there's + data waiting on the file descriptor, and it always thinks there's + data waiting, even when we've already dealt with the data. Wed May 24 05:20:31 UTC 2000 EWarmenhoven - Inviting someone is possible now (I hope - I haven't been able to get diff -r 1eeece1c7b7b -r e159ba2486fc src/oscar.c --- a/src/oscar.c Wed May 24 10:07:01 2000 +0000 +++ b/src/oscar.c Wed May 24 19:12:50 2000 +0000 @@ -58,47 +58,45 @@ static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); -/* FIXME ! This uses 100% of the CPU, guaranteed. We shouldn't be using - * aim_select at all. we should be using the gtk/gdk watcher functions */ +/* FIXME ! This uses 100% of the CPU, guaranteed. It's not using aim_select + * anymore, which is a good thing, but gdk still thinks there's always data + * to be read, even though aim_get_command and aim_rxdispatch have already + * taken care of the data that there was. So, it constantly calls this, and + * it acts basically like an infinite loop that actually does some work, and + * eats all of your CPU. + */ static void oscar_callback(gpointer data, gint source, GdkInputCondition condition) { struct aim_session_t *sess = (struct aim_session_t *)data; - struct aim_conn_t *conn = NULL; - struct timeval tv; - int selstat; - tv.tv_sec = 0; tv.tv_usec = 0; - conn = aim_select(sess, &tv, &selstat); - - switch(selstat) { - case -1: /* error */ + if (condition & GDK_INPUT_EXCEPTION) { + signoff(); + hide_login_progress("Disconnected."); + aim_logoff(sess); + gdk_input_remove(inpa); + return; + } + if (condition & GDK_INPUT_WRITE) { + aim_tx_flushqueue(sess); + } + if (condition & GDK_INPUT_READ) { + if (aim_get_command(sess, gaim_conn) < 0) { + debug_print("connection error!\n"); signoff(); hide_login_progress("Disconnected."); aim_logoff(sess); gdk_input_remove(inpa); - break; - case 0: + } else { + aim_rxdispatch(sess); + /* the rest of this is a bad hack to try and get it to + * update the display at least occasionally */ gdk_input_remove(inpa); while (gtk_events_pending()) gtk_main_iteration(); inpa = gdk_input_add(gaim_conn->fd, - GDK_INPUT_READ | GDK_INPUT_WRITE | - GDK_INPUT_EXCEPTION, - oscar_callback, sess); - break; - case 1: /* outgoing data pending */ - aim_tx_flushqueue(sess); - break; - case 2: /* incoming data pending */ - if (aim_get_command(sess, conn) < 0) { - debug_print("connection error!\n"); - signoff(); - hide_login_progress("Disconnected."); - aim_logoff(sess); - gdk_input_remove(inpa); - } else - aim_rxdispatch(sess); - break; + GDK_INPUT_READ | GDK_INPUT_WRITE | GDK_INPUT_EXCEPTION, + oscar_callback, sess); + } } } @@ -153,8 +151,8 @@ gaim_conn = conn; inpa = gdk_input_add(conn->fd, - GDK_INPUT_READ | GDK_INPUT_EXCEPTION, - oscar_callback, sess); + GDK_INPUT_READ | GDK_INPUT_WRITE | GDK_INPUT_EXCEPTION, + oscar_callback, sess); u = find_user(username);