a_glib_poll: Preserve errno from g_poll()
When poll() is interrupted because of a signal, it sets errno to EINTR. GLib ignores this kind of failure. However, a_glib_poll() calls a_xcb_check() at its end. This will call xcb_poll_for_event() which internally might call recv(), which can fail with EAGAIN if no new events are available. Thus, a_glib_poll() will return an error and set errno to EAGAIN. This leads to the following error message being printed by GLib: GLib-WARNING: poll(2) failed due to: Resource temporarily unavailable. Fix this by preserving the errno from g_poll() in a_glib_poll(). Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
81da3a2ce7
commit
e907f44db9
|
@ -404,6 +404,7 @@ a_glib_poll(GPollFD *ufds, guint nfsd, gint timeout)
|
||||||
guint res;
|
guint res;
|
||||||
struct timeval now, length_time;
|
struct timeval now, length_time;
|
||||||
float length;
|
float length;
|
||||||
|
int saved_errno;
|
||||||
lua_State *L = globalconf_get_lua_State();
|
lua_State *L = globalconf_get_lua_State();
|
||||||
|
|
||||||
/* Do all deferred work now */
|
/* Do all deferred work now */
|
||||||
|
@ -434,8 +435,10 @@ a_glib_poll(GPollFD *ufds, guint nfsd, gint timeout)
|
||||||
|
|
||||||
/* Actually do the polling, record time of wakeup and check for new xcb events */
|
/* Actually do the polling, record time of wakeup and check for new xcb events */
|
||||||
res = g_poll(ufds, nfsd, timeout);
|
res = g_poll(ufds, nfsd, timeout);
|
||||||
|
saved_errno = errno;
|
||||||
gettimeofday(&last_wakeup, NULL);
|
gettimeofday(&last_wakeup, NULL);
|
||||||
a_xcb_check();
|
a_xcb_check();
|
||||||
|
errno = saved_errno;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue