comparison src/session.c @ 8280:084ed9f7ac19

[gaim-migrate @ 9004] Soem tweaks from Scott Lamb for the event loop code. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 17 Feb 2004 08:43:44 +0000
parents f24172f53650
children 56360561af5e
comparison
equal deleted inserted replaced
8279:319448d52b33 8280:084ed9f7ac19
44 static gboolean had_first_save = FALSE; 44 static gboolean had_first_save = FALSE;
45 gboolean session_managed = FALSE; 45 gboolean session_managed = FALSE;
46 46
47 /* ICE belt'n'braces stuff */ 47 /* ICE belt'n'braces stuff */
48 48
49 struct ice_connection_info {
50 IceConn connection;
51 guint input_id;
52 };
53
49 static void ice_process_messages(gpointer data, gint fd, 54 static void ice_process_messages(gpointer data, gint fd,
50 GaimInputCondition condition) { 55 GaimInputCondition condition) {
51 IceConn connection = (IceConn)data; 56 struct ice_connection_info *conninfo = (struct ice_connection_info*) data;
52 IceProcessMessagesStatus status; 57 IceProcessMessagesStatus status;
53 58
54 /* please don't block... please! */ 59 /* please don't block... please! */
55 status = IceProcessMessages(connection, NULL, NULL); 60 status = IceProcessMessages(conninfo->connection, NULL, NULL);
56 61
57 if (status == IceProcessMessagesIOError) { 62 if (status == IceProcessMessagesIOError) {
58 gaim_debug(GAIM_DEBUG_INFO, "Session Management", 63 gaim_debug(GAIM_DEBUG_INFO, "Session Management",
59 "ICE IO error, closing connection... "); 64 "ICE IO error, closing connection... ");
60 65
61 /* IO error, please disconnect */ 66 /* IO error, please disconnect */
62 IceSetShutdownNegotiation(connection, False); 67 IceSetShutdownNegotiation(conninfo->connection, False);
63 IceCloseConnection(connection); 68 IceCloseConnection(conninfo->connection);
64 69
65 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); 70 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n");
66 71
67 /* cancel the handler */ 72 /* cancel the handler */
68 gaim_input_remove(IceConnectionNumber(connection)); 73 gaim_input_remove(conninfo->input_id);
69 } 74 }
70 } 75 }
71 76
72 static void ice_connection_watch(IceConn connection, IcePointer client_data, 77 static void ice_connection_watch(IceConn connection, IcePointer client_data,
73 Bool opening, IcePointer *watch_data) { 78 Bool opening, IcePointer *watch_data) {
79 struct ice_connection_info *conninfo = NULL;
80
74 if (opening) { 81 if (opening) {
75 gaim_debug(GAIM_DEBUG_INFO, "Session Management", 82 gaim_debug(GAIM_DEBUG_INFO, "Session Management",
76 "Handling new ICE connection... "); 83 "Handling new ICE connection... ");
77 84
78 /* ensure ICE connection is not passed to child processes */ 85 /* ensure ICE connection is not passed to child processes */
79 fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC); 86 fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC);
80 87
88 conninfo = g_new(struct ice_connection_info, 1);
89 conninfo->connection = connection;
90
81 /* watch the connection */ 91 /* watch the connection */
82 gaim_input_add(IceConnectionNumber(connection), GAIM_INPUT_READ, 92 conninfo->input_id = gaim_input_add(IceConnectionNumber(connection), GAIM_INPUT_READ,
83 ice_process_messages, connection); 93 ice_process_messages, conninfo);
94 *watch_data = conninfo;
84 } else { 95 } else {
85 gaim_debug(GAIM_DEBUG_INFO, "Session Management", 96 gaim_debug(GAIM_DEBUG_INFO, "Session Management",
86 "Handling closed ICE connection... "); 97 "Handling closed ICE connection... ");
87 98
88 /* stop watching it */ 99 /* get the input ID back and stop watching it */
89 gaim_input_remove(IceConnectionNumber(connection)); 100 conninfo = (struct ice_connection_info*) *watch_data;
101 gaim_input_remove(conninfo->input_id);
102 g_free(conninfo);
90 } 103 }
91 104
92 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n"); 105 gaim_debug(GAIM_DEBUG_INFO, NULL, "done.\n");
93 } 106 }
94 107