Changeset 0cb6c26 for select.c


Ignore:
Timestamp:
May 5, 2009, 1:30:07 AM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
1e6e74e
Parents:
e0473d2
Message:
Fix a race that could cause us to miss a SIGINT

When I refactored the previous commits to unmask SIGINT in
owl_global_is_interrupted, I accidentally opened a window for us to miss
a SIGINT for a cycle of the event loop if it arrived in owl_select()
between a call to that functuon and pselect().

Undo that refactoring to make is_interrupted() just poll the flag, add
owl_function_(un)mask_sigint() for convenience, and use them in the
relevant locations.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • select.c

    r3a84694 r0cb6c26  
    290290{
    291291  owl_input in;
     292
     293  owl_global_unset_interrupted(&g);
     294  owl_function_unmask_sigint(NULL);
     295
    292296  in.ch = in.uch = owl_global_get_startup_tio(&g)->c_cc[VINTR];
    293297  owl_process_input_char(in);
     
    301305  fd_set aim_rfds, aim_wfds;
    302306  struct timespec timeout;
    303   sigset_t mask, intr;
    304 
    305   sigemptyset(&intr);
    306   sigaddset(&intr, SIGINT);
     307  sigset_t mask;
    307308
    308309  owl_select_process_timers(&timeout);
    309310
    310   sigprocmask(SIG_BLOCK, &intr, &mask);
     311  owl_function_mask_sigint(&mask);
    311312  if(owl_global_is_interrupted(&g)) {
    312      owl_select_handle_intr();
     313    owl_select_handle_intr();
    313314    return;
    314315  }
     
    352353  }
    353354
    354   sigprocmask(SIG_UNBLOCK, &intr, NULL);
     355  owl_function_unmask_sigint(NULL);
    355356
    356357  if(ret > 0) {
Note: See TracChangeset for help on using the changeset viewer.