summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2003-04-02 23:26:06 +0000
committerjbj <devnull@localhost>2003-04-02 23:26:06 +0000
commit598457907828b062cedc2cff252aeeab7b988fce (patch)
treec5da5e5a4e73420a8dd6105fe5705d9f41483be5
parent95f01d39a57c3c3d8ebf80cfd78e67c550dc32e5 (diff)
downloadlibrpm-tizen-598457907828b062cedc2cff252aeeab7b988fce.tar.gz
librpm-tizen-598457907828b062cedc2cff252aeeab7b988fce.tar.bz2
librpm-tizen-598457907828b062cedc2cff252aeeab7b988fce.zip
Use rpmswEnter/rpmswExit throughout.
CVS patchset: 6730 CVS date: 2003/04/02 23:26:06
-rw-r--r--lib/depends.c8
-rw-r--r--lib/psm.c11
-rw-r--r--lib/rpmts.c2
-rw-r--r--lib/rpmts.h6
-rw-r--r--lib/transaction.c16
-rw-r--r--rpmio/rpmio.c3
-rw-r--r--rpmio/rpmio_internal.h55
-rw-r--r--rpmio/rpmsq.c17
-rw-r--r--rpmio/rpmsq.h5
-rw-r--r--rpmio/rpmsw.c8
-rw-r--r--rpmio/rpmsw.h17
11 files changed, 65 insertions, 83 deletions
diff --git a/lib/depends.c b/lib/depends.c
index 856759916..bfe02be50 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -1179,7 +1179,7 @@ int rpmtsOrder(rpmts ts)
rpmalMakeIndex(ts->addedPackages);
#endif
- (void) rpmswNow(&ts->begin);
+ (void) rpmswEnter(&ts->op, -1);
/* T1. Initialize. */
if (oType == 0)
@@ -1582,7 +1582,7 @@ assert(newOrderCount == ts->orderCount);
#endif
freeBadDeps();
- ts->ms_order += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
+ ts->ms_order += rpmswExit(&ts->op, -1)/1000;
return 0;
}
@@ -1597,7 +1597,7 @@ int rpmtsCheck(rpmts ts)
int xx;
int rc;
- (void) rpmswNow(&ts->begin);
+ (void) rpmswEnter(&ts->op, -1);
/* Do lazy, readonly, open of rpm database. */
if (rpmtsGetRdb(ts) == NULL && ts->dbmode != -1) {
@@ -1724,7 +1724,7 @@ exit:
mi = rpmdbFreeIterator(mi);
pi = rpmtsiFree(pi);
- ts->ms_check += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
+ ts->ms_check += rpmswExit(&ts->op, -1)/1000;
/*@-branchstate@*/
if (closeatexit)
diff --git a/lib/psm.c b/lib/psm.c
index c755cf8f1..d637443e7 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -470,13 +470,18 @@ static pid_t psmWait(rpmpsm psm)
/*@globals fileSystem, internalState @*/
/*@modifies psm, fileSystem, internalState @*/
{
+ const rpmts ts = psm->ts;
+ rpmtime_t msecs;
+
(void) rpmsqWait(&psm->sq);
+ msecs = psm->sq.op.usecs/1000;
+ ts->ms_scriptlets += msecs;
- rpmMessage(RPMMESS_DEBUG, _("%s: waitpid(%d) rc %d status %x secs %u.%03u\n"),
+ rpmMessage(RPMMESS_DEBUG,
+ _("%s: waitpid(%d) rc %d status %x secs %u.%03u\n"),
psm->stepName, (unsigned)psm->sq.child,
(unsigned)psm->sq.reaped, psm->sq.status,
- (unsigned)psm->sq.msecs/1000,
- (unsigned)psm->sq.msecs%1000);
+ (unsigned)msecs/1000, (unsigned)msecs%1000);
return psm->sq.reaped;
}
diff --git a/lib/rpmts.c b/lib/rpmts.c
index 070a62c3d..13710a5c2 100644
--- a/lib/rpmts.c
+++ b/lib/rpmts.c
@@ -1270,8 +1270,6 @@ rpmts rpmtsCreate(void)
memset(ts->pksignid, 0, sizeof(ts->pksignid));
ts->dig = NULL;
- (void) rpmswNow(&ts->create);
-
ts->nrefs = 0;
return rpmtsLink(ts, "tsCreate");
diff --git a/lib/rpmts.h b/lib/rpmts.h
index 26b98333e..9e7ab76d3 100644
--- a/lib/rpmts.h
+++ b/lib/rpmts.h
@@ -194,15 +194,15 @@ struct rpmts_s {
size_t pkpktlen; /*!< Current pubkey packet length. */
unsigned char pksignid[8]; /*!< Current pubkey fingerprint. */
- struct rpmsw_s create; /*!< Creation time stamp. */
- struct rpmsw_s begin; /*!< Begin operation time stamp. */
- struct rpmsw_s end; /*!< End operation time stamp. */
+ struct rpmop_s op; /*!< Transaction operation time stamp. */
+
rpmtime_t ms_check;
rpmtime_t ms_order;
rpmtime_t ms_fingerprint;
rpmtime_t ms_repackage;
rpmtime_t ms_install;
rpmtime_t ms_erase;
+ rpmtime_t ms_scriptlets;
/*@null@*/
pgpDig dig; /*!< Current signature/pubkey parameters. */
diff --git a/lib/transaction.c b/lib/transaction.c
index 41ceba2f5..fc2b6ac7b 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -1154,7 +1154,7 @@ rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elements\n"), rpmtsNElements(ts)
*/
rpmMessage(RPMMESS_DEBUG, _("computing %d file fingerprints\n"), totalFileCount);
-(void) rpmswNow(&ts->begin);
+ (void) rpmswEnter(&ts->op, -1);
numAdded = numRemoved = 0;
pi = rpmtsiInit(ts);
@@ -1367,7 +1367,7 @@ rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n"));
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_STOP, 6, ts->orderCount,
NULL, ts->notifyData));
-ts->ms_fingerprint += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
+ ts->ms_fingerprint += rpmswExit(&ts->op, -1)/1000;
/* ===============================================
* Free unused memory as soon as possible.
@@ -1424,7 +1424,7 @@ ts->ms_fingerprint += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
numRemoved, NULL, ts->notifyData));
progress++;
-(void) rpmswNow(&ts->begin);
+ (void) rpmswEnter(&ts->op, -1);
/* XXX TR_REMOVED needs CPIO_MAP_{ABSOLUTE,ADDDOT} CPIO_ALL_HARDLINKS */
fi->mapflags |= CPIO_MAP_ABSOLUTE;
@@ -1437,7 +1437,7 @@ ts->ms_fingerprint += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
fi->mapflags &= ~CPIO_MAP_ADDDOT;
fi->mapflags &= ~CPIO_ALL_HARDLINKS;
-ts->ms_repackage += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
+ ts->ms_repackage += rpmswExit(&ts->op, -1)/1000;
/*@switchbreak@*/ break;
}
@@ -1472,7 +1472,7 @@ assert(psm != NULL);
switch (rpmteType(p)) {
case TR_ADDED:
-(void) rpmswNow(&ts->begin);
+ (void) rpmswEnter(&ts->op, -1);
pkgKey = rpmteAddedKey(p);
@@ -1569,12 +1569,12 @@ assert(psm != NULL);
p->h = headerFree(p->h);
-ts->ms_install += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
+ ts->ms_install += rpmswExit(&ts->op, -1)/1000;
/*@switchbreak@*/ break;
case TR_REMOVED:
-(void) rpmswNow(&ts->begin);
+ (void) rpmswEnter(&ts->op, -1);
rpmMessage(RPMMESS_DEBUG, "========== --- %s\n", rpmteNEVR(p));
/*
@@ -1586,7 +1586,7 @@ ts->ms_install += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
ourrc++;
}
-ts->ms_erase += rpmswDiff(rpmswNow(&ts->end), &ts->begin)/1000;
+ ts->ms_erase += rpmswExit(&ts->op, -1)/1000;
/*@switchbreak@*/ break;
}
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index 0ea141e79..c0595f834 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -356,9 +356,6 @@ FD_t XfdNew(const char * msg, const char * file, unsigned line)
fd->ndigests = 0;
memset(fd->digests, 0, sizeof(fd->digests));
- (void) rpmswNow(&fd->stats->create);
- (void) rpmswNow(&fd->stats->begin);
-
fd->ftpFileDoneNeeded = 0;
fd->firstFree = 0;
fd->fileSize = 0;
diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h
index 64eebd59f..ec895af44 100644
--- a/rpmio/rpmio_internal.h
+++ b/rpmio/rpmio_internal.h
@@ -115,7 +115,6 @@ enum FDSTAT_e {
* Cumulative statistics for a descriptor.
*/
typedef /*@abstract@*/ struct {
- struct rpmsw_s create; /*!< Structure creation time. */
struct rpmsw_s begin; /*!< Operation start time. */
struct rpmop_s ops[4]; /*!< Cumulative statistics. */
} * FDSTAT_t;
@@ -131,7 +130,8 @@ typedef struct _FDDIGEST_s {
* The FD_t File Handle data structure.
*/
struct _FD_s {
-/*@refs@*/ int nrefs;
+/*@refs@*/
+ int nrefs;
int flags;
#define RPMIO_DEBUG_IO 0x40000000
#define RPMIO_DEBUG_REFS 0x20000000
@@ -141,7 +141,8 @@ struct _FD_s {
FDSTACK_t fps[8];
int urlType; /* ufdio: */
-/*@dependent@*/ void * url; /* ufdio: URL info */
+/*@dependent@*/
+ void * url; /* ufdio: URL info */
int rd_timeoutsecs; /* ufdRead: per FD_t timer */
ssize_t bytesRemain; /* ufdio: */
ssize_t contentLength; /* ufdio: */
@@ -149,7 +150,8 @@ struct _FD_s {
int wr_chunked; /* ufdio: */
int syserrno; /* last system errno encountered */
-/*@observer@*/ const void *errcookie; /* gzdio/bzdio/ufdio: */
+/*@observer@*/
+ const void *errcookie; /* gzdio/bzdio/ufdio: */
FDSTAT_t stats; /* I/O statistics */
@@ -356,17 +358,16 @@ void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
/** \ingroup rpmio
*/
-/*@-uniondef@*/
/*@unused@*/ static inline
void fdstat_enter(/*@null@*/ FD_t fd, int opx)
/*@globals internalState @*/
/*@modifies fd, internalState @*/
{
- if (fd == NULL || fd->stats == NULL) return;
+ if (fd == NULL) return;
/*@-boundswrite@*/
- fd->stats->ops[opx].count++;
+ if (fd->stats != NULL)
+ (void) rpmswEnter(&fd->stats->ops[opx], 0);
/*@=boundswrite@*/
- (void) rpmswNow(&fd->stats->begin);
}
/** \ingroup rpmio
@@ -376,28 +377,16 @@ void fdstat_exit(/*@null@*/ FD_t fd, int opx, ssize_t rc)
/*@globals internalState @*/
/*@modifies fd, internalState @*/
{
- struct rpmsw_s end;
if (fd == NULL) return;
- if (rc == -1) fd->syserrno = errno;
- if (fd->stats == NULL) return;
+ if (rc == -1)
+ fd->syserrno = errno;
+ else if (rc > 0 && fd->bytesRemain > 0)
+ fd->bytesRemain -= rc;
/*@-boundswrite@*/
- (void) rpmswNow(&end);
- if (rc >= 0) {
- switch(opx) {
- case FDSTAT_SEEK:
- fd->stats->ops[opx].bytes = rc;
- break;
- default:
- fd->stats->ops[opx].bytes += rc;
- if (fd->bytesRemain > 0) fd->bytesRemain -= rc;
- break;
- }
- }
- fd->stats->ops[opx].usecs += rpmswDiff(&end, &fd->stats->begin);
- fd->stats->begin = end; /* structure assignment */
+ if (fd->stats != NULL)
+ (void) rpmswExit(&fd->stats->ops[opx], rc);
/*@=boundswrite@*/
}
-/*@=uniondef@*/
/** \ingroup rpmio
*/
@@ -407,25 +396,25 @@ void fdstat_print(/*@null@*/ FD_t fd, const char * msg, FILE * fp)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
- static int usec_scale = 1000000;
+ static int usec_scale = (1000*1000);
int opx;
if (fd == NULL || fd->stats == NULL) return;
for (opx = 0; opx < 4; opx++) {
- rpmop ops = &fd->stats->ops[opx];
- if (ops->count <= 0) continue;
+ rpmop op = &fd->stats->ops[opx];
+ if (op->count <= 0) continue;
switch (opx) {
case FDSTAT_READ:
if (msg) fprintf(fp, "%s:", msg);
fprintf(fp, "%8d reads, %8ld total bytes in %d.%06d secs\n",
- ops->count, (long)ops->bytes,
- (int)(ops->usecs/usec_scale), (int)(ops->usecs%usec_scale));
+ op->count, (long)op->bytes,
+ (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale));
/*@switchbreak@*/ break;
case FDSTAT_WRITE:
if (msg) fprintf(fp, "%s:", msg);
fprintf(fp, "%8d writes, %8ld total bytes in %d.%06d secs\n",
- ops->count, (long)ops->bytes,
- (int)(ops->usecs/usec_scale), (int)(ops->usecs%usec_scale));
+ op->count, (long)op->bytes,
+ (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale));
/*@switchbreak@*/ break;
case FDSTAT_SEEK:
/*@switchbreak@*/ break;
diff --git a/rpmio/rpmsq.c b/rpmio/rpmsq.c
index fe58d0983..e676857fa 100644
--- a/rpmio/rpmsq.c
+++ b/rpmio/rpmsq.c
@@ -340,15 +340,6 @@ fprintf(stderr, " Parent(%p): %p child %d\n", ME(), sq, sq->child);
/*@=modfilesys@*/
#endif
-#ifdef DYING
-/*@-bounds@*/
- /* Unblock child. */
- xx = close(sq->pipes[0]);
- xx = close(sq->pipes[1]);
- sq->pipes[0] = sq->pipes[1] = -1;
-/*@=bounds@*/
-#endif
-
}
out:
@@ -365,7 +356,6 @@ static int rpmsqWaitUnregister(rpmsq sq)
/*@globals fileSystem, internalState @*/
/*@modifies sq, fileSystem, internalState @*/
{
- struct rpmsw_s end;
int same_thread = 0;
int ret = 0;
int xx;
@@ -384,7 +374,7 @@ static int rpmsqWaitUnregister(rpmsq sq)
sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
- (void) rpmswNow(&sq->begin);
+ (void) rpmswEnter(&sq->op, -1);
/*@-infloops@*/
while (ret == 0 && sq->reaped != sq->child) {
@@ -395,10 +385,7 @@ static int rpmsqWaitUnregister(rpmsq sq)
}
/*@=infloops@*/
-/*@-uniondef@*/
- sq->msecs = rpmswDiff(rpmswNow(&end), &sq->begin)/1000;
-/*@=uniondef@*/
- sq->script_msecs += sq->msecs;
+ sq->ms_scriptlets += rpmswExit(&sq->op, -1)/1000;
if (same_thread)
xx = sigrelse(SIGCHLD);
diff --git a/rpmio/rpmsq.h b/rpmio/rpmsq.h
index 6d80f7853..40b829029 100644
--- a/rpmio/rpmsq.h
+++ b/rpmio/rpmsq.h
@@ -39,9 +39,8 @@ struct rpmsqElem {
pid_t child; /*!< Currently running child. */
volatile pid_t reaped; /*!< Reaped waitpid(3) return. */
volatile int status; /*!< Reaped waitpid(3) status. */
- struct rpmsw_s begin; /*!< Start time. */
- rpmtime_t msecs; /*!< Instance duration (msecs). */
- rpmtime_t script_msecs; /*!< Accumulated script duration (msecs). */
+ struct rpmop_s op; /*!< Scriptlet operation timestamp; */
+ rpmtime_t ms_scriptlets; /*!< Accumulated script duration (msecs). */
int reaper; /*!< Register SIGCHLD handler? */
int pipes[2]; /*!< Parent/child interlock. */
void * id; /*!< Blocking thread id (pthread_t). */
diff --git a/rpmio/rpmsw.c b/rpmio/rpmsw.c
index 4d521deb2..89333b0f2 100644
--- a/rpmio/rpmsw.c
+++ b/rpmio/rpmsw.c
@@ -250,16 +250,18 @@ rpmtime_t rpmswInit(void)
/*@=incondefs@*/
/*@-mods@*/
-int rpmswEnter(rpmop op)
+int rpmswEnter(rpmop op, ssize_t rc)
{
op->count++;
+ if (rc < 0)
+ op->usecs = 0;
/*@-uniondef@*/
(void) rpmswNow(&op->begin);
/*@=uniondef@*/
return 0;
}
-int rpmswExit(rpmop op, ssize_t rc)
+rpmtime_t rpmswExit(rpmop op, ssize_t rc)
{
struct rpmsw_s end;
@@ -268,6 +270,6 @@ int rpmswExit(rpmop op, ssize_t rc)
/*@=uniondef@*/
if (rc > 0)
op->bytes += rc;
- return 0;
+ return op->usecs;
}
/*@=mods@*/
diff --git a/rpmio/rpmsw.h b/rpmio/rpmsw.h
index 48bcf1b20..6ed42e58a 100644
--- a/rpmio/rpmsw.h
+++ b/rpmio/rpmsw.h
@@ -45,18 +45,22 @@ extern "C" {
* @param *sw time stamp
* @return 0 on success
*/
+/*@-exportlocal@*/
/*@null@*/
rpmsw rpmswNow(/*@returned@*/ rpmsw sw)
/*@globals internalState @*/
/*@modifies sw, internalState @*/;
+/*@=exportlocal@*/
/** Return benchmark time stamp difference.
* @param *end end time stamp
* @param *begin begin time stamp
* @return difference in micro-seconds
*/
+/*@-exportlocal@*/
rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin)
/*@*/;
+/*@=exportlocal@*/
/** Return benchmark time stamp overhead.
* @return overhead in micro-seconds
@@ -64,27 +68,28 @@ rpmtime_t rpmswDiff(/*@null@*/ rpmsw end, /*@null@*/ rpmsw begin)
/*@-exportlocal@*/
rpmtime_t rpmswInit(void)
/*@globals internalState @*/
- /*@modifes internalState @*/;
+ /*@modifies internalState @*/;
/*@=exportlocal@*/
/** \ingroup rpmio
* Enter timed operation.
* @param op operation statistics
+ * @param rc -1 clears usec counter
* @return 0 always
*/
-int rpmswEnter(rpmop op)
+int rpmswEnter(rpmop op, ssize_t rc)
/*@globals internalState @*/
- /*@modifes op->count, op->begin, internalState @*/;
+ /*@modifies *op, internalState @*/;
/** \ingroup rpmio
* Exit timed operation.
* @param op operation statistics
* @param rc per-operation data (e.g. bytes transferred)
- * @return 0 always
+ * @return cumulative usecs for operation
*/
-int rpmswExit(rpmop op, ssize_t rc)
+rpmtime_t rpmswExit(rpmop op, ssize_t rc)
/*@globals internalState @*/
- /*@modifes op-bytes, op->usecs, internalState @*/;
+ /*@modifies *op, internalState @*/;
#ifdef __cplusplus
}