make signal-handling patch work with older glib versions

This commit is contained in:
Nils Philippsen 2014-07-03 11:21:23 +02:00
parent 7abb3de37c
commit 8afb02d876
2 changed files with 50 additions and 25 deletions

View File

@ -1,11 +1,21 @@
From 54a700c45c81f1ffff5f3dfcecb3929143e31d48 Mon Sep 17 00:00:00 2001
From 3b5d3b7e1f320b0bfbe48024a586c0a22375aa2d Mon Sep 17 00:00:00 2001
From: Nils Philippsen <nils@redhat.com>
Date: Wed, 19 Mar 2014 13:23:16 +0100
Date: Thu, 3 Jul 2014 10:38:03 +0200
Subject: [PATCH] patch: signal-handling
Squashed commit of the following:
commit 2b629e1d9c60dcf26defe6d05b515611874db270
commit 1e9e8cf5edc469114c8eadf46817cd5c1261b35c
Author: Nils Philippsen <nils@redhat.com>
Date: Thu Jul 3 10:14:52 2014 +0200
don't use g_unix_open_pipe(), g_unix_fd_add()
These functions have only recently been added to glib. Use pipe()/
fcntl() and g_io_channel_unix_new()/g_io_add_watch() instead which are
available in the minimum glib version needed for gtk+-2.x.
commit acbdf3f693d3d2a78ee7490ca1bf76957daf00cf
Author: Nils Philippsen <nils@redhat.com>
Date: Thu Mar 13 13:38:12 2014 +0100
@ -16,13 +26,13 @@ Date: Thu Mar 13 13:38:12 2014 +0100
non-reentrant functions from a signal handler. The top half (the real
signal handler) just writes a character into a pipe which gets picked up
and serviced by the bottom half from the normal event loop, this
serializes things and makes use of non-reentrant functions safe.
serializes things and makes using non-reentrant functions safe.
---
src/xsane.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 131 insertions(+), 15 deletions(-)
src/xsane.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 136 insertions(+), 15 deletions(-)
diff --git a/src/xsane.c b/src/xsane.c
index eee76ff..02b4da4 100644
index 2b9211b..fc2ebbe 100644
--- a/src/xsane.c
+++ b/src/xsane.c
@@ -47,6 +47,7 @@
@ -48,7 +58,7 @@ index eee76ff..02b4da4 100644
-static RETSIGTYPE xsane_quit_handler(int signal);
-static RETSIGTYPE xsane_sigchld_handler(int signal);
+static RETSIGTYPE xsane_signal_handler_top_half(int signal);
+static gboolean xsane_signal_handler_bottom_half(gint fd,
+static gboolean xsane_signal_handler_bottom_half(GIOChannel *source,
+ GIOCondition condition,
+ gpointer user_data);
+static void xsane_sigchld_handler(void);
@ -119,7 +129,7 @@ index eee76ff..02b4da4 100644
+ errno = errno_saved;
+}
+
+static gboolean xsane_signal_handler_bottom_half(gint fd,
+static gboolean xsane_signal_handler_bottom_half(GIOChannel *source,
+ GIOCondition condition,
+ gpointer user_data)
+{
@ -162,7 +172,7 @@ index eee76ff..02b4da4 100644
+ }
+
+ /* previous invocation might have read more than it should, so ignore
+ * EGAIN/EWOULDBLOCK */
+ * EAGAIN/EWOULDBLOCK */
+ if (readlen < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
+ {
+ DBG(DBG_error, "Error while reading from pipe: %d '%s'\n", errno,
@ -179,14 +189,26 @@ index eee76ff..02b4da4 100644
{
int status;
XsaneChildprocess **childprocess_listptr = &xsane.childprocess_list;
@@ -6062,18 +6170,26 @@ void xsane_interface(int argc, char **argv)
@@ -6026,6 +6134,8 @@ void xsane_interface(int argc, char **argv)
{
struct SIGACTION act;
+ GIOChannel *gio_pipe_read;
+
DBG(DBG_proc, "xsane_interface\n");
xsane.info_label = NULL;
@@ -6069,18 +6179,29 @@ void xsane_interface(int argc, char **argv)
}
}
+ if (!g_unix_open_pipe(xsane_signal_pipe, FD_CLOEXEC, NULL) ||
+ fcntl(xsane_signal_pipe[0], F_SETFL, O_NONBLOCK, 1) ||
+ fcntl(xsane_signal_pipe[1], F_SETFL, O_NONBLOCK, 1) ||
+ !g_unix_fd_add(xsane_signal_pipe[0], G_IO_IN | G_IO_PRI,
+ if ((pipe(xsane_signal_pipe) == -1) ||
+ (fcntl(xsane_signal_pipe[0], F_SETFD, FD_CLOEXEC) == -1) ||
+ (fcntl(xsane_signal_pipe[0], F_SETFL, O_NONBLOCK) == -1) ||
+ (fcntl(xsane_signal_pipe[1], F_SETFD, FD_CLOEXEC) == -1) ||
+ (fcntl(xsane_signal_pipe[1], F_SETFL, O_NONBLOCK) == -1) ||
+ !(gio_pipe_read = g_io_channel_unix_new(xsane_signal_pipe[0])) ||
+ !g_io_add_watch(gio_pipe_read, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
+ xsane_signal_handler_bottom_half, NULL))
+ {
+ DBG(DBG_error,
@ -216,5 +238,5 @@ index eee76ff..02b4da4 100644
gtk_main();
sane_exit();
--
1.8.5.3
1.9.3

View File

@ -61,16 +61,16 @@ Patch11: xsane-0.999-pdf-no-high-bpp.patch
# build against lcms 2.x
# submitted to upstream (Oliver Rauch) via email, 2013-09-23
Patch12: xsane-0.999-lcms2.patch
# fix signal handling (#1073698)
# submitted to upstream (Oliver Rauch) via email, 2014-03-19
Patch13: xsane-0.999-signal-handling.patch
# fix issues found during static analysis that don't require far-reaching
# refactoring
# submitted to upstream (Oliver Rauch) via email, 2014-04-02
Patch14: xsane-0.999-coverity.patch
Patch13: xsane-0.999-coverity.patch
# update lib/snprintf.c to the latest version from LPRng that has a Free license
# submitted to upstream (Oliver Rauch) via email, 2014-05-29
Patch15: xsane-0.999-update-to-current-lprng-plp_snprintf.patch
Patch14: xsane-0.999-update-to-current-lprng-plp_snprintf.patch
# fix signal handling (#1073698)
# submitted to upstream (Oliver Rauch) via email, 2014-07-03
Patch15: xsane-0.999-signal-handling.patch
# autoconf-generated files
Patch100: xsane-0.999-7-autoconf.patch.bz2
@ -137,9 +137,9 @@ done
%patch10 -p1 -b .man-page
%patch11 -p1 -b .pdf-no-high-bpp
%patch12 -p1 -b .lcms2
%patch13 -p1 -b .signal-handling
%patch14 -p1 -b .coverity
%patch15 -p1 -b .snprintf
%patch13 -p1 -b .coverity
%patch14 -p1 -b .snprintf
%patch15 -p1 -b .signal-handling
%patch100 -p1 -b .autoconf
@ -239,6 +239,9 @@ fi
%{_datadir}/sane/xsane
%changelog
* Thu Jul 03 2014 Nils Philippsen <nils@redhat.com>
- make signal-handling patch work with older glib versions
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.999-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild