Mercurial > pidgin
comparison src/oscar.c @ 259:e159ba2486fc
[gaim-migrate @ 269]
Got rid of aim_select but it still uses 100% of the CPU.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 24 May 2000 19:12:50 +0000 |
parents | 5b28ef2b550e |
children | 59f1748b09a6 |
comparison
equal
deleted
inserted
replaced
258:1eeece1c7b7b | 259:e159ba2486fc |
---|---|
56 static int gaim_chat_join (struct aim_session_t *, struct command_rx_struct *, ...); | 56 static int gaim_chat_join (struct aim_session_t *, struct command_rx_struct *, ...); |
57 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); | 57 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); |
58 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); | 58 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); |
59 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); | 59 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); |
60 | 60 |
61 /* FIXME ! This uses 100% of the CPU, guaranteed. We shouldn't be using | 61 /* FIXME ! This uses 100% of the CPU, guaranteed. It's not using aim_select |
62 * aim_select at all. we should be using the gtk/gdk watcher functions */ | 62 * anymore, which is a good thing, but gdk still thinks there's always data |
63 * to be read, even though aim_get_command and aim_rxdispatch have already | |
64 * taken care of the data that there was. So, it constantly calls this, and | |
65 * it acts basically like an infinite loop that actually does some work, and | |
66 * eats all of your CPU. | |
67 */ | |
63 static void oscar_callback(gpointer data, gint source, | 68 static void oscar_callback(gpointer data, gint source, |
64 GdkInputCondition condition) { | 69 GdkInputCondition condition) { |
65 struct aim_session_t *sess = (struct aim_session_t *)data; | 70 struct aim_session_t *sess = (struct aim_session_t *)data; |
66 struct aim_conn_t *conn = NULL; | 71 |
67 struct timeval tv; | 72 if (condition & GDK_INPUT_EXCEPTION) { |
68 int selstat; | 73 signoff(); |
69 | 74 hide_login_progress("Disconnected."); |
70 tv.tv_sec = 0; tv.tv_usec = 0; | 75 aim_logoff(sess); |
71 conn = aim_select(sess, &tv, &selstat); | 76 gdk_input_remove(inpa); |
72 | 77 return; |
73 switch(selstat) { | 78 } |
74 case -1: /* error */ | 79 if (condition & GDK_INPUT_WRITE) { |
80 aim_tx_flushqueue(sess); | |
81 } | |
82 if (condition & GDK_INPUT_READ) { | |
83 if (aim_get_command(sess, gaim_conn) < 0) { | |
84 debug_print("connection error!\n"); | |
75 signoff(); | 85 signoff(); |
76 hide_login_progress("Disconnected."); | 86 hide_login_progress("Disconnected."); |
77 aim_logoff(sess); | 87 aim_logoff(sess); |
78 gdk_input_remove(inpa); | 88 gdk_input_remove(inpa); |
79 break; | 89 } else { |
80 case 0: | 90 aim_rxdispatch(sess); |
91 /* the rest of this is a bad hack to try and get it to | |
92 * update the display at least occasionally */ | |
81 gdk_input_remove(inpa); | 93 gdk_input_remove(inpa); |
82 while (gtk_events_pending()) | 94 while (gtk_events_pending()) |
83 gtk_main_iteration(); | 95 gtk_main_iteration(); |
84 inpa = gdk_input_add(gaim_conn->fd, | 96 inpa = gdk_input_add(gaim_conn->fd, |
85 GDK_INPUT_READ | GDK_INPUT_WRITE | | 97 GDK_INPUT_READ | GDK_INPUT_WRITE | GDK_INPUT_EXCEPTION, |
86 GDK_INPUT_EXCEPTION, | 98 oscar_callback, sess); |
87 oscar_callback, sess); | 99 } |
88 break; | |
89 case 1: /* outgoing data pending */ | |
90 aim_tx_flushqueue(sess); | |
91 break; | |
92 case 2: /* incoming data pending */ | |
93 if (aim_get_command(sess, conn) < 0) { | |
94 debug_print("connection error!\n"); | |
95 signoff(); | |
96 hide_login_progress("Disconnected."); | |
97 aim_logoff(sess); | |
98 gdk_input_remove(inpa); | |
99 } else | |
100 aim_rxdispatch(sess); | |
101 break; | |
102 } | 100 } |
103 } | 101 } |
104 | 102 |
105 int oscar_login(char *username, char *password) { | 103 int oscar_login(char *username, char *password) { |
106 struct aim_session_t *sess; | 104 struct aim_session_t *sess; |
151 gaim_auth_server_ready, 0); | 149 gaim_auth_server_ready, 0); |
152 aim_send_login(sess, conn, username, password, &info); | 150 aim_send_login(sess, conn, username, password, &info); |
153 | 151 |
154 gaim_conn = conn; | 152 gaim_conn = conn; |
155 inpa = gdk_input_add(conn->fd, | 153 inpa = gdk_input_add(conn->fd, |
156 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | 154 GDK_INPUT_READ | GDK_INPUT_WRITE | GDK_INPUT_EXCEPTION, |
157 oscar_callback, sess); | 155 oscar_callback, sess); |
158 | 156 |
159 u = find_user(username); | 157 u = find_user(username); |
160 | 158 |
161 if (!u) { | 159 if (!u) { |
162 u = g_new0(struct aim_user, 1); | 160 u = g_new0(struct aim_user, 1); |