RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 20-May-2017 21:21:07 Branch: rpm-5_4 Handle: 2017052019210700 Modified files: (Branch: rpm-5_4) rpm CHANGES configure.ac rpm/lib poptALL.c rpm/rpmio librpmio.vers msqio.c poptIO.c poptIO.h rpmio.h rpmmsq.h tmq.c Log: - rpmmsq: permit building --without-msq. - rpmmsq: add per-executable and per-rpm message queue id's. Summary: Revision Changes Path 1.3501.2.553+2 -0 rpm/CHANGES 2.472.2.172 +20 -7 rpm/configure.ac 2.144.2.19 +7 -1 rpm/lib/poptALL.c 2.199.2.77 +2 -0 rpm/rpmio/librpmio.vers 1.1.2.3 +76 -20 rpm/rpmio/msqio.c 1.94.2.29 +9 -1 rpm/rpmio/poptIO.c 1.8.4.4 +2 -2 rpm/rpmio/poptIO.h 1.97.2.18 +3 -0 rpm/rpmio/rpmio.h 1.1.2.3 +0 -2 rpm/rpmio/rpmmsq.h 1.1.2.3 +1 -1 rpm/rpmio/tmq.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3501.2.552 -r1.3501.2.553 CHANGES --- rpm/CHANGES 20 May 2017 16:30:10 -0000 1.3501.2.552 +++ rpm/CHANGES 20 May 2017 19:21:07 -0000 1.3501.2.553 @@ -1,4 +1,6 @@ 5.4.17 -> 5.4.18: + - jbj: rpmmsq: permit building --without-msq. + - jbj: rpmmsq: add per-executable and per-rpm message queue id's. - jbj: rpmmsq: use pool allocation. permit queue deletion. - jbj: rpmio: add ".msqio" to send/receive SysV messages. - jbj: rpmsw: use clock_gettime (if available). @@ . patch -p0 <<'@@ .' Index: rpm/configure.ac ============================================================================ $ cvs diff -u -r2.472.2.171 -r2.472.2.172 configure.ac --- rpm/configure.ac 13 May 2017 07:03:14 -0000 2.472.2.171 +++ rpm/configure.ac 20 May 2017 19:21:07 -0000 2.472.2.172 @@ -1373,19 +1373,15 @@ dnl # oddball system calls AC_CHECK_HEADERS(sys/syscall.h) +AC_CHECK_HEADERS(linux/memfd.h) +AC_CHECK_FUNCS(memfd_create) AC_CHECK_HEADERS(linux/random.h) AC_CHECK_FUNCS(getentropy) AC_CHECK_FUNCS(getrandom) AC_CHECK_FUNCS(splice tee vmsplice) -AC_CHECK_HEADERS(linux/memfd.h) -AC_CHECK_FUNCS(memfd_create) - -AC_CHECK_HEADERS(sched.h) AC_CHECK_FUNCS(clone setns unshare) -AC_CHECK_HEADERS(linux/kcmp.h) -AC_CHECK_FUNCS(kcmp) AC_CHECK_FUNCS(fadvise posix_fadvise) AC_CHECK_FUNCS(fallocate posix_fallocate) @@ -4183,7 +4179,7 @@ RPM_CHECK_LIB( [POSIX Message Queues in RT], [mq], [rt], [mq_open], [mqueue.h], - [no,external:none], [], + [yes,external:none], [], [ $(echo "$OLIBS" | grep -- ' -lrt' > /dev/null) && LIBS="$OLIBS" AC_CHECK_FUNCS(mq_close) AC_CHECK_FUNCS(mq_getattr) @@ -4197,6 +4193,21 @@ AC_CHECK_FUNCS(mq_unlink) ], []) +dnl # SysV Message Queues <sys/msg.h> +OLIBS="$LIBS" +RPM_CHECK_LIB( + [SysV Message Queues in C], [msq], + [c], [msgget], [sys/msg.h], + [yes,external:none], [], + [ LIBS="$OLIBS" + AC_CHECK_HEADERS(sys/ipc.h) + AC_CHECK_FUNCS(ftok) + AC_CHECK_FUNCS(msgctl) + AC_CHECK_FUNCS(msgget) + AC_CHECK_FUNCS(msgrcv) + AC_CHECK_FUNCS(msgsnd) + ], []) + dnl # MOUNT <sys/mount.h> OLIBS="$LIBS" RPM_CHECK_LIB( @@ -4308,6 +4319,8 @@ [c], [sched_yield], [sched.h], [yes,external:none], [], [ LIBS="$OLIBS" + AC_CHECK_HEADERS(linux/kcmp.h) + AC_CHECK_FUNCS(kcmp) AC_CHECK_FUNCS(sched_getaffinity) AC_CHECK_FUNCS(sched_setaffinity) AC_CHECK_FUNCS(sched_getparam) @@ . patch -p0 <<'@@ .' Index: rpm/lib/poptALL.c ============================================================================ $ cvs diff -u -r2.144.2.18 -r2.144.2.19 poptALL.c --- rpm/lib/poptALL.c 16 May 2017 18:29:10 -0000 2.144.2.18 +++ rpm/lib/poptALL.c 20 May 2017 19:21:07 -0000 2.144.2.19 @@ -4,7 +4,10 @@ */ #include "system.h" -extern const char *__progname; + +#if defined(HAVE_SYS_IPC_H) +# include <sys/ipc.h> +#endif #if defined(RPM_VENDOR_WINDRIVER) const char *__usrlibrpm = USRLIBRPM; @@ -579,6 +582,9 @@ int i; rpmioMtrace(); +#if defined(HAVE_FTOK) + __progname_key = ftok(arg0, __progname_projid); +#endif rpmioInitUsage(RPMLOG_DEBUG, __FUNCTION__); setprogname(arg0); /* Retrofit glibc __progname */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/librpmio.vers ============================================================================ $ cvs diff -u -r2.199.2.76 -r2.199.2.77 librpmio.vers --- rpm/rpmio/librpmio.vers 20 May 2017 16:30:10 -0000 2.199.2.76 +++ rpm/rpmio/librpmio.vers 20 May 2017 19:21:07 -0000 2.199.2.77 @@ -353,6 +353,8 @@ print_expand_trace; print_macro_trace; __progname; + __progname_key; + __progname_projid; program_name; prpsoffsets32; prpsoffsets64; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/msqio.c ============================================================================ $ cvs diff -u -r1.1.2.2 -r1.1.2.3 msqio.c --- rpm/rpmio/msqio.c 20 May 2017 16:30:10 -0000 1.1.2.2 +++ rpm/rpmio/msqio.c 20 May 2017 19:21:07 -0000 1.1.2.3 @@ -4,11 +4,20 @@ */ #include "system.h" + +#if defined(WITH_MSQ) +#if defined(HAVE_SYS_MSG_H) +# include <sys/msg.h> +#endif +#if defined(HAVE_SYS_IPC_H) +# include <sys/ipc.h> +#endif +#endif /* WITH_MSQ */ + #include "rpmio_internal.h" +#include <rpmlog.h> #include <rpmmacro.h> -#include <rpmcb.h> - -#if defined(WITH_BZIP2) +#include <rpmcb.h> /* XXX rpmIsDebug() */ #define _RPMMSQ_INTERNAL #include "rpmmsq.h" @@ -19,7 +28,7 @@ #define SPEW(_list) if (_rpmmsq_debug || _rpmio_debug) fprintf _list -#define MSQONLY(fd) assert(fdGetIo(fd) == bzdio) +#define MSQONLY(fd) assert(fdGetIo(fd) == msqio) #ifdef __cplusplus GENfree(rpmmsq) @@ -38,14 +47,38 @@ RPMIOPOOL_MODULE(msq) +#ifdef REFERENCE +key_t +xftok (const char *path, int proj_id) +{ + key_t key = -1; /* assume failure */ + struct stat st; + + if (stat(path, &st) < 0) + goto exit; + + key = 0; + key |= ((st.st_ino & 0xffff); + key |= ((st.st_dev & 0xff) << 16); + key |= ((proj_id & 0xff) << 24)); + +exit: +fprintf(stderr, "<-- %s(%p,0x%02x) key 0x%x\n", __FUNCTION__, (proj_id & 0xff), key); + return key; +} +#endif + rpmmsq rpmmsqNew(const char * path, const char * fmode, int fdno, int flags) { rpmmsq msq = rpmmsqGetPool(_rpmmsqPool); - int perms = 0664; - const char * s = fmode; - int c; assert(fmode != NULL); /* XXX return NULL instead? */ + msq->qid = -1; + +#if defined(WITH_MSQ) + const char * s = fmode; + int c; + int perms = 0664; switch ((c = *s++)) { case 'a': perms |= IPC_CREAT; break; @@ -62,14 +95,29 @@ break; } - msq->key = path && *path - ? ftok(path, 42) - : IPC_PRIVATE; + if (!strcmp(path, "private") || !strcmp(path, "IPC_PRIVATE")) + msq->key = IPC_PRIVATE; + else if (!strcmp(path, "program") || !strcmp(path, "__progname_key")) + msq->key = __progname_key; + else { + int projid = __progname_projid; + if (!strcmp(path, "rpm")) + path = "/usr/lib/rpm"; + msq->key = ftok(path, projid); + if (msq->key == -1) { + int lvl = RPMLOG_WARNING; + rpmlog(lvl, "%s: ftok(%s,0x%02x) failed: %m\n", + __FUNCTION__, path, (projid & 0xff)); + msq->key = __progname_key; + rpmlog(lvl, "Using program key 0x%x\n", msq->key); + } + } msq->perms = perms; msq->mtype = getpid(); /* XXX single queue, multiple RW processes. */ msq->qid = msgget(msq->key, msq->perms); SPEW((stderr, "<-- %s(0x%x,0%o) qid %d\n", "msqget", msq->key, msq->perms, msq->qid)); +#endif /* WITH_MSQ */ return (msq->qid != -1 ? rpmmsqLink(msq) : rpmmsqFree(msq)); } @@ -78,6 +126,7 @@ { ssize_t rc = -1; /* assume failure */ +#if defined(WITH_MSQ) struct msgbuf * msgp = xmalloc(sizeof(*msgp) + count); size_t msgsz = count; long msgtyp = msq->mtype; @@ -90,8 +139,9 @@ nb = rc; } SPEW((stderr, "<-- %s(0x%x,%p,%lu,%ld,%d) rc %ld\t\"%.*s\"\n", "msqrcv", msq->qid, msgp, (unsigned long)msgsz, (long)msgtyp, msgflg, (long)rc, nb, buf)); - msgp = _free(msgp); +#endif /* WITH_MSQ */ + return rc; } @@ -99,6 +149,7 @@ { ssize_t rc = -1; /* assume failure */ +#if defined(WITH_MSQ) struct msgbuf * msgp = xmalloc(sizeof(*msgp) + count); size_t msgsz = count; int msgflg = 0; @@ -110,8 +161,9 @@ SPEW((stderr, "<-- %s(0x%x,%p,%lu,%d) rc %ld\t\"%.*s\"\n", "msqsnd", msq->qid, msgp, (unsigned long)msgsz, msgflg, (long)rc, (int)count, buf)); if (rc == 0) rc = count; - msgp = _free(msgp); +#endif /* WITH_MSQ */ + return rc; } @@ -124,11 +176,14 @@ int rpmmsqClose(rpmmsq msq, int delete) { - int rc = 0; + int rc = -2; /* assume failure */ +#if defined(WITH_MSQ) if (_rpmmsq_debug) rpmmsqDump(__FUNCTION__, msq, NULL); - if (delete) + if (delete || msq->key == IPC_PRIVATE) (void) rpmmsqCtl(msq, IPC_RMID, NULL); + rc = 0; +#endif /* WITH_MSQ */ return rc; } @@ -155,6 +210,7 @@ rpmmsq msq = (rpmmsq) _msq; int rc = -2; /* assume failure */ +#if defined(WITH_MSQ) if (msq) switch (cmd) { default: @@ -188,6 +244,7 @@ break; #endif } +#endif /* WITH_MSQ */ SPEW((stderr, "<-- %s(0x%x,%d,%p) rc %d\n", "msqctl", (msq ? (unsigned)msq->qid : 0xdeadbeef), cmd, buf, rc)); @@ -196,9 +253,7 @@ int rpmmsqDump(const char * msg, void *_msq, FILE *fp) { - rpmmsq msq = (rpmmsq) _msq; - struct msqid_ds ds; - int rc; + int rc = -1; /* assume failure */ if (fp == NULL) fp = stderr; @@ -206,6 +261,9 @@ if (msg) fprintf(fp, "================ %s\n", msg); +#if defined(WITH_MSQ) + rpmmsq msq = (rpmmsq) _msq; + struct msqid_ds ds; rc = rpmmsqCtl(msq, IPC_STAT, &ds); if (!rc) { #if defined(__linux__) @@ -247,6 +305,7 @@ fprintf(fp, "\t msgseg: %d\n", mi.msgseg); } #endif +#endif /* WITH_MSQ */ return rc; } @@ -385,6 +444,3 @@ }; FDIO_t msqio = &msqio_s; - -#endif - @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/poptIO.c ============================================================================ $ cvs diff -u -r1.94.2.28 -r1.94.2.29 poptIO.c --- rpm/rpmio/poptIO.c 20 May 2017 13:40:40 -0000 1.94.2.28 +++ rpm/rpmio/poptIO.c 20 May 2017 19:21:07 -0000 1.94.2.29 @@ -5,6 +5,9 @@ #include "system.h" +#if defined(HAVE_SYS_IPC_H) +# include <sys/ipc.h> +#endif #if defined(HAVE_SYS_RESOURCE_H) # include <sys/resource.h> #endif @@ -75,6 +78,8 @@ #endif /* __cplusplus */ const char *__progname; +int __progname_key; +int __progname_projid; #if !defined(POPT_ARGFLAG_TOGGLE) /* XXX compat with popt < 1.15 */ #define POPT_ARGFLAG_TOGGLE 0 @@ -884,7 +889,10 @@ int rc; rpmioMtrace(); - rpmioInitInfo(RPMLOG_DEBUG, __FUNCTION__); +#if defined(HAVE_FTOK) + __progname_key = ftok(arg0, __progname_projid); +#endif + rpmioInitUsage(RPMLOG_DEBUG, __FUNCTION__); setprogname(arg0); /* Retrofit glibc __progname */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/poptIO.h ============================================================================ $ cvs diff -u -r1.8.4.3 -r1.8.4.4 poptIO.h --- rpm/rpmio/poptIO.h 13 May 2017 07:09:16 -0000 1.8.4.3 +++ rpm/rpmio/poptIO.h 20 May 2017 19:21:07 -0000 1.8.4.4 @@ -18,8 +18,6 @@ #include <mire.h> #include <popt.h> -extern int __debug; /* XXX I know I'm gonna regret __debug ... */ - #ifdef __cplusplus extern "C" { #endif @@ -27,6 +25,8 @@ /** \ingroup rpmio */ +extern int __debug; /* XXX I know I'm gonna regret __debug ... */ + extern int _rpmio_popt_context_flags; /* XXX POPT_CONTEXT_POSIXMEHARDER */ extern pgpHashAlgo rpmioDigestHashAlgo; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmio.h ============================================================================ $ cvs diff -u -r1.97.2.17 -r1.97.2.18 rpmio.h --- rpm/rpmio/rpmio.h 20 May 2017 13:40:40 -0000 1.97.2.17 +++ rpm/rpmio/rpmio.h 20 May 2017 19:21:07 -0000 1.97.2.18 @@ -35,6 +35,9 @@ /** \ingroup rpmio */ extern int _rpmio_debug; +extern const char * __progname; +extern int __progname_key; +extern int __progname_projid; /** \ingroup rpmio */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmsq.h ============================================================================ $ cvs diff -u -r1.1.2.2 -r1.1.2.3 rpmmsq.h --- rpm/rpmio/rpmmsq.h 20 May 2017 16:30:10 -0000 1.1.2.2 +++ rpm/rpmio/rpmmsq.h 20 May 2017 19:21:07 -0000 1.1.2.3 @@ -10,8 +10,6 @@ /** */ #if defined(_RPMMSQ_INTERNAL) -#include <sys/msg.h> -#include <sys/ipc.h> struct rpmmsq_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ int flags; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/tmq.c ============================================================================ $ cvs diff -u -r1.1.2.2 -r1.1.2.3 tmq.c --- rpm/rpmio/tmq.c 20 May 2017 16:30:10 -0000 1.1.2.2 +++ rpm/rpmio/tmq.c 20 May 2017 19:21:07 -0000 1.1.2.3 @@ -272,7 +272,7 @@ size_t blen; int xx; - const char *msqname = "/var/lib/rpm/tmp";; + const char *msqname = "rpm";; rpmmsq msq = rpmmsqNew(msqname, "w+", -1, 0); if (msq) { @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org