Changeset 0cb6c26 for functions.c


Ignore:
Timestamp:
May 5, 2009, 1:30:07 AM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, 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
  • functions.c

    rbf66f4e r0cb6c26  
    29902990  int viewsize, i, curmsg, start;
    29912991  owl_message *m;
    2992   sigset_t intr;
    2993   sigemptyset(&intr);
    2994   sigaddset(&intr, SIGINT);
    29952992
    29962993  v=owl_global_get_current_view(&g);
     
    30353032      i--;
    30363033    }
    3037     sigprocmask(SIG_BLOCK, &intr, NULL);
     3034    owl_function_mask_sigint(NULL);
    30383035    if(owl_global_is_interrupted(&g)) {
    30393036      owl_global_unset_interrupted(&g);
     3037      owl_function_unmask_sigint(NULL);
    30403038      owl_function_makemsg("Search interrupted!");
    30413039      owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    30423040      return;
    30433041    }
     3042    owl_function_unmask_sigint(NULL);
    30443043  }
    30453044  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     
    35173516     return COLORS;
    35183517}
     3518
     3519void owl_function_mask_sigint(sigset_t *oldmask) {
     3520  sigset_t intr;
     3521
     3522  sigemptyset(&intr);
     3523  sigaddset(&intr, SIGINT);
     3524  sigprocmask(SIG_BLOCK, &intr, oldmask);
     3525}
     3526
     3527void owl_function_unmask_sigint(sigset_t *oldmask) {
     3528  sigset_t intr;
     3529
     3530  sigemptyset(&intr);
     3531  sigaddset(&intr, SIGINT);
     3532  sigprocmask(SIG_UNBLOCK, &intr, oldmask);
     3533}
Note: See TracChangeset for help on using the changeset viewer.