Changeset f97c1a6 for zephyr.c


Ignore:
Timestamp:
May 23, 2011, 9:09:44 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
33b6431b
Parents:
4c7c21f (diff), 1d21d9f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge branch 'g_main_loop'

The logic in owl_select_prune_bad_fds still needs to be reimplemented.

Conflicts:
	configure.ac
	owl.c
	select.c
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    r3b8a563 rf97c1a6  
    77#include "owl.h"
    88
     9static GSource *owl_zephyr_event_source_new(int fd);
     10
     11static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout);
     12static gboolean owl_zephyr_event_check(GSource *source);
     13static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
     14
    915#ifdef HAVE_LIBZEPHYR
    1016static GList *deferred_subs = NULL;
     
    1622
    1723Code_t ZResetAuthentication(void);
     24
     25static GSourceFuncs zephyr_event_funcs = {
     26  owl_zephyr_event_prepare,
     27  owl_zephyr_event_check,
     28  owl_zephyr_event_dispatch,
     29  NULL
     30};
    1831#endif
    1932
     
    8497  Code_t code;
    8598  char *perl;
     99  GSource *event_source;
    86100
    87101  owl_select_remove_io_dispatch(d);
     
    99113  }
    100114
    101   owl_select_add_io_dispatch(ZGetFD(), OWL_IO_READ|OWL_IO_EXCEPT, &owl_zephyr_process_events, NULL, NULL);
     115  event_source = owl_zephyr_event_source_new(ZGetFD());
     116  g_source_attach(event_source, NULL);
     117  g_source_unref(event_source);
    102118
    103119  owl_global_set_havezephyr(&g);
     
    127143  perl = owl_perlconfig_execute("BarnOwl::Zephyr::_zephyr_startup()");
    128144  g_free(perl);
    129 
    130   owl_select_add_pre_select_action(owl_zephyr_pre_select_action, NULL, NULL);
    131145}
    132146
     
    180194    if((code = ZPending()) < 0) {
    181195      owl_function_debugmsg("Error (%s) in ZPending()\n",
     196                            error_message(code));
     197      return 0;
     198    }
     199    return code;
     200  }
     201#endif
     202  return 0;
     203}
     204
     205int owl_zephyr_zqlength(void)
     206{
     207#ifdef HAVE_LIBZEPHYR
     208  Code_t code;
     209  if(owl_global_is_havezephyr(&g)) {
     210    if((code = ZQLength()) < 0) {
     211      owl_function_debugmsg("Error (%s) in ZQLength()\n",
    182212                            error_message(code));
    183213      return 0;
     
    14691499}
    14701500
    1471 void owl_zephyr_process_events(const owl_io_dispatch *d, void *data)
    1472 {
     1501typedef struct { /*noproto*/
     1502  GSource source;
     1503  GPollFD poll_fd;
     1504} owl_zephyr_event_source;
     1505
     1506static GSource *owl_zephyr_event_source_new(int fd) {
     1507  GSource *source;
     1508  owl_zephyr_event_source *event_source;
     1509
     1510  source = g_source_new(&zephyr_event_funcs, sizeof(owl_zephyr_event_source));
     1511  event_source = (owl_zephyr_event_source*) source;
     1512  event_source->poll_fd.fd = fd;
     1513  event_source->poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_PRI | G_IO_ERR;
     1514  g_source_add_poll(source, &event_source->poll_fd);
     1515
     1516  return source;
     1517}
     1518
     1519static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout) {
     1520  *timeout = -1;
     1521  return owl_zephyr_zqlength() > 0;
     1522}
     1523
     1524static gboolean owl_zephyr_event_check(GSource *source) {
     1525  owl_zephyr_event_source *event_source = (owl_zephyr_event_source*)source;
     1526  if (event_source->poll_fd.revents & event_source->poll_fd.events)
     1527    return owl_zephyr_zpending() > 0;
     1528  return FALSE;
     1529}
     1530
     1531static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) {
    14731532  _owl_zephyr_process_events();
    1474 }
    1475 
    1476 int owl_zephyr_pre_select_action(owl_ps_action *a, void *p)
    1477 {
    1478   return _owl_zephyr_process_events();
    1479 }
     1533  return TRUE;
     1534}
Note: See TracChangeset for help on using the changeset viewer.