|
Panu Matilainen |
1c9fae |
changeset: 6177:6acd7701e4df
|
|
Panu Matilainen |
1c9fae |
user: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
1c9fae |
date: Fri Jul 20 11:19:56 2007 +0300
|
|
Panu Matilainen |
1c9fae |
files: rpmdb/rpmdb.c rpmdb/rpmdb.h
|
|
Panu Matilainen |
1c9fae |
description:
|
|
Panu Matilainen |
1c9fae |
Support explicitly asking from rpmdb cleanup + termination.
|
|
Panu Matilainen |
1c9fae |
New rpmdbCheckTerminate() function which checks for termination signals
|
|
Panu Matilainen |
1c9fae |
and allows requesting termination via parameter as well. Make
|
|
Panu Matilainen |
1c9fae |
rpmdbCheckSignals() just a wrapper that calls it with terminate=0.
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
diff -r c0237c16e2e3 -r 6acd7701e4df rpmdb/rpmdb.c
|
|
Panu Matilainen |
1c9fae |
--- a/rpmdb/rpmdb.c Fri Jul 20 10:41:15 2007 +0300
|
|
Panu Matilainen |
1c9fae |
+++ b/rpmdb/rpmdb.c Fri Jul 20 11:19:56 2007 +0300
|
|
Panu Matilainen |
1c9fae |
@@ -700,14 +700,14 @@ static rpmdb rpmdbRock;
|
|
Panu Matilainen |
1c9fae |
/*@unchecked@*/ /*@exposed@*/ /*@null@*/
|
|
Panu Matilainen |
1c9fae |
static rpmdbMatchIterator rpmmiRock;
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
-int rpmdbCheckSignals(void)
|
|
Panu Matilainen |
1c9fae |
+int rpmdbCheckTerminate(int terminate)
|
|
Panu Matilainen |
1c9fae |
/*@globals rpmdbRock, rpmmiRock @*/
|
|
Panu Matilainen |
1c9fae |
/*@modifies rpmdbRock, rpmmiRock @*/
|
|
Panu Matilainen |
1c9fae |
{
|
|
Panu Matilainen |
1c9fae |
sigset_t newMask, oldMask;
|
|
Panu Matilainen |
1c9fae |
- static int terminate = 0;
|
|
Panu Matilainen |
1c9fae |
-
|
|
Panu Matilainen |
1c9fae |
- if (terminate) return 0;
|
|
Panu Matilainen |
1c9fae |
+ static int terminating = 0;
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ if (terminating) return 0;
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
(void) sigfillset(&newMask); /* block all signals */
|
|
Panu Matilainen |
1c9fae |
(void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
|
|
Panu Matilainen |
1c9fae |
@@ -716,10 +716,11 @@ int rpmdbCheckSignals(void)
|
|
Panu Matilainen |
1c9fae |
|| sigismember(&rpmsqCaught, SIGQUIT)
|
|
Panu Matilainen |
1c9fae |
|| sigismember(&rpmsqCaught, SIGHUP)
|
|
Panu Matilainen |
1c9fae |
|| sigismember(&rpmsqCaught, SIGTERM)
|
|
Panu Matilainen |
1c9fae |
- || sigismember(&rpmsqCaught, SIGPIPE))
|
|
Panu Matilainen |
1c9fae |
- terminate = 1;
|
|
Panu Matilainen |
1c9fae |
-
|
|
Panu Matilainen |
1c9fae |
- if (terminate) {
|
|
Panu Matilainen |
1c9fae |
+ || sigismember(&rpmsqCaught, SIGPIPE)
|
|
Panu Matilainen |
1c9fae |
+ || terminate)
|
|
Panu Matilainen |
1c9fae |
+ terminating = 1;
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+ if (terminating) {
|
|
Panu Matilainen |
1c9fae |
rpmdb db;
|
|
Panu Matilainen |
1c9fae |
rpmdbMatchIterator mi;
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
@@ -745,6 +746,11 @@ int rpmdbCheckSignals(void)
|
|
Panu Matilainen |
1c9fae |
exit(EXIT_FAILURE);
|
|
Panu Matilainen |
1c9fae |
}
|
|
Panu Matilainen |
1c9fae |
return sigprocmask(SIG_SETMASK, &oldMask, NULL);
|
|
Panu Matilainen |
1c9fae |
+}
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+int rpmdbCheckSignals(void)
|
|
Panu Matilainen |
1c9fae |
+{
|
|
Panu Matilainen |
1c9fae |
+ return rpmdbCheckTerminate(0);
|
|
Panu Matilainen |
1c9fae |
}
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
/**
|
|
Panu Matilainen |
1c9fae |
diff -r c0237c16e2e3 -r 6acd7701e4df rpmdb/rpmdb.h
|
|
Panu Matilainen |
1c9fae |
--- a/rpmdb/rpmdb.h Fri Jul 20 10:41:15 2007 +0300
|
|
Panu Matilainen |
1c9fae |
+++ b/rpmdb/rpmdb.h Fri Jul 20 11:19:56 2007 +0300
|
|
Panu Matilainen |
1c9fae |
@@ -1039,12 +1039,20 @@ Header rpmdbNextIterator(/*@null@*/ rpmd
|
|
Panu Matilainen |
1c9fae |
/*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/;
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
/** \ingroup rpmdb
|
|
Panu Matilainen |
1c9fae |
- * Check rpmdb signal handler for trapped signal exit.
|
|
Panu Matilainen |
1c9fae |
+ * Check rpmdb signal handler for trapped signal exit. Just a compatibility
|
|
Panu Matilainen |
1c9fae |
+ * wrapper for rpmdbCheckTerminate()
|
|
Panu Matilainen |
1c9fae |
*/
|
|
Panu Matilainen |
1c9fae |
/*@mayexit@*/
|
|
Panu Matilainen |
1c9fae |
int rpmdbCheckSignals(void)
|
|
Panu Matilainen |
1c9fae |
/*@globals fileSystem, internalState @*/
|
|
Panu Matilainen |
1c9fae |
/*@modifies fileSystem, internalState @*/;
|
|
Panu Matilainen |
1c9fae |
+
|
|
Panu Matilainen |
1c9fae |
+/** \ingroup rpmdb
|
|
Panu Matilainen |
1c9fae |
+ * Check rpmdb signal handler for trapped signal or requested exit.
|
|
Panu Matilainen |
1c9fae |
+ * @param terminate 0 to only check for signals, 1 to terminate anyway
|
|
Panu Matilainen |
1c9fae |
+ */
|
|
Panu Matilainen |
1c9fae |
+/*@mayexit@*/
|
|
Panu Matilainen |
1c9fae |
+int rpmdbCheckTerminate(int terminate);
|
|
Panu Matilainen |
1c9fae |
|
|
Panu Matilainen |
1c9fae |
/** \ingroup rpmdb
|
|
Panu Matilainen |
1c9fae |
* Destroy rpm database iterator.
|
|
Panu Matilainen |
1c9fae |
|