- Timestamp:
- May 31, 2008, 11:40:29 PM (16 years ago)
- Branches:
- barnowl_perlaim
- Children:
- 7a1c90d
- Parents:
- b1fd36e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
select.c
r2f69081 rc453ada 148 148 } 149 149 150 int owl_select_aim_hack(fd_set *rfds, fd_set *wfds)151 {152 aim_conn_t *cur;153 aim_session_t *sess;154 int max_fd;155 156 FD_ZERO(rfds);157 FD_ZERO(wfds);158 max_fd = 0;159 sess = owl_global_get_aimsess(&g);160 for (cur = sess->connlist, max_fd = 0; cur; cur = cur->next) {161 if (cur->fd != -1) {162 FD_SET(cur->fd, rfds);163 if (cur->status & AIM_CONN_STATUS_INPROGRESS) {164 /* Yes, we're checking writable sockets here. Without it, AIM165 login is really slow. */166 FD_SET(cur->fd, wfds);167 }168 169 if (cur->fd > max_fd)170 max_fd = cur->fd;171 }172 }173 return max_fd;174 }175 176 150 void owl_select() 177 151 { 178 int i, max_fd, aim_max_fd, aim_done;152 int max_fd; 179 153 fd_set r; 180 154 fd_set e; 181 fd_set aim_rfds, aim_wfds;182 155 struct timeval timeout; 183 156 … … 187 160 max_fd = owl_select_dispatch_prepare_fd_sets(&r, &e); 188 161 189 /* AIM HACK: 190 * 191 * The problem - I'm not sure where to hook into the owl/faim 192 * interface to keep track of when the AIM socket(s) open and 193 * close. In particular, the bosconn thing throws me off. So, 194 * rather than register particular dispatchers for AIM, I look up 195 * the relevant FDs and add them to select's watch lists, then 196 * check for them individually before moving on to the other 197 * dispatchers. --asedeno 198 */ 199 aim_done = 1; 200 FD_ZERO(&aim_rfds); 201 FD_ZERO(&aim_wfds); 202 if (owl_global_is_doaimevents(&g)) { 203 aim_done = 0; 204 aim_max_fd = owl_select_aim_hack(&aim_rfds, &aim_wfds); 205 if (max_fd < aim_max_fd) max_fd = aim_max_fd; 206 for(i = 0; i <= aim_max_fd; i++) { 207 if (FD_ISSET(i, &aim_rfds)) { 208 FD_SET(i, &r); 209 FD_SET(i, &e); 210 } 211 } 212 } 213 /* END AIM HACK */ 214 215 if ( select(max_fd+1, &r, &aim_wfds, &e, &timeout) ) { 216 /* Merge fd_sets and clear AIM FDs. */ 217 for(i = 0; i <= max_fd; i++) { 218 /* Merge all interesting FDs into one set, since we have a 219 single dispatch per FD. */ 220 if (FD_ISSET(i, &r) || FD_ISSET(i, &aim_wfds) || FD_ISSET(i, &e)) { 221 /* AIM HACK: no separate dispatch, just process here if 222 needed, and only once per run through. */ 223 if (!aim_done && (FD_ISSET(i, &aim_rfds) || FD_ISSET(i, &aim_wfds))) { 224 owl_process_aim(); 225 aim_done = 1; 226 } 227 else { 228 FD_SET(i, &r); 229 } 230 } 231 } 162 if ( select(max_fd+1, &r, NULL, &e, &timeout) ) { 232 163 /* NOTE: the same dispatch function is called for both exceptional 233 164 and read ready FDs. */
Note: See TracChangeset
for help on using the changeset viewer.