RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm-4_5: rpm/ CHANGES rpm/python/ rpmmodule.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Thu 16 Aug 2007 - 14:25:48 CEST
Message-Id: <20070816122548.0EA9D348455@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   16-Aug-2007 14:25:47
  Branch: rpm-4_5                          Handle: 2007081613254700

  Modified files:           (Branch: rpm-4_5)
    rpm                     CHANGES
    rpm/python              rpmmodule.c

  Log:
    - python: backport signalsCaught, remove archscore.

  Summary:
    Revision    Changes     Path
    1.1360.2.32 +1  -0      rpm/CHANGES
    1.148.2.3   +46 -20     rpm/python/rpmmodule.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1360.2.31 -r1.1360.2.32 CHANGES
  --- rpm/CHANGES	12 Aug 2007 08:09:13 -0000	1.1360.2.31
  +++ rpm/CHANGES	16 Aug 2007 12:25:47 -0000	1.1360.2.32
  @@ -1,4 +1,5 @@
   4.4.9 -> 4.5:
  +    - jbj: python: backport signalsCaught, remove archscore.
       - jbj: re-add --force popt alias.
       - jbj: eliminate --initdb.
       - jbj: eliminate --rsegfault/--wsegfault.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/python/rpmmodule.c
  ============================================================================
  $ cvs diff -u -r1.148.2.2 -r1.148.2.3 rpmmodule.c
  --- rpm/python/rpmmodule.c	7 Jun 2007 18:09:31 -0000	1.148.2.2
  +++ rpm/python/rpmmodule.c	16 Aug 2007 12:25:47 -0000	1.148.2.3
  @@ -7,6 +7,7 @@
   #include <rpmio_internal.h>
   #include <rpmcli.h>	/* XXX for rpmCheckSig */
   #include <rpmdb.h>
  +#include <rpmsq.h>
   
   #include "legacy.h"
   #include "misc.h"
  @@ -41,30 +42,43 @@
    */
   PyObject * pyrpmError;
   
  +extern sigset_t rpmsqCaught;
  +
  +#if PY_VERSION_HEX < 0x02050000
  +typedef int Py_ssize_t;
  +#endif
  +
   /**
    */
  -static PyObject * archScore(PyObject * self, PyObject * args, PyObject * kwds)
  +static PyObject * signalsCaught(PyObject * self, PyObject * check)
   {
  -    char * arch;
  -    int score;
  -    char * kwlist[] = {"arch", NULL};
  +    PyObject *caught, *o;
  +    Py_ssize_t llen;
  +    int signum, i;
  +    sigset_t newMask, oldMask;
   
  -    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &arch))
  +    if (!PyList_Check(check)) {
  +	PyErr_SetString(PyExc_TypeError, "list expected");
   	return NULL;
  +    }
   
  -    score = rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch);
  +    llen = PyList_Size(check);
  +    caught = PyList_New(0);
   
  -    return Py_BuildValue("i", score);
  -}
  -
  -extern sigset_t rpmsqCaught;
  -/**
  - */
  -static PyObject * sqCaught(PyObject * self, PyObject * args)
  -{
  -    if (!PyArg_ParseTuple(args, ":sqCaught")) return NULL;
  +    /* block signals while checking for them */
  +    (void) sigfillset(&newMask);
  +    (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
  +
  +    for (i = 0; i < llen; i++) {
  +	o = PyList_GetItem(check, i);
  +	signum = PyInt_AsLong(o);
  +	if (sigismember(&rpmsqCaught, signum)) {
  +	    PyList_Append(caught, o);
  +	}
  +    }
  +    (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
   
  -    return Py_BuildValue("i", rpmsqCaught);
  +    return caught;
   }
   
   /**
  @@ -164,10 +178,7 @@
       { "delMacro", (PyCFunction) rpmrc_DelMacro, METH_VARARGS|METH_KEYWORDS,
   	NULL },
   
  -    { "archscore", (PyCFunction) archScore, METH_VARARGS|METH_KEYWORDS,
  -	NULL },
  -
  -    { "sqCaught", (PyCFunction) sqCaught, METH_VARARGS,
  +    { "signalsCaught", (PyCFunction) signalsCaught, METH_O,
   	NULL },
       { "checkSignals", (PyCFunction) checkSignals, METH_VARARGS,
   	NULL },
  @@ -203,6 +214,14 @@
       { NULL }
   } ;
   
  +/*
  + * Force clean up of open iterators and dbs on exit.
  + */
  +static void rpm_exithook(void)
  +{
  +   rpmdbCheckTerminate(1);
  +}
  +
   /**
    */
   static char rpm__doc__[] =
  @@ -241,6 +260,13 @@
       if (m == NULL)
   	return;
   
  +    /* 
  +     * treat error to register rpm cleanup hook as fatal, tracebacks
  +     * can and will leave stale locks around if we can't clean up
  +     */
  +    if (Py_AtExit(rpm_exithook) == -1)
  +	return;
  +
       rpmReadConfigFiles(NULL, NULL);
   
       d = PyModule_GetDict(m);
  @@ .
Received on Thu Aug 16 14:25:48 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.