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: 28-May-2017 20:39:22 Branch: rpm-5_4 Handle: 2017052818392200 Added files: (Branch: rpm-5_4) rpm/rpmio rpmaio.c rpmaio.h Modified files: (Branch: rpm-5_4) rpm CHANGES rpm/rpmio Makefile.am msqio.c poptIO.c rpmmsq.h Log: - rpmaio: stub in an AIO aiocb pool. Summary: Revision Changes Path 1.3501.2.565+1 -0 rpm/CHANGES 1.293.2.82 +4 -3 rpm/rpmio/Makefile.am 1.1.2.16 +5 -100 rpm/rpmio/msqio.c 1.94.2.32 +1 -0 rpm/rpmio/poptIO.c 1.1.2.1 +132 -0 rpm/rpmio/rpmaio.c 1.1.2.1 +67 -0 rpm/rpmio/rpmaio.h 1.1.2.13 +4 -47 rpm/rpmio/rpmmsq.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3501.2.564 -r1.3501.2.565 CHANGES --- rpm/CHANGES 28 May 2017 18:01:52 -0000 1.3501.2.564 +++ rpm/CHANGES 28 May 2017 18:39:22 -0000 1.3501.2.565 @@ -1,4 +1,5 @@ 5.4.17 -> 5.4.18: + - jbj: rpmaio: stub in an AIO aiocb pool. - jbj: msqio: replace pthreads monitor with yarn. - jbj: rpmio: wire up the fooInit callback, pass the message to fooDbug. - jbj: rpmio: stub in fooDbug and fooInit callbacks for pools. @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/Makefile.am ============================================================================ $ cvs diff -u -r1.293.2.81 -r1.293.2.82 Makefile.am --- rpm/rpmio/Makefile.am 23 May 2017 05:54:19 -0000 1.293.2.81 +++ rpm/rpmio/Makefile.am 28 May 2017 18:39:22 -0000 1.293.2.82 @@ -153,9 +153,9 @@ groestl.h hamsi.h jh.h jsmn.h keccak.h lane.h luffa.h md2.h md6.h \ duktape.h mongoc.h radiogatun.h \ salsa10.h salsa20.h shabal.h shavite3.h simd.h skein.h tib3.h tiger.h \ - pcrs.h rpmacl.h rpmasn.h rpmaug.h rpmbag.h rpmbc.h rpmbz.h rpmcap.h \ - rpmcdsa.h rpmct.h rpmcudf.h rpmcvs.h rpmdate.h rpmdav.h rpmdir.h \ - rpmficl.h rpmgc.h rpmgfs.h rpmgit.h rpmhash.h \ + pcrs.h rpmacl.h rpmaio.h rpmasn.h rpmaug.h rpmbag.h rpmbc.h rpmbz.h \ + rpmcap.h rpmcdsa.h rpmct.h rpmcudf.h rpmcvs.h rpmdate.h rpmdav.h \ + rpmdir.h rpmficl.h rpmgc.h rpmgfs.h rpmgit.h rpmhash.h \ rpmhkp.h rpmhook.h rpmio_internal.h rpmjni.h rpmjs.h rpmjsio.h \ rpmkeyring.h rpmku.h rpmltc.h rpmlua.h \ rpmmqtt.h rpmmrb.h rpmmsq.h rpmnix.h rpmnss.h \ @@ -198,6 +198,7 @@ pcrs.c \ poptIO.c \ rpmacl.c \ + rpmaio.c \ rpmasn.c \ rpmaug.c \ rpmbag.c \ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/msqio.c ============================================================================ $ cvs diff -u -r1.1.2.15 -r1.1.2.16 msqio.c --- rpm/rpmio/msqio.c 28 May 2017 18:01:52 -0000 1.1.2.15 +++ rpm/rpmio/msqio.c 28 May 2017 18:39:22 -0000 1.1.2.16 @@ -6,6 +6,9 @@ #include "system.h" #if defined(WITH_MQ) || defined(WITH_MSQ) +#if defined(HAVE_AIO_H) +# include <aio.h> +#endif #if defined(HAVE_SYS_MSG_H) # include <sys/msg.h> #endif @@ -24,6 +27,8 @@ #include <rpmzlog.h> /* XXX rpmzLog type */ #include <yarn.h> +#define _RPMAIO_INTERNAL +#include "rpmaio.h" #define _RPMMSQ_INTERNAL #include "rpmmsq.h" @@ -343,106 +348,6 @@ } /* =============================================================== */ -int _rpmaio_debug = 0; - -static char *LIO_[] = { "READ", "WRITE", "NOP", "DSYNC", "SYNC", "CLOSE" }; -static char * rpmaioDbug(void *_aio, char *b, size_t nb) -{ - rpmaio aio = (rpmaio) _aio; - size_t len = strlen(b); - char * be = b + len; - rpmioItem item = (rpmioItem) aio; - long use; - - if (aio && (use = PEEK(item->use)) > 1) { - int colorize = isatty(fileno(stderr)); -#define ANSI_BRIGHT_BLUE "\x1b[34;1m" -#define ANSI_RESET "\x1b[0m" - *be++ = '\n'; - if (colorize) be = stpcpy(be, ANSI_BRIGHT_BLUE); - be += sprintf(be, "========================== aio(%p) use %ld ix %d\n", - aio, use, aio->ix); -#define PRINT_AIO(_fmt, _foo) \ - { be += sprintf(be, "%25s: %"#_fmt"\n", #_foo, aio->cb._foo); } -#define PRINT_AIO_SIGEV(_fmt, _foo) \ - { be += sprintf(be, "%25s: %"#_fmt"\n", #_foo, aio->cb.aio_sigevent._foo); } - PRINT_AIO(d, aio_fildes); - be += sprintf(be, "%25s: %s\n", "aio_lio_opcode", - LIO_[aio->cb.aio_lio_opcode % (sizeof(LIO_)/sizeof(LIO_[0]))]); - if (aio->cb.aio_reqprio) - PRINT_AIO(d, aio_reqprio); - PRINT_AIO(p, aio_buf); - PRINT_AIO(zd, aio_nbytes); - switch (aio->cb.aio_sigevent.sigev_notify) { - default: - break; - case SIGEV_THREAD: - PRINT_AIO_SIGEV(p, sigev_value.sival_ptr); - PRINT_AIO_SIGEV(d, sigev_signo); - PRINT_AIO_SIGEV(d, sigev_notify); - PRINT_AIO_SIGEV(p, sigev_notify_function); - PRINT_AIO_SIGEV(p, sigev_notify_attributes); - break; - } -#undef PRINT_AIO_SIGEV -#undef PRINT_AIO - be--; - if (colorize) be = stpcpy(be, ANSI_RESET); - *be = '\0'; - } - return b; -} - -static void rpmaioInit(void *_aio) -{ - rpmaio aio = (rpmaio) _aio; - - if (aio) { - aio->cb.aio_fildes = 0; - aio->cb.aio_lio_opcode = 0; - aio->cb.aio_reqprio = 0; - aio->cb.aio_buf = NULL; - aio->cb.aio_nbytes = 0; - aio->ix = -1; - } -} - -static void rpmaioFini(void *_aio) -{ - rpmaio aio = (rpmaio) _aio; - - if (aio) { - aio->cb.aio_fildes = 0; - aio->cb.aio_lio_opcode = 0; - aio->cb.aio_reqprio = 0; - aio->cb.aio_buf = NULL; - aio->cb.aio_nbytes = 0; - aio->ix = -1; - } -} - -RPMIOPOOL_MODULE(aio) - -rpmaio rpmaioNew(int fdno, int op, int prio, void *b, size_t nb) -{ - rpmaio aio = rpmaioGetPool(_rpmaioPool); - - aio->_item.next = NULL; /* XXX rpmmalloc.c ? */ - aio->cb.aio_fildes = fdno; - aio->cb.aio_lio_opcode = op; - aio->cb.aio_reqprio = prio; - aio->cb.aio_buf = b; - aio->cb.aio_nbytes = nb; - - aio->cb.__error_code = EINPROGRESS; /* XXX */ - aio->cb.__return_value = 0; /* XXX */ - - aio->ix = -1; - - return rpmaioLink(aio); -} - -/* =============================================================== */ static char * rpmmsqDbug(void *_msq, char *b, size_t nb) { rpmmsq msq = (rpmmsq) _msq; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/poptIO.c ============================================================================ $ cvs diff -u -r1.94.2.31 -r1.94.2.32 poptIO.c --- rpm/rpmio/poptIO.c 28 May 2017 18:01:52 -0000 1.94.2.31 +++ rpm/rpmio/poptIO.c 28 May 2017 18:39:22 -0000 1.94.2.32 @@ -40,6 +40,7 @@ #include <rpmtpm.h> #include <rpmgfs.h> +#include <rpmaio.h> #include <rpmaug.h> #include <rpmbag.h> #include <rpmbf.h> @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmaio.c ============================================================================ $ cvs diff -u -r0 -r1.1.2.1 rpmaio.c --- /dev/null 2017-05-28 20:38:34.000000000 +0200 +++ rpmaio.c 2017-05-28 20:39:22.973011964 +0200 @@ -0,0 +1,132 @@ +/** \ingroup rpmio + * \file rpmio/msqio.c + * Support for SysV message queues. + */ + +#include "system.h" + +#if defined(WITH_AIO) +#if defined(HAVE_AIO_H) +# include <aio.h> +#endif +#endif /* WITH_AIO */ + +#include <rpmio.h> +#include <yarn.h> + +#define _RPMAIO_INTERNAL +#include "rpmaio.h" + +#include "debug.h" + +int _rpmaio_debug; + +#define SPEW(_fmt, ...) \ + if (_rpmaio_debug || _rpmio_debug) \ + fprintf(stderr, _fmt, __VA_ARGS__) + +#define Z(_rc) assert((_rc) == 0) + +#define PEEK(_bolt) yarnPeekLock(_bolt) + +#ifdef __cplusplus +GENfree(rpmaio) +#endif /* __cplusplus */ + +static char *LIO_[] = { "READ", "WRITE", "NOP", "DSYNC", "SYNC", "CLOSE" }; + +static char * rpmaioDbug(void *_aio, char *b, size_t nb) +{ + rpmaio aio = (rpmaio) _aio; + size_t len = strlen(b); + char * be = b + len; + rpmioItem item = (rpmioItem) aio; + long use; + + if (aio && (use = PEEK(item->use)) > 1) { + int colorize = isatty(fileno(stderr)); +#define ANSI_BRIGHT_BLUE "\x1b[34;1m" +#define ANSI_RESET "\x1b[0m" + *be++ = '\n'; + if (colorize) be = stpcpy(be, ANSI_BRIGHT_BLUE); + be += sprintf(be, "========================== aio(%p) use %ld ix %d\n", + aio, use, aio->ix); +#define PRINT_AIO(_fmt, _foo) \ + { be += sprintf(be, "%25s: %"#_fmt"\n", #_foo, aio->cb._foo); } +#define PRINT_AIO_SIGEV(_fmt, _foo) \ + { be += sprintf(be, "%25s: %"#_fmt"\n", #_foo, aio->cb.aio_sigevent._foo); } + PRINT_AIO(d, aio_fildes); + be += sprintf(be, "%25s: %s\n", "aio_lio_opcode", + LIO_[aio->cb.aio_lio_opcode % (sizeof(LIO_)/sizeof(LIO_[0]))]); + if (aio->cb.aio_reqprio) + PRINT_AIO(d, aio_reqprio); + PRINT_AIO(p, aio_buf); + PRINT_AIO(zd, aio_nbytes); + switch (aio->cb.aio_sigevent.sigev_notify) { + default: + break; + case SIGEV_THREAD: + PRINT_AIO_SIGEV(p, sigev_value.sival_ptr); + PRINT_AIO_SIGEV(d, sigev_signo); + PRINT_AIO_SIGEV(d, sigev_notify); + PRINT_AIO_SIGEV(p, sigev_notify_function); + PRINT_AIO_SIGEV(p, sigev_notify_attributes); + break; + } +#undef PRINT_AIO_SIGEV +#undef PRINT_AIO + be--; + if (colorize) be = stpcpy(be, ANSI_RESET); + *be = '\0'; + } + return b; +} + +static void rpmaioInit(void *_aio) +{ + rpmaio aio = (rpmaio) _aio; + + if (aio) { + aio->cb.aio_fildes = 0; + aio->cb.aio_lio_opcode = 0; + aio->cb.aio_reqprio = 0; + aio->cb.aio_buf = NULL; + aio->cb.aio_nbytes = 0; + aio->ix = -1; + } +} + +static void rpmaioFini(void *_aio) +{ + rpmaio aio = (rpmaio) _aio; + + if (aio) { + aio->cb.aio_fildes = 0; + aio->cb.aio_lio_opcode = 0; + aio->cb.aio_reqprio = 0; + aio->cb.aio_buf = NULL; + aio->cb.aio_nbytes = 0; + aio->ix = -1; + } +} + +RPMIOPOOL_MODULE(aio) + +rpmaio rpmaioNew(int fdno, int op, int prio, void *b, size_t nb) +{ + rpmaio aio = rpmaioGetPool(_rpmaioPool); + + aio->_item.next = NULL; /* XXX rpmmalloc.c ? */ + aio->cb.aio_fildes = fdno; + aio->cb.aio_lio_opcode = op; + aio->cb.aio_reqprio = prio; + aio->cb.aio_buf = b; + aio->cb.aio_nbytes = nb; + + aio->cb.__error_code = EINPROGRESS; /* XXX */ + aio->cb.__return_value = 0; /* XXX */ + + aio->ix = -1; + + return rpmaioLink(aio); +} @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmaio.h ============================================================================ $ cvs diff -u -r0 -r1.1.2.1 rpmaio.h --- /dev/null 2017-05-28 20:38:34.000000000 +0200 +++ rpmaio.h 2017-05-28 20:39:22.982011946 +0200 @@ -0,0 +1,67 @@ +#ifndef _H_RPMAIO_ +#define _H_RPMAIO_ + +/** + */ +extern int _rpmaio_debug; + +typedef struct rpmaio_s * rpmaio; + +#if defined(_RPMAIO_INTERNAL) +enum { + LIO_DSYNC = LIO_NOP+1, + LIO_SYNC, + LIO_CLOSE, + LIO_READ64 = LIO_READ | 128, + LIO_WRITE64 = LIO_WRITE | 128, +}; + +struct rpmaio_s { + struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ + struct aiocb cb; + int ix; +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Unreference a aio wrapper instance. + * @param aio aio wrapper + * @return NULL on last dereference + */ +rpmaio rpmaioUnlink (rpmaio aio); +#define rpmaioUnlink(_aio) \ + ((rpmaio)rpmioUnlinkPoolItem((rpmioItem)(_aio), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Reference a aio wrapper instance. + * @param aio aio wrapper + * @return new aio wrapper reference + */ +rpmaio rpmaioLink (rpmaio aio); +#define rpmaioLink(_aio) \ + ((rpmaio)rpmioLinkPoolItem((rpmioItem)(_aio), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Destroy a aio wrapper. + * @param aio aio wrapper + * @return NULL on last dereference + */ +rpmaio rpmaioFree(rpmaio aio); +#define rpmaioFree(_aio) \ + ((rpmaio)rpmioFreePoolItem((rpmioItem)(_aio), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Create an aio wrapper. + * @return aio wrapper + */ +rpmaio rpmaioNew(int fdno, int op, int prio, void *b, size_t nb); + +#ifdef __cplusplus +} +#endif + +#endif /* _H_RPMAIO_ */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmsq.h ============================================================================ $ cvs diff -u -r1.1.2.12 -r1.1.2.13 rpmmsq.h --- rpm/rpmio/rpmmsq.h 28 May 2017 18:01:53 -0000 1.1.2.12 +++ rpm/rpmio/rpmmsq.h 28 May 2017 18:39:22 -0000 1.1.2.13 @@ -36,53 +36,6 @@ /** */ -#include <aio.h> - -enum { - LIO_DSYNC = LIO_NOP+1, - LIO_SYNC, - LIO_CLOSE, - LIO_READ64 = LIO_READ | 128, - LIO_WRITE64 = LIO_WRITE | 128, -}; - -extern int _rpmaio_debug; - -typedef struct rpmaio_s * rpmaio; - -struct rpmaio_s { - struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ - struct aiocb cb; - int ix; -}; - -/** - * Unreference a aio wrapper instance. - * @param aio aio wrapper - * @return NULL on last dereference - */ -rpmaio rpmaioUnlink (rpmaio aio); -#define rpmaioUnlink(_aio) \ - ((rpmaio)rpmioUnlinkPoolItem((rpmioItem)(_aio), __FUNCTION__, __FILE__, __LINE__)) - -/** - * Reference a aio wrapper instance. - * @param aio aio wrapper - * @return new aio wrapper reference - */ -rpmaio rpmaioLink (rpmaio aio); -#define rpmaioLink(_aio) \ - ((rpmaio)rpmioLinkPoolItem((rpmioItem)(_aio), __FUNCTION__, __FILE__, __LINE__)) - -/** - * Destroy a aio wrapper. - * @param aio aio wrapper - * @return NULL on last dereference - */ -rpmaio rpmaioFree(rpmaio aio); -#define rpmaioFree(_aio) \ - ((rpmaio)rpmioFreePoolItem((rpmioItem)(_aio), __FUNCTION__, __FILE__, __LINE__)) - #if defined(_RPMMSQ_INTERNAL) struct rpmmsq_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ @@ -154,6 +107,10 @@ #define rpmmsqFree(_msq) \ ((rpmmsq)rpmioFreePoolItem((rpmioItem)(_msq), __FUNCTION__, __FILE__, __LINE__)) +/** + * Create a msq wrapper. + * @return msq wrapper + */ rpmmsq rpmmsqNew(const char * path, const char * fmode, int fdno, unsigned flags); ssize_t rpmmsqRecv(rpmmsq msq, char * buf, size_t count, unsigned long *priop); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org