~ubuntu-branches/ubuntu/utopic/cups/utopic

« back to all changes in this revision

Viewing changes to debian/patches/avoid_stale_lockfile_in_dbus_notifier.patch

  • Committer: Package Import Robot
  • Author(s): Didier Raboud, Till Kamppeter, Steve Langasek, Didier Raboud
  • Date: 2014-01-03 18:42:39 UTC
  • mfrom: (99.2.3 sid)
  • Revision ID: package-import@ubuntu.com-20140103184239-85wju2l7weie4dgo
Tags: 1.7.0-1
* New 1.7.0 upstream release

[ Till Kamppeter ]
* Refresh most patches with quilt
* Removed usb-backend-do-not-crash-if-usb-disabled-in-bios and
  cupsd-no-crash-on-avahi-threaded-poll-shutdown patches as they got
  applied upstream
* Removed drop-arch-specifics-from-doc patch as it is not needed
  anymore
* Updated drop_unnecessary_dependencies, manpage-hyphen-minus,
  manpage-translations and ppd-poll-with-client-conf patches manually
  to apply to the new CUPS version
* Added error counting exception from
  usb-backend-do-not-crash-if-usb-disabled-in-bios to
  tests-ignore-warnings
* Install the newly added ippfind utility and its manpage in
  cups-client
* Added pwg.h to libcups2-dev package
* Call dh_auto_clean only if the file Makedefs is present, to avoid a
  FTBFS
* Added color management extensions from Joe Simon's GSoC 2013
  project.
* Patch cups-files.conf to activate CUPS daemon syncing of files when
  closing, so that config files (like printers.conf) do not
  mysteriously disappear (LP: #1157972)
* In the AppArmor profile, allow execution of programs in
  /etc/cups/interfaces/, needed to make CUPS working with queues based
  on System V interface scripts, especially PPD-less queues
  auto-generated by cups-browsed from cups-filters 1.0.41 on.
* Silenced AppArmor noise from udev.conf in syslog (LP: #1229766)

[ Steve Langasek ]
* Add cups-filters (>= 1.0.42) as alternative to foomatic-filters
  (which is deprecated) in package relationships

[ Didier Raboud ]
* Remove Roger Leigh from uploaders on his request with thanks for his
  past work!
* Switch avahi LSB Should-Start dependency to be avahi-daemon; also
  bump package relationship to >= 0.6.31-3~ (Closes: #731608)
* Refresh the manpage translation files
* Move the USB backend quirk rules file to cups-server-common
* Add 38 new 1.7.0 libcups2 symbols
* Mark one C++ libcupsppdc1 symbol as optional as it isn't exported in
  1.7.0 anymore
* Import Fedora patches:
  - to avoid sign-extending CRCs in gz decompression
  - to build with full read-only relocations
  - to fix job history logging (upstream patch)
  - to set the internal default for SyncOnClose to Yes, instead of
    only configuring it to Yes
  - to fix a stringpool corruption issue
  - to prevent USB timeouts causing incorrect print output
* Import Fedora patch updates:
  - to dont-use-dbus-from-two-threads patch so it removes a call to
    avahi_threaded_poll_stop()
  - to avoid_stale_lockfile_in_dbus_notifier patch to call _exit when
    handling SIGTERM
* Move manpage-translations patch at the very end of the patch series
  to have it include all our patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Avoid stale lockfile in dbus notifier
 
2
Bug-Redhat: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=1026949
 
3
Author: Tim Waugh <twaugh@redhat.com>
 
4
Last-Updated: 2014-01-02
 
5
 
 
6
--- a/notifier/dbus.c
 
7
+++ b/notifier/dbus.c
 
8
@@ -4,7 +4,7 @@
 
9
  *   D-Bus notifier for CUPS.
 
10
  *
 
11
  *   Copyright 2008-2012 by Apple Inc.
 
12
- *   Copyright (C) 2011 Red Hat, Inc.
 
13
+ *   Copyright (C) 2011, 2013 Red Hat, Inc.
 
14
  *   Copyright (C) 2007 Tim Waugh <twaugh@redhat.com>
 
15
  *   Copyright 1997-2005 by Easy Software Products.
 
16
  *
 
17
@@ -157,9 +157,16 @@
 
18
 
 
19
 
 
20
 /*
 
21
+ * Global variables...
 
22
+ */
 
23
+
 
24
+static char            lock_filename[1024];    /* Lock filename */
 
25
+
 
26
+/*
 
27
  * Local functions...
 
28
  */
 
29
 
 
30
+static void            release_lock(void);
 
31
 static int             acquire_lock(int *fd, char *lockfile, size_t locksize);
 
32
 static const char      *validate_utf8(const char *str);
 
33
 
 
34
@@ -253,8 +260,6 @@
 
35
   DBusMessage          *message;       /* Message to send */
 
36
   DBusMessageIter      iter;           /* Iterator for message data */
 
37
   int                  lock_fd = -1;   /* Lock file descriptor */
 
38
-  char                 lock_filename[1024];
 
39
-                                       /* Lock filename */
 
40
 
 
41
 
 
42
  /*
 
43
@@ -656,7 +661,7 @@
 
44
   if (lock_fd >= 0)
 
45
   {
 
46
     close(lock_fd);
 
47
-    unlink(lock_filename);
 
48
+    release_lock();
 
49
   }
 
50
 
 
51
   return (0);
 
52
@@ -664,6 +669,27 @@
 
53
 
 
54
 
 
55
 /*
 
56
+ * 'release_lock()' - Release the singleton lock.
 
57
+ */
 
58
+
 
59
+static void
 
60
+release_lock(void)
 
61
+{
 
62
+  unlink(lock_filename);
 
63
+}
 
64
+
 
65
+
 
66
+/*
 
67
+ * 'handle_sigterm()' - Handle SIGTERM signal.
 
68
+ */
 
69
+static void
 
70
+handle_sigterm(int signum)
 
71
+{
 
72
+  release_lock();
 
73
+  _exit (0);
 
74
+}
 
75
+
 
76
+/*
 
77
  * 'acquire_lock()' - Acquire a lock so we only have a single notifier running.
 
78
  */
 
79
 
 
80
@@ -672,7 +698,8 @@
 
81
              char   *lockfile,         /* I - Lock filename buffer */
 
82
             size_t locksize)           /* I - Size of filename buffer */
 
83
 {
 
84
-  const char   *tmpdir;                /* Temporary directory */
 
85
+  const char           *tmpdir;        /* Temporary directory */
 
86
+  struct sigaction     action;         /* POSIX sigaction data */
 
87
 
 
88
 
 
89
  /*
 
90
@@ -690,8 +717,16 @@
 
91
 
 
92
   if ((*fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) < 0)
 
93
     return (-1);
 
94
-  else
 
95
-    return (0);
 
96
+
 
97
+ /*
 
98
+  * Set a SIGTERM handler to make sure we release the lock if the
 
99
+  * scheduler decides to stop us.
 
100
+  */
 
101
+  memset(&action, 0, sizeof(action));
 
102
+  action.sa_handler = handle_sigterm;
 
103
+  sigaction(SIGTERM, &action, NULL);
 
104
+
 
105
+  return (0);
 
106
 }
 
107
 #else /* !HAVE_DBUS */
 
108
 int