diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 79c58b0f4..bf045b0f3 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -15,6 +15,16 @@ EPICS Base 3.15.0.x releases are not intended for use in production systems.
Code that calls errlogRemoveListener(myfunc) must be modified to use +the new, safer routine errlogRemoveListeners(myfunc, &pvt) instead. +The replacement routine takes a second argument which must be the same private +pointer that was passed to errlogAddListener() when adding that +listener. It also deletes all matching listeners (hence the new plural name) and +returns how many were actually deleted, whereas the previous routine only +removed the first listener that matched.
+The Perl script makeIncludeDbd.pl has been removed and the rules diff --git a/src/libCom/error/errlog.c b/src/libCom/error/errlog.c index 05df1bc0d..b2714d7a9 100644 --- a/src/libCom/error/errlog.c +++ b/src/libCom/error/errlog.c @@ -331,11 +331,12 @@ epicsShareFunc void epicsShareAPI errlogAddListener( ellAdd(&pvtData.listenerList,&plistenerNode->node); epicsMutexUnlock(pvtData.listenerLock); } - -epicsShareFunc void epicsShareAPI errlogRemoveListener( - errlogListener listener) + +epicsShareFunc int epicsShareAPI errlogRemoveListeners( + errlogListener listener, void *pPrivate) { listenerNode *plistenerNode; + int count = 0; errlogInit(0); if (!pvtData.atExit) @@ -343,21 +344,25 @@ epicsShareFunc void epicsShareAPI errlogRemoveListener( plistenerNode = (listenerNode *)ellFirst(&pvtData.listenerList); while (plistenerNode) { - if (plistenerNode->listener==listener) { + listenerNode *pnext = (listenerNode *)ellNext(&plistenerNode->node); + + if (plistenerNode->listener == listener && + plistenerNode->pPrivate == pPrivate) { ellDelete(&pvtData.listenerList, &plistenerNode->node); - free((void *)plistenerNode); - break; + free(plistenerNode); + ++count; } - plistenerNode = (listenerNode *)ellNext(&plistenerNode->node); + plistenerNode = pnext; } if (!pvtData.atExit) epicsMutexUnlock(pvtData.listenerLock); - if (!plistenerNode) { + if (count == 0) { fprintf(pvtData.console, - "errlogRemoveListener did not find listener\n"); + "errlogRemoveListeners: No listeners found\n"); } + return count; } epicsShareFunc int epicsShareAPI eltc(int yesno) diff --git a/src/libCom/error/errlog.h b/src/libCom/error/errlog.h index 24902d57a..14061bb87 100644 --- a/src/libCom/error/errlog.h +++ b/src/libCom/error/errlog.h @@ -57,8 +57,8 @@ epicsShareFunc errlogSevEnum epicsShareAPI errlogGetSevToLog(void); epicsShareFunc void epicsShareAPI errlogAddListener( errlogListener listener, void *pPrivate); -epicsShareFunc void epicsShareAPI errlogRemoveListener( - errlogListener listener); +epicsShareFunc int epicsShareAPI errlogRemoveListeners( + errlogListener listener, void *pPrivate); epicsShareFunc int epicsShareAPI eltc(int yesno); epicsShareFunc int errlogSetConsole(FILE *stream); diff --git a/src/libCom/test/epicsErrlogTest.c b/src/libCom/test/epicsErrlogTest.c index c595f6d13..ed2ab1788 100644 --- a/src/libCom/test/epicsErrlogTest.c +++ b/src/libCom/test/epicsErrlogTest.c @@ -142,7 +142,7 @@ MAIN(epicsErrlogTest) char msg[256]; clientPvt pvt, pvt2; - testPlan(29); + testPlan(32); strcpy(msg, truncmsg); @@ -186,8 +186,9 @@ MAIN(epicsErrlogTest) testOk1(pvt.count == 2); testOk1(pvt2.count == 1); - /* Removes the first listener, but the second remains */ - errlogRemoveListener(&logClient); + /* Removes the first listener */ + testOk(1 == errlogRemoveListeners(&logClient, &pvt), + "Removed 1 listener"); pvt2.expect = "Testing3"; pvt2.checkLen = strlen(pvt2.expect); @@ -198,8 +199,10 @@ MAIN(epicsErrlogTest) testOk1(pvt.count == 2); testOk1(pvt2.count == 2); - /* Remove the second listener */ - errlogRemoveListener(&logClient); + /* Add the second listener again, then remove both instances */ + errlogAddListener(&logClient, &pvt2); + testOk(2 == errlogRemoveListeners(&logClient, &pvt2), + "Removed 2 listeners"); errlogPrintfNoConsole("Something different"); errlogFlush(); @@ -314,7 +317,8 @@ MAIN(epicsErrlogTest) testOk1(pvt.count == N+1); /* Clean up */ - errlogRemoveListener(&logClient); + testOk(1 == errlogRemoveListeners(&logClient, &pvt), + "Removed 1 listener"); testLogPrefix();