Changeset 959cb85
- Timestamp:
- May 23, 2011, 8:57:46 PM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 3535a6e
- Parents:
- 6b4033f
- git-author:
- David Benjamin <davidben@mit.edu> (02/25/11 22:29:41)
- git-committer:
- David Benjamin <davidben@mit.edu> (05/23/11 20:57:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zephyr.c
rfe3b017 r959cb85 7 7 #include "owl.h" 8 8 9 static GSource *owl_zephyr_event_source_new(int fd); 10 11 static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout); 12 static gboolean owl_zephyr_event_check(GSource *source); 13 static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); 14 9 15 #ifdef HAVE_LIBZEPHYR 10 16 static GList *deferred_subs = NULL; … … 16 22 17 23 Code_t ZResetAuthentication(void); 24 25 static GSourceFuncs zephyr_event_funcs = { 26 owl_zephyr_event_prepare, 27 owl_zephyr_event_check, 28 owl_zephyr_event_dispatch, 29 NULL 30 }; 18 31 #endif 19 32 … … 84 97 Code_t code; 85 98 char *perl; 99 GSource *event_source; 86 100 87 101 owl_select_remove_io_dispatch(d); … … 99 113 } 100 114 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); 102 118 103 119 owl_global_set_havezephyr(&g); … … 127 143 perl = owl_perlconfig_execute("BarnOwl::Zephyr::_zephyr_startup()"); 128 144 g_free(perl); 129 130 owl_select_add_pre_select_action(owl_zephyr_pre_select_action, NULL, NULL);131 145 } 132 146 … … 180 194 if((code = ZPending()) < 0) { 181 195 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 205 int 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", 182 212 error_message(code)); 183 213 return 0; … … 1419 1449 } 1420 1450 1421 void owl_zephyr_process_events(const owl_io_dispatch *d, void *data) 1422 { 1451 typedef struct { /*noproto*/ 1452 GSource source; 1453 GPollFD poll_fd; 1454 } owl_zephyr_event_source; 1455 1456 static GSource *owl_zephyr_event_source_new(int fd) { 1457 GSource *source; 1458 owl_zephyr_event_source *event_source; 1459 1460 source = g_source_new(&zephyr_event_funcs, sizeof(owl_zephyr_event_source)); 1461 event_source = (owl_zephyr_event_source*) source; 1462 event_source->poll_fd.fd = fd; 1463 event_source->poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_PRI | G_IO_ERR; 1464 g_source_add_poll(source, &event_source->poll_fd); 1465 1466 return source; 1467 } 1468 1469 static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout) { 1470 *timeout = -1; 1471 return owl_zephyr_zqlength() > 0; 1472 } 1473 1474 static gboolean owl_zephyr_event_check(GSource *source) { 1475 owl_zephyr_event_source *event_source = (owl_zephyr_event_source*)source; 1476 if (event_source->poll_fd.revents & event_source->poll_fd.events) 1477 return owl_zephyr_zpending() > 0; 1478 return FALSE; 1479 } 1480 1481 static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { 1423 1482 _owl_zephyr_process_events(); 1424 } 1425 1426 int owl_zephyr_pre_select_action(owl_ps_action *a, void *p) 1427 { 1428 return _owl_zephyr_process_events(); 1429 } 1483 return TRUE; 1484 }
Note: See TracChangeset
for help on using the changeset viewer.