Changes in / [b70d24f:5f3168a]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • select.c

    r2f69081 r6b580b0  
    105105}
    106106
    107 int owl_select_dispatch_prepare_fd_sets(fd_set *r, fd_set *e)
     107int owl_select_dispatch_prepare_fd_sets(fd_set *r, fd_set *w, fd_set *e)
    108108{
    109109  int i, len, max_fd;
     
    119119    d = (owl_dispatch*)owl_list_get_element(dl, i);
    120120    FD_SET(d->fd, r);
     121    FD_SET(d->fd, w);
    121122    FD_SET(d->fd, e);
    122123    if (max_fd < d->fd) max_fd = d->fd;
     
    148149}
    149150
    150 int owl_select_aim_hack(fd_set *rfds, fd_set *wfds)
     151int owl_select_aim_hack(fd_set *fds)
    151152{
    152153  aim_conn_t *cur;
     
    154155  int max_fd;
    155156
    156   FD_ZERO(rfds);
    157   FD_ZERO(wfds);
     157  FD_ZERO(fds);
    158158  max_fd = 0;
    159159  sess = owl_global_get_aimsess(&g);
    160160  for (cur = sess->connlist, max_fd = 0; cur; cur = cur->next) {
    161161    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, AIM
    165            login is really slow. */
    166         FD_SET(cur->fd, wfds);
    167       }
    168      
     162      FD_SET(cur->fd, fds);
    169163      if (cur->fd > max_fd)
    170164        max_fd = cur->fd;
    171165    }
    172166  }
     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 
    173174  return max_fd;
    174175}
     
    178179  int i, max_fd, aim_max_fd, aim_done;
    179180  fd_set r;
     181  fd_set w;
    180182  fd_set e;
    181   fd_set aim_rfds, aim_wfds;
     183  fd_set aim_fds;
    182184  struct timeval timeout;
    183185
     
    185187  timeout.tv_usec = 0;
    186188
    187   max_fd = owl_select_dispatch_prepare_fd_sets(&r, &e);
     189  max_fd = owl_select_dispatch_prepare_fd_sets(&r, &w, &e);
    188190
    189191  /* AIM HACK:
     
    198200   */
    199201  aim_done = 1;
    200   FD_ZERO(&aim_rfds);
    201   FD_ZERO(&aim_wfds);
     202  FD_ZERO(&aim_fds);
     203  FD_ZERO(&w);
    202204  if (owl_global_is_doaimevents(&g)) {
    203205    aim_done = 0;
    204     aim_max_fd = owl_select_aim_hack(&aim_rfds, &aim_wfds);
     206    aim_max_fd = owl_select_aim_hack(&aim_fds);
    205207    if (max_fd < aim_max_fd) max_fd = aim_max_fd;
    206208    for(i = 0; i <= aim_max_fd; i++) {
    207       if (FD_ISSET(i, &aim_rfds)) {
     209      if (FD_ISSET(i, &aim_fds)) {
    208210        FD_SET(i, &r);
     211        FD_SET(i, &w); /* Yes, we're checking writable sockets
     212                          here. Without it, AIM login is really
     213                          slow. */
    209214        FD_SET(i, &e);
    210215      }
     
    212217  }
    213218  /* END AIM HACK */
    214 
    215   if ( select(max_fd+1, &r, &aim_wfds, &e, &timeout) ) {
     219 
     220  if ( select(max_fd, &r, &w, &e, &timeout) ) {
    216221    /* Merge fd_sets and clear AIM FDs. */
    217222    for(i = 0; i <= max_fd; i++) {
    218223      /* Merge all interesting FDs into one set, since we have a
    219224         single dispatch per FD. */
    220       if (FD_ISSET(i, &r) || FD_ISSET(i, &aim_wfds) || FD_ISSET(i, &e)) {
     225      if (FD_ISSET(i, &r) || FD_ISSET(i, &w) || FD_ISSET(i, &e)) {
    221226        /* AIM HACK: no separate dispatch, just process here if
    222227           needed, and only once per run through. */
    223         if (!aim_done && (FD_ISSET(i, &aim_rfds) || FD_ISSET(i, &aim_wfds))) {
     228        if (!aim_done && FD_ISSET(i, &aim_fds)) {
    224229          owl_process_aim();
    225230          aim_done = 1;
     
    230235      }
    231236    }
     237
    232238    /* NOTE: the same dispatch function is called for both exceptional
    233239       and read ready FDs. */
Note: See TracChangeset for help on using the changeset viewer.