Changeset 87833a8 for owl.c


Ignore:
Timestamp:
Mar 25, 2011, 3:46:46 AM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Children:
37d188f
Parents:
96ade35
git-author:
David Benjamin <davidben@mit.edu> (02/26/11 14:11:26)
git-committer:
David Benjamin <davidben@mit.edu> (03/25/11 03:46:46)
Message:
Make owl_signal_init take a signal-thread callback

Instead of pushing the work directly the main thread. This will allow us
to react to SIGINT earlier.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    rfafb842 r87833a8  
    354354}
    355355
    356 static void sig_handler(int sig, void *data) {
     356static gboolean sig_handler_main_thread(gpointer data) {
     357  int sig = GPOINTER_TO_INT(data);
     358
    357359  owl_function_debugmsg("Got signal %d", sig);
    358360  /* TODO: These don't need to be re-entrant anymore! */
     
    372374    owl_process_input_char(in);
    373375  }
     376  return FALSE;
     377}
     378
     379static void sig_handler(int sig, void *data) {
     380  GMainContext *context = data;
     381  GSource *source;
     382
     383  /* TODO: Special-case SIGINT so that it can interrupt outside the
     384   * event loop. */
     385
     386  /* Send a message to the main thread. */
     387  source = g_idle_source_new();
     388  g_source_set_priority(source, G_PRIORITY_DEFAULT);
     389  g_source_set_callback(source, sig_handler_main_thread,
     390                        GINT_TO_POINTER(sig), NULL);
     391  g_source_attach(source, context);
     392  g_source_unref(source);
    374393}
    375394
     
    385404  sigaddset(&sigset, SIGINT);
    386405
    387   owl_signal_init(&sigset, sig_handler, NULL);
     406  owl_signal_init(&sigset, sig_handler, g_main_context_default());
    388407}
    389408
Note: See TracChangeset for help on using the changeset viewer.