Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/libpcp_web/src/batons.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,25 @@ seriesPassBaton(seriesBatonPhase **head, void *arg, const char *caller)
seriesBatonPhase *next;
seriesBatonMagic *baton = (seriesBatonMagic *)arg;

if (baton == NULL) {
pmNotifyErr(LOG_ERR, "%s: NULL baton from %s\n", __FUNCTION__, caller);
return;
}
if (head == NULL) {
pmNotifyErr(LOG_ERR, "%s: NULL baton from %s\n", __FUNCTION__, caller);
return;
}

if (UNLIKELY(baton->traced || pmDebugOptions.series)) {
fprintf(stderr,
"Baton [%s/%p] references: %u -> %u (@ %s[%s])\n",
magic_str(baton), baton, baton->refcount, baton->refcount - 1,
caller, "seriesPassBaton");
}
assert(baton->refcount);
if (baton->refcount == 0) {
pmNotifyErr(LOG_ERR, "%s: refcount is 0 from %s\n", __FUNCTION__, caller);
return;
}

if (--baton->refcount > 0) {
/* phase still in-progress so no more to do */
Expand Down
19 changes: 19 additions & 0 deletions src/libpcp_web/src/discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ pmDiscoverLookupAdd(const char *fullpath, pmDiscoverModule *module, void *arg)
h->context.name = name;
h->metavol = sdsempty();
h->datavol = sdsempty();
if (h->metavol == NULL || h->datavol == NULL) {
sdsfree(h->metavol);
sdsfree(h->datavol);
sdsfree(name);
free(h);
return NULL;
}
h->module = module;
h->data = arg;
if (p == NULL)
Expand Down Expand Up @@ -297,6 +304,12 @@ pmDiscoverArchives(const char *dir, pmDiscoverModule *module, void *arg)
* if this is a newly discovered archive or directory
*/
a = pmDiscoverLookupAdd(dir, module, arg);
if (a == NULL) {
if (pmDebugOptions.discovery)
fprintf(stderr, "%s: pmDiscoverLookupAdd failed for %s\n",
__FUNCTION__, dir);
return -ENOMEM;
}
a->flags |= DISCOVER_FLAGS_DIRECTORY;

if ((dirp = opendir(dir)) == NULL) {
Expand Down Expand Up @@ -332,6 +345,12 @@ pmDiscoverArchives(const char *dir, pmDiscoverModule *module, void *arg)
*/
*suffix = '\0'; /* strip suffix from path giving archive name */
a = pmDiscoverLookupAdd(path, module, arg);
if (a == NULL) {
if (pmDebugOptions.discovery)
fprintf(stderr, "%s: pmDiscoverLookupAdd failed for %s\n",
__FUNCTION__, path);
continue;
}

/*
* note: pmDiscoverLookupAdd sets DISCOVER_FLAGS_NEW
Expand Down
6 changes: 5 additions & 1 deletion src/libpcp_web/src/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,10 @@ freeSeriesLoadBaton(seriesLoadBaton *baton)
void
doneSeriesLoadBaton(seriesLoadBaton *baton, const char *caller)
{
if (baton == NULL) {
pmNotifyErr(LOG_ERR, "%s: NULL baton from %s\n", __FUNCTION__, caller);
return;
}
seriesPassBaton(&baton->current, baton, caller);
}

Expand Down Expand Up @@ -1310,7 +1314,7 @@ void
pmSeriesDiscoverClosed(pmDiscoverEvent *event, void *arg)
{
pmDiscover *p = (pmDiscover *)event->data;
seriesLoadBaton *baton = p->baton;
seriesLoadBaton *baton = p ? p->baton : NULL;

(void)arg;

Expand Down
Loading