The following commit implements a global timeout for
__pmDiscoverServicesWithOptions().
The timeout is specified as "timeout=N.N" in the global options string
argument, where N.N is a floating point value indicating the number of
seconds before timing out.
The implementation is a sleeping thread which wakes up after the
specified amount of time and sets a flag indicating that the timeout has
expired. If the discovery process finishes before the timeout, the
sleeping thread is cancelled. The flag exists on the stack of
__pmDiscoverServicesWithOptions() which joins with the sleeping thread
before returning, thus ensuring that it is always safe for the sleeping
thread to set the flag.
The implementation is reflected in pmfind(1) vie the new --timeout=N.N
and -t N.N options.
The implementation also creates a new __pmServiceDiscoveryOptions struct
which gets passed among the internal functions where the 'flags'
argument of __pmDiscoverServicesWithOptions() was previously passed. It
also consolidates some duplication among various internal options
structures.
As usual, it's on the brolley/dev branch of pcpfans.
Dave
----------------------------------------------------
commit 567fadf6b8c59f86467f3a68c70ad7612bb7c3ce
Author: Dave Brolley <brolley@xxxxxxxxxx>
Date: Tue Jul 22 14:41:25 2014 -0400
Implement a global timeout option for service discovery.
timeout=N.N in the options string will interrupt service
discovery if it has not completed within the specified
number of seconds.
|