pcp
[Top] [All Lists]

Re: [pcp] pmRegisterDerived return values

To: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Subject: Re: [pcp] pmRegisterDerived return values
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Thu, 21 Jan 2016 19:03:56 -0500 (EST)
Cc: Marko Myllynen <myllynen@xxxxxxxxxx>, pcp developers <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <006201d153e5$03a61fd0$0af25f70$@internode.on.net>
References: <569CB025.4070603@xxxxxxxxxx> <569CB7C5.7030803@xxxxxxxxxxxxxxxx> <1305297915.11201184.1453261568406.JavaMail.zimbra@xxxxxxxxxx> <006201d153e5$03a61fd0$0af25f70$@internode.on.net>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: AQIHi+15HIXLtpebrkfAOJtsaFEj0AIkYFWzAnUHQ96ec+Vf4PJ+VzMO
Thread-topic: pmRegisterDerived return values
Hi Ken,

----- Original Message -----
> > -----Original Message-----
> [...]
> So, if this becomes a new function pmRegisterDerivedMetric_r(...) ... then
> the implementation changes are a bit messy ... the error buffer is currently
> used at a heap of places that will require errmsg to be passed down as an
> additional parameter along all the call paths.  Ugly yes, impossible no.

I think it may not be quite so bad.  I've pushed one simplified approach to
my git tree, if you could take a look?  I went with a non-underscore-r name
since the original is thread-safe really, and modelled it very closely on
pmParseInterval(3) and similar APIs error handling (which differs again to
many of the *_r routines, which take buffer+length).

Whaddyareckon?  It definitely resolves the bug - verified it with extension
to the existing python test cases.


Changes committed to git://git.pcp.io/nathans/pcp.git master

Nathan Scott (1):
      libpcp: add pmRegisterDerivedMetric for python-friendly error handling


 man/man3/pmparseinterval.3   |    4 ++-
 man/man3/pmregisterderived.3 |   50 ++++++++++++++++++++++++++++++++++++-
 qa/803                       |   26 +++++++++++++++++++
 qa/803.out                   |    8 ++++++
 qa/group                     |    1 
 qa/src/.gitignore            |    1 
 qa/src/GNUlocaldefs          |    2 -
 qa/src/derived.c             |   57 +++++++++++++++++++++++++++++++++++++++++++
 qa/src/test_pcp.python       |    2 -
 src/include/pcp/pmapi.h      |    1 
 src/libpcp/src/derive.c      |   37 +++++++++++++++++++++++++++
 src/libpcp/src/exports       |    1 
 src/libpcp/src/getopt.c      |    2 -
 src/python/pcp/pmapi.py      |   25 ++++++------------
 14 files changed, 196 insertions(+), 21 deletions(-)


commit 7f498293ba665cf748ed33e2681b54353b9f8964
Author: Nathan Scott <nathans@xxxxxxxxxx>
Date:   Fri Jan 22 11:00:35 2016 +1100

    libpcp: add pmRegisterDerivedMetric for python-friendly error handling
    
    Accessing thread-local storage used in libpcp (via pmDerivedErrStr) is
    proving highly problematic.  So, add a convenience routine to do very
    similar error handling to pmLoadDerivedConfig, and that is modelled on
    the likes of pmParseInterval (caller gets a buffer to free on error).
    
    Test program added to exercise the C API, and python tests extended to
    verify access from python-land, now handled like all other exceptions.
    
    Resolves Fedora BZ #1299806.


cheers.

--
Nathan

<Prev in Thread] Current Thread [Next in Thread>