summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2012-05-25 11:02:15 -0400
committerDavid Zeuthen <davidz@redhat.com>2012-05-25 11:02:15 -0400
commit1caa8c2d3636bdd99dbbf0c84002946c432bd6e1 (patch)
tree45ce7b7b3dde8b0ec8201ca234eaacdfbb631634
parent587deddf80b2ad72d1ff21a2d5858c720303106c (diff)
downloadpolkit-1caa8c2d3636bdd99dbbf0c84002946c432bd6e1.tar.gz
Use g_unix_signal_add() from GLib 2.30
... instead of the one I wrote myself. Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--configure.ac2
-rw-r--r--src/polkitd/Makefile.am1
-rw-r--r--src/polkitd/gposixsignal.c148
-rw-r--r--src/polkitd/gposixsignal.h42
-rw-r--r--src/polkitd/main.c10
5 files changed, 4 insertions, 199 deletions
diff --git a/configure.ac b/configure.ac
index 961a886..930d8de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,7 +123,7 @@ if test "x$GCC" = "xyes"; then
changequote([,])dnl
fi
-PKG_CHECK_MODULES(GLIB, [gio-2.0 >= 2.28.0])
+PKG_CHECK_MODULES(GLIB, [gio-2.0 >= 2.30.0])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
diff --git a/src/polkitd/Makefile.am b/src/polkitd/Makefile.am
index 584b795..8132fa7 100644
--- a/src/polkitd/Makefile.am
+++ b/src/polkitd/Makefile.am
@@ -19,7 +19,6 @@ libpriv_PROGRAMS = polkitd
polkitd_SOURCES = \
main.c \
- gposixsignal.h gposixsignal.c \
$(NULL)
polkitd_CFLAGS = \
diff --git a/src/polkitd/gposixsignal.c b/src/polkitd/gposixsignal.c
deleted file mode 100644
index 0dbd8e8..0000000
--- a/src/polkitd/gposixsignal.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-/*
- * Copyright (C) 2010 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#include "config.h"
-
-#include "gposixsignal.h"
-
-#if defined(__linux__)
-#include <unistd.h>
-#include <sys/signalfd.h>
-#include <signal.h>
-
-typedef struct
-{
- GSource source;
- GPollFD pollfd;
- gint signum;
-} _GPosixSignalSource;
-
-static gboolean
-_g_posix_signal_source_prepare (GSource *_source,
- gint *timeout)
-{
- *timeout = -1;
- return FALSE;
-}
-
-static gboolean
-_g_posix_signal_source_check (GSource *_source)
-{
- _GPosixSignalSource *source = (_GPosixSignalSource *) _source;
- return source->pollfd.revents != 0;
-}
-
-static gboolean
-_g_posix_signal_source_dispatch (GSource *_source,
- GSourceFunc callback,
- gpointer user_data)
-
-{
- _GPosixSignalWatchFunc func = (_GPosixSignalWatchFunc) callback;
- g_warn_if_fail (func != NULL);
- return (*func) (user_data);
-}
-
-static void
-_g_posix_signal_source_finalize (GSource *_source)
-{
- _GPosixSignalSource *source = (_GPosixSignalSource *) _source;
- close (source->pollfd.fd);
-}
-
-static GSourceFuncs _g_posix_signal_source_funcs =
-{
- _g_posix_signal_source_prepare,
- _g_posix_signal_source_check,
- _g_posix_signal_source_dispatch,
- _g_posix_signal_source_finalize
-};
-
-GSource *
-_g_posix_signal_source_new (gint signum)
-{
- sigset_t sigset;
- gint fd;
- GSource *_source;
- _GPosixSignalSource *source;
-
- _source = NULL;
-
- sigemptyset (&sigset);
- sigaddset (&sigset, signum);
-
- if (sigprocmask (SIG_BLOCK, &sigset, NULL) == -1)
- g_assert_not_reached ();
-
- fd = signalfd (-1, &sigset, SFD_NONBLOCK | SFD_CLOEXEC);
-
- _source = g_source_new (&_g_posix_signal_source_funcs, sizeof (_GPosixSignalSource));
- source = (_GPosixSignalSource *) _source;
-
- source->pollfd.fd = fd;
- source->pollfd.events = G_IO_IN;
- g_source_add_poll (_source, &source->pollfd);
-
- source->signum = signum;
- return _source;
-}
-
-guint
-_g_posix_signal_watch_add (gint signum,
- gint priority,
- _GPosixSignalWatchFunc function,
- gpointer user_data,
- GDestroyNotify notify)
-{
- GSource *source;
- guint id;
-
- g_return_val_if_fail (function != NULL, 0);
-
- source = _g_posix_signal_source_new (signum);
- if (priority != G_PRIORITY_DEFAULT_IDLE)
- g_source_set_priority (source, priority);
- g_source_set_callback (source, (GSourceFunc) function, user_data, notify);
- id = g_source_attach (source, NULL);
- g_source_unref (source);
-
- return id;
-}
-#else /* __linux__ */
-
-GSource *
-_g_posix_signal_source_new (gint signum)
-{
- return NULL;
-}
-
-guint
-_g_posix_signal_watch_add (gint signum,
- gint priority,
- _GPosixSignalWatchFunc function,
- gpointer user_data,
- GDestroyNotify notify)
-{
- return 0;
-}
-
-#endif /* __linux__ */
diff --git a/src/polkitd/gposixsignal.h b/src/polkitd/gposixsignal.h
deleted file mode 100644
index f9b3249..0000000
--- a/src/polkitd/gposixsignal.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-/*
- * Copyright (C) 2010 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#ifndef ___G_POSIX_SIGNAL_H__
-#define ___G_POSIX_SIGNAL_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef gboolean (*_GPosixSignalWatchFunc) (gpointer user_data);
-
-GSource *_g_posix_signal_source_new (gint signum);
-
-guint _g_posix_signal_watch_add (gint signum,
- gint priority,
- _GPosixSignalWatchFunc function,
- gpointer user_data,
- GDestroyNotify notify);
-
-G_END_DECLS
-
-#endif /* ___G_POSIX_SIGNAL_H__ */
diff --git a/src/polkitd/main.c b/src/polkitd/main.c
index b21723f..f77a12f 100644
--- a/src/polkitd/main.c
+++ b/src/polkitd/main.c
@@ -28,8 +28,6 @@
#include <polkit/polkit.h>
#include <polkitbackend/polkitbackend.h>
-#include "gposixsignal.h"
-
/* ---------------------------------------------------------------------------------------------------- */
static PolkitBackendAuthority *authority = NULL;
@@ -147,11 +145,9 @@ main (int argc,
loop = g_main_loop_new (NULL, FALSE);
- sigint_id = _g_posix_signal_watch_add (SIGINT,
- G_PRIORITY_DEFAULT,
- on_sigint,
- NULL,
- NULL);
+ sigint_id = g_unix_signal_add (SIGINT,
+ on_sigint,
+ NULL);
name_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
"org.freedesktop.PolicyKit1",