mirror of https://github.com/xzeldon/htop.git
Handle interrupted sampling from within libpcp PDU transfers
This situation can arise if pcp-htop screen is resized right at the same time sampling from pmcd(1) is happening. Have a couple more goes at it before giving up entirely; once there is no data available though we cannot proceed into accessing the sample result data structure (segv will result) so a new short-circuit guard is added there also.
This commit is contained in:
parent
f75a8bc3a1
commit
8ac8542b6e
|
@ -164,7 +164,10 @@ bool PCPMetric_fetch(struct timeval* timestamp) {
|
|||
pmFreeResult(pcp->result);
|
||||
pcp->result = NULL;
|
||||
}
|
||||
int sts = pmFetch(pcp->totalMetrics, pcp->fetch, &pcp->result);
|
||||
int sts, count = 0;
|
||||
do {
|
||||
sts = pmFetch(pcp->totalMetrics, pcp->fetch, &pcp->result);
|
||||
} while (sts == PM_ERR_IPC && ++count < 3);
|
||||
if (sts < 0) {
|
||||
if (pmDebugOptions.appl0)
|
||||
fprintf(stderr, "Error: cannot fetch metric values: %s\n",
|
||||
|
|
|
@ -680,7 +680,8 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||
PCPMetric_enable(PCP_PROC_SMAPS_SWAPPSS, smaps_flag && enabled);
|
||||
|
||||
struct timeval timestamp;
|
||||
PCPMetric_fetch(×tamp);
|
||||
if (PCPMetric_fetch(×tamp) != true)
|
||||
return;
|
||||
|
||||
double sample = this->timestamp;
|
||||
this->timestamp = pmtimevalToReal(×tamp);
|
||||
|
|
Loading…
Reference in New Issue