Historically xstat_cm_test and xstat_fs_test have supported option
'-period <mm>' to specify continuous operaiton for a length of time. If
'-period 0' was specified, both programs exited immediately.
Beginning with commits
2c1a7e47336c8f8d14dd6c65d53925a9e0e87c66 'xstat:
add xstat_*_Wait functions' and
6b67cac432043a43d7cdfa6af972ab54412aff94
'convert xstat and friends to pthreads', xstat_cm_test and xstat_fs_test
now support -period 0 to run "forever". This support is implemented in
xstat_cm_Wait and xstat_fs_Wait, respectively. Although the "wait
forever" logic was added to allow consolidation of similar code in
afsmonitor, it also changed how xstat_cm_test and xstat_fs_test behave
for '-period 0'.
Unfortunately, there is a bug in this support, at least when running on
pthreads. After the initial 24 minute timer expires, the while (1) will
repeatedly run select with a timeout that is now 0. This causes the
while loop to consume 100% of the CPU on which this thread is
dispatched.
Instead, modify the wait-forever logic to specify NULL for the select()
timeout value. Also update the man page to document that '-period 0'
means forever.
Change-Id: I25d0d5be0eedb8bf3de495785b9b03a3e3d45221
Reviewed-on: https://gerrit.openafs.org/14366
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
=item B<-period> <I<data collection time>>
Sets the number of minutes the program runs; at the end of this period of
-time, the program exits. The default is 10 minutes.
+time, the program exits. The default is 10 minutes. Period 0 means run
+forever.
=item B<-debug>
}
} else if (sleep_secs == 0) {
/* Sleep forever. */
- tv.tv_sec = 24 * 60;
- tv.tv_usec = 0;
if (xstat_cm_debug)
fprintf(stderr, "[%s] going to sleep ...\n", rn);
while (1) {
0, /*Descriptors ready for reading */
0, /*Descriptors ready for writing */
0, /*Descriptors with exceptional conditions */
- &tv); /*Timeout structure */
+ NULL); /* NULL timeout means "forever" */
if (code < 0) {
fprintf(stderr, "[%s] select() error %d\n", rn, errno);
break;
}
} else if (sleep_secs == 0) {
/* Sleep forever. */
- tv.tv_sec = 24 * 60;
- tv.tv_usec = 0;
if (xstat_fs_debug)
fprintf(stderr, "[ %s ] going to sleep ...\n", rn);
while (1) {
0, /*Descriptors ready for reading */
0, /*Descriptors ready for writing */
0, /*Descriptors with exceptional conditions */
- &tv); /*Timeout structure */
+ NULL); /* NULL timeout means "forever" */
if (code < 0) {
fprintf(stderr, "[%s] select() error %d\n", rn, errno);
break;