library: a couple of miscellaneous changes, <PIDS> api
This patch represents the following minor adjustments: . old PROCTAB used with select & reap more descriptive . reformatted PROCPS_PIDS_VAL macro like other 3rd gen Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
428ef496a6
commit
8444a6fe0b
14
proc/pids.c
14
proc/pids.c
@ -79,10 +79,10 @@ struct procps_pidsinfo {
|
|||||||
proc_t*(*read_something)(PROCTAB*, proc_t*); // readproc/readeither via which
|
proc_t*(*read_something)(PROCTAB*, proc_t*); // readproc/readeither via which
|
||||||
unsigned pgs2k_shift; // to convert some proc vaules
|
unsigned pgs2k_shift; // to convert some proc vaules
|
||||||
unsigned oldflags; // the old library PROC_FILL flagss
|
unsigned oldflags; // the old library PROC_FILL flagss
|
||||||
PROCTAB *PT; // the old library essential interface
|
PROCTAB *fetch_PT; // oldlib interface for 'select' & 'reap'
|
||||||
unsigned long hertz; // for TIME_ALL & TIME_ELAPSED calculations
|
unsigned long hertz; // for TIME_ALL & TIME_ELAPSED calculations
|
||||||
unsigned long long boot_seconds; // for TIME_ELAPSED calculation
|
unsigned long long boot_seconds; // for TIME_ELAPSED calculation
|
||||||
PROCTAB *get_PT; // old library interface for active 'get'
|
PROCTAB *get_PT; // oldlib interface for active 'get'
|
||||||
struct stacks_extent *get_ext; // an extent used for active 'get'
|
struct stacks_extent *get_ext; // an extent used for active 'get'
|
||||||
enum pids_fetch_type get_type; // last known type of 'get' request
|
enum pids_fetch_type get_type; // last known type of 'get' request
|
||||||
};
|
};
|
||||||
@ -1077,7 +1077,7 @@ static int stacks_fetch (
|
|||||||
|
|
||||||
// iterate stuff --------------------------------------
|
// iterate stuff --------------------------------------
|
||||||
n_inuse = 0;
|
n_inuse = 0;
|
||||||
while (info->read_something(info->PT, &task)) {
|
while (info->read_something(info->fetch_PT, &task)) {
|
||||||
if (!(n_inuse < n_alloc)) {
|
if (!(n_inuse < n_alloc)) {
|
||||||
n_alloc += MEMORY_INCR;
|
n_alloc += MEMORY_INCR;
|
||||||
if ((!(info->fetch.anchor = realloc(info->fetch.anchor, sizeof(void *) * n_alloc)))
|
if ((!(info->fetch.anchor = realloc(info->fetch.anchor, sizeof(void *) * n_alloc)))
|
||||||
@ -1337,13 +1337,13 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_reap (
|
|||||||
if (!info->curitems)
|
if (!info->curitems)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!oldproc_open(&info->PT, info->oldflags))
|
if (!oldproc_open(&info->fetch_PT, info->oldflags))
|
||||||
return NULL;
|
return NULL;
|
||||||
info->read_something = which ? readeither : readproc;
|
info->read_something = which ? readeither : readproc;
|
||||||
|
|
||||||
rc = stacks_fetch(info);
|
rc = stacks_fetch(info);
|
||||||
|
|
||||||
oldproc_close(&info->PT);
|
oldproc_close(&info->fetch_PT);
|
||||||
// we better have found at least 1 pid
|
// we better have found at least 1 pid
|
||||||
return (rc > 0) ? &info->fetch.results : NULL;
|
return (rc > 0) ? &info->fetch.results : NULL;
|
||||||
} // end: procps_pids_reap
|
} // end: procps_pids_reap
|
||||||
@ -1421,13 +1421,13 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_select (
|
|||||||
memcpy(ids, these, sizeof(unsigned) * numthese);
|
memcpy(ids, these, sizeof(unsigned) * numthese);
|
||||||
ids[numthese] = 0;
|
ids[numthese] = 0;
|
||||||
|
|
||||||
if (!oldproc_open(&info->PT, (info->oldflags | which), ids, numthese))
|
if (!oldproc_open(&info->fetch_PT, (info->oldflags | which), ids, numthese))
|
||||||
return NULL;
|
return NULL;
|
||||||
info->read_something = readproc;
|
info->read_something = readproc;
|
||||||
|
|
||||||
rc = stacks_fetch(info);
|
rc = stacks_fetch(info);
|
||||||
|
|
||||||
oldproc_close(&info->PT);
|
oldproc_close(&info->fetch_PT);
|
||||||
// no guarantee any pids/uids were found
|
// no guarantee any pids/uids were found
|
||||||
return (rc > -1) ? &info->fetch.results : NULL;
|
return (rc > -1) ? &info->fetch.results : NULL;
|
||||||
} // end: procps_pids_select
|
} // end: procps_pids_select
|
||||||
|
@ -192,8 +192,8 @@ struct pids_fetch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define PROCPS_PIDS_VAL(rel_enum,type,stack) \
|
#define PROCPS_PIDS_VAL( relative_enum, type, stack ) \
|
||||||
stack -> head [ rel_enum ] . result . type
|
stack -> head [ relative_enum ] . result . type
|
||||||
|
|
||||||
|
|
||||||
struct procps_pidsinfo;
|
struct procps_pidsinfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user