Changeset dc1edbd for select.c


Ignore:
Timestamp:
May 23, 2011, 8:57:46 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
117b2ba
Parents:
08e9842
git-author:
David Benjamin <davidben@mit.edu> (02/26/11 16:32:51)
git-committer:
David Benjamin <davidben@mit.edu> (05/23/11 20:57:46)
Message:
Add a GSource for AIM events

The AIM file descriptor hack is somewhat less of a hack now. Remove code
related to the old AIM implementation now that it's been superceded.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • select.c

    r257b9c4 rdc1edbd  
    296296}
    297297
    298 int owl_select_aim_hack(fd_set *rfds, fd_set *wfds)
    299 {
    300   aim_conn_t *cur;
    301   aim_session_t *sess;
    302   int max_fd;
    303 
    304   max_fd = 0;
    305   sess = owl_global_get_aimsess(&g);
    306   for (cur = sess->connlist; cur; cur = cur->next) {
    307     if (cur->fd != -1) {
    308       FD_SET(cur->fd, rfds);
    309       if (cur->status & AIM_CONN_STATUS_INPROGRESS) {
    310         /* Yes, we're checking writable sockets here. Without it, AIM
    311            login is really slow. */
    312         FD_SET(cur->fd, wfds);
    313       }
    314      
    315       if (cur->fd > max_fd)
    316         max_fd = cur->fd;
    317     }
    318   }
    319   return max_fd;
    320 }
    321 
    322298void owl_process_input_char(owl_input j)
    323299{
     
    331307}
    332308
    333 #if 0
    334 /* FIXME: Reimplement the AIM hack and handle AIM events. */
    335 void owl_select(void)
    336 {
    337   int i, max_fd, max_fd2, aim_done, ret;
    338   fd_set r;
    339   fd_set w;
    340   fd_set e;
    341   fd_set aim_rfds, aim_wfds;
    342   struct timespec timeout;
    343   sigset_t mask;
    344 
    345   owl_select_process_timers(&timeout);
    346 
    347   owl_select_mask_signals(&mask);
    348 
    349   if(owl_global_is_interrupted(&g)) {
    350     owl_select_handle_intr(&mask);
    351     return;
    352   }
    353   FD_ZERO(&r);
    354   FD_ZERO(&w);
    355   FD_ZERO(&e);
    356 
    357   max_fd = owl_select_prepare_io_dispatch_fd_sets(&r, &w, &e);
    358 
    359   /* AIM HACK:
    360    *
    361    *  The problem - I'm not sure where to hook into the owl/faim
    362    *  interface to keep track of when the AIM socket(s) open and
    363    *  close. In particular, the bosconn thing throws me off. So,
    364    *  rather than register particular dispatchers for AIM, I look up
    365    *  the relevant FDs and add them to select's watch lists, then
    366    *  check for them individually before moving on to the other
    367    *  dispatchers. --asedeno
    368    */
    369   aim_done = 1;
    370   FD_ZERO(&aim_rfds);
    371   FD_ZERO(&aim_wfds);
    372   if (owl_global_is_doaimevents(&g)) {
    373     aim_done = 0;
    374     max_fd2 = owl_select_aim_hack(&aim_rfds, &aim_wfds);
    375     if (max_fd < max_fd2) max_fd = max_fd2;
    376     for(i = 0; i <= max_fd2; i++) {
    377       if (FD_ISSET(i, &aim_rfds)) {
    378         FD_SET(i, &r);
    379         FD_SET(i, &e);
    380       }
    381       if (FD_ISSET(i, &aim_wfds)) {
    382         FD_SET(i, &w);
    383         FD_SET(i, &e);
    384       }
    385     }
    386   }
    387   /* END AIM HACK */
    388 
    389   if (owl_select_do_pre_select_actions()) {
    390     timeout.tv_sec = 0;
    391     timeout.tv_nsec = 0;
    392   }
    393 
    394   ret = pselect(max_fd+1, &r, &w, &e, &timeout, &mask);
    395 
    396   if(ret < 0 && errno == EINTR) {
    397     if(owl_global_is_interrupted(&g)) {
    398       owl_select_handle_intr(NULL);
    399     }
    400     sigprocmask(SIG_SETMASK, &mask, NULL);
    401     return;
    402   }
    403 
    404   sigprocmask(SIG_SETMASK, &mask, NULL);
    405 
    406   if(ret > 0) {
    407     /* AIM HACK: process all AIM events at once. */
    408     for(i = 0; !aim_done && i <= max_fd; i++) {
    409       if (FD_ISSET(i, &r) || FD_ISSET(i, &w) || FD_ISSET(i, &e)) {
    410         if (FD_ISSET(i, &aim_rfds) || FD_ISSET(i, &aim_wfds)) {
    411           owl_process_aim();
    412           aim_done = 1;
    413         }
    414       }
    415     }
    416     owl_select_io_dispatch(&r, &w, &e, max_fd);
    417   }
    418 }
    419 #endif
    420 
    421309void owl_select_init(void)
    422310{
Note: See TracChangeset for help on using the changeset viewer.