Changeset 2f69081
- Timestamp:
- Feb 19, 2008, 1:22:48 AM (16 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 18108b1e, 61abb18
- Parents:
- 9d2f010
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
select.c
r6b580b0 r2f69081 105 105 } 106 106 107 int owl_select_dispatch_prepare_fd_sets(fd_set *r, fd_set * w, fd_set *e)107 int owl_select_dispatch_prepare_fd_sets(fd_set *r, fd_set *e) 108 108 { 109 109 int i, len, max_fd; … … 119 119 d = (owl_dispatch*)owl_list_get_element(dl, i); 120 120 FD_SET(d->fd, r); 121 FD_SET(d->fd, w);122 121 FD_SET(d->fd, e); 123 122 if (max_fd < d->fd) max_fd = d->fd; … … 149 148 } 150 149 151 int owl_select_aim_hack(fd_set * fds)150 int owl_select_aim_hack(fd_set *rfds, fd_set *wfds) 152 151 { 153 152 aim_conn_t *cur; … … 155 154 int max_fd; 156 155 157 FD_ZERO(fds); 156 FD_ZERO(rfds); 157 FD_ZERO(wfds); 158 158 max_fd = 0; 159 159 sess = owl_global_get_aimsess(&g); 160 160 for (cur = sess->connlist, max_fd = 0; cur; cur = cur->next) { 161 161 if (cur->fd != -1) { 162 FD_SET(cur->fd, fds); 162 FD_SET(cur->fd, rfds); 163 if (cur->status & AIM_CONN_STATUS_INPROGRESS) { 164 /* Yes, we're checking writable sockets here. Without it, AIM 165 login is really slow. */ 166 FD_SET(cur->fd, wfds); 167 } 168 163 169 if (cur->fd > max_fd) 164 170 max_fd = cur->fd; 165 171 } 166 172 } 167 cur = owl_global_get_bosconn(&g);168 if (cur->fd != -1) {169 FD_SET(cur->fd, fds);170 if (cur->fd > max_fd)171 max_fd = cur->fd;172 }173 174 173 return max_fd; 175 174 } … … 179 178 int i, max_fd, aim_max_fd, aim_done; 180 179 fd_set r; 181 fd_set w;182 180 fd_set e; 183 fd_set aim_ fds;181 fd_set aim_rfds, aim_wfds; 184 182 struct timeval timeout; 185 183 … … 187 185 timeout.tv_usec = 0; 188 186 189 max_fd = owl_select_dispatch_prepare_fd_sets(&r, & w, &e);187 max_fd = owl_select_dispatch_prepare_fd_sets(&r, &e); 190 188 191 189 /* AIM HACK: … … 200 198 */ 201 199 aim_done = 1; 202 FD_ZERO(&aim_ fds);203 FD_ZERO(& w);200 FD_ZERO(&aim_rfds); 201 FD_ZERO(&aim_wfds); 204 202 if (owl_global_is_doaimevents(&g)) { 205 203 aim_done = 0; 206 aim_max_fd = owl_select_aim_hack(&aim_ fds);204 aim_max_fd = owl_select_aim_hack(&aim_rfds, &aim_wfds); 207 205 if (max_fd < aim_max_fd) max_fd = aim_max_fd; 208 206 for(i = 0; i <= aim_max_fd; i++) { 209 if (FD_ISSET(i, &aim_ fds)) {207 if (FD_ISSET(i, &aim_rfds)) { 210 208 FD_SET(i, &r); 211 FD_SET(i, &w); /* Yes, we're checking writable sockets212 here. Without it, AIM login is really213 slow. */214 209 FD_SET(i, &e); 215 210 } … … 217 212 } 218 213 /* END AIM HACK */ 219 220 if ( select(max_fd , &r, &w, &e, &timeout) ) {214 215 if ( select(max_fd+1, &r, &aim_wfds, &e, &timeout) ) { 221 216 /* Merge fd_sets and clear AIM FDs. */ 222 217 for(i = 0; i <= max_fd; i++) { 223 218 /* Merge all interesting FDs into one set, since we have a 224 219 single dispatch per FD. */ 225 if (FD_ISSET(i, &r) || FD_ISSET(i, & w) || FD_ISSET(i, &e)) {220 if (FD_ISSET(i, &r) || FD_ISSET(i, &aim_wfds) || FD_ISSET(i, &e)) { 226 221 /* AIM HACK: no separate dispatch, just process here if 227 222 needed, and only once per run through. */ 228 if (!aim_done && FD_ISSET(i, &aim_fds)) {223 if (!aim_done && (FD_ISSET(i, &aim_rfds) || FD_ISSET(i, &aim_wfds))) { 229 224 owl_process_aim(); 230 225 aim_done = 1; … … 235 230 } 236 231 } 237 238 232 /* NOTE: the same dispatch function is called for both exceptional 239 233 and read ready FDs. */
Note: See TracChangeset
for help on using the changeset viewer.