Continuation of a discussion from IRC, with conclusions and a patch ...
The current state of play is described as follows ... things noted as
WRONG are indeed so, and the attached patch addresses all of them.
Nathan, unless you want otherwise, I'll leave you to merge this patch
with your changes (that I suspect address only the dbpmda issue) and
I'll keep my changes local and uncommitted awaiting the true gospel from
oss.sgi.com.
-------------------
src/pmcd/src/dopdus.c
DoText()
if AGENT_DSO calls version.*.text() (separate cases for
one.text, two.text and four.text)
otherwise buffer is malloc'd via __pmDecodeText()
if (DSO AND PMDA_INTERFACE_1) OR (not DSO) free(buffer)
src/dbpmda/src/pmda.c
calls __pmDecodeText() & free(buffer)
src/dbpmda/src/dso.c
calls version.*.text() depending on PMDA_INTERFACE_x & free(buffer)
WRONG - should not call free() unless using PMDA_INTERFACE_1
src/libpcp/src/p_text.c
in __pmDecodeText(), buffer is malloc'd
src/libpcp/src/help.c
below pmLookupText()
if PM_CONTEXT_HOST buffer is malloc'd via __pmDecodeText()
if PM_CONTEXT_LOCAL calls calls version.*.text() then
strdup's buffer
WRONG ... should not strdup for PMDA_INTERFACE_1
so in both cases PMAPI contract for client is honoured and
man/man3/pmdatext.3
is just plain WRONG ... the returned buffer should never be
free'd
client must free()
libpcp_pmda/src/help.c
pmdaGetHelp() and pmdaGetInDomHelp() return a pointer into
the mmap'd help file
libpcp_pmda/src/callback.c
pmdaText() calls pmdaGetHelp() or pmdaGetInDomHelp(), and so
returns a non-malloc'd buffer
libpcp_pmda/src/mainloop.c
__pmdaMainPDU() calls version.*.text() then free's the result
buffer
WRONG - should not call free() unless using PMDA_INTERFACE_1
pmdas/mmv/mmv.c
mmv_text() returns static buffer else pointer into mmap
area
pmdas/sample/src/sample.c
sample_text() calls pmdaText()
pmdas/summary/mainloop.c
calls version.two.text()
patch.pcp
Description: Text Data
|