Skip to content
Snippets Groups Projects
Commit 1745b9d5 authored by Dan Egnor's avatar Dan Egnor
Browse files

More glib2 fixes from Lennart Poettering

parent 263531c0
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,10 @@ static fd_set read_set,write_set,except_set; ...@@ -28,6 +28,10 @@ static fd_set read_set,write_set,except_set;
static int count; static int count;
static void *ret = NULL; static void *ret = NULL;
#if GLIB_MAJOR_VERSION >= 2
static GPollFunc save_poll_func = NULL;
#endif
static void *on_select( static void *on_select(
oop_adapter_select *s,int num,fd_set *r,fd_set *w,fd_set *x, oop_adapter_select *s,int num,fd_set *r,fd_set *w,fd_set *x,
struct timeval now,void *unused) struct timeval now,void *unused)
...@@ -92,6 +96,7 @@ oop_source *oop_glib_new(void) { ...@@ -92,6 +96,7 @@ oop_source *oop_glib_new(void) {
sel = oop_select_new(oop_sys_source(sys),on_select,NULL); sel = oop_select_new(oop_sys_source(sys),on_select,NULL);
#if GLIB_MAJOR_VERSION >= 2 #if GLIB_MAJOR_VERSION >= 2
save_poll_func = g_main_context_get_poll_func(g_main_context_default());
g_main_context_set_poll_func(g_main_context_default(), on_poll); g_main_context_set_poll_func(g_main_context_default(), on_poll);
#else #else
g_main_set_poll_func(on_poll); g_main_set_poll_func(on_poll);
...@@ -110,17 +115,22 @@ static gint real_poll(GPollFD *array,guint num,gint timeout) { ...@@ -110,17 +115,22 @@ static gint real_poll(GPollFD *array,guint num,gint timeout) {
assert(sizeof(GPollFD) == sizeof(struct pollfd)); assert(sizeof(GPollFD) == sizeof(struct pollfd));
return poll((struct pollfd *) array,num,timeout); return poll((struct pollfd *) array,num,timeout);
} }
#endif
void oop_glib_delete(void) { void oop_glib_delete(void) {
assert(use_count > 0 && "oop_glib_delete() called too much"); assert(use_count > 0 && "oop_glib_delete() called too much");
if (0 != --use_count) return; if (0 != --use_count) return;
oop_select_delete(sel); #if GLIB_MAJOR_VERSION >= 2
oop_sys_delete(sys); g_main_context_set_poll_func(g_main_context_default(), save_poll_func);
#elif defined(HAVE_POLL_H)
g_main_set_poll_func(real_poll); g_main_set_poll_func(real_poll);
}
#else #else
void oop_glib_delete(void) { /* sigh */ } return;
#endif #endif
oop_select_delete(sel);
oop_sys_delete(sys);
}
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment