libCom: Replaced errlogRemoveListener()
New version errlogRemoveListeners() is safer.
This commit is contained in:
@@ -15,6 +15,16 @@ EPICS Base 3.15.0.x releases are not intended for use in production systems.</p>
|
||||
<h2 align="center">Changes between 3.15.0.1 and 3.15.0.2</h2>
|
||||
<!-- Insert new items immediately below here ... -->
|
||||
|
||||
<h3>errlogRemoveListener() routine changed</h3>
|
||||
|
||||
<p>Code that calls <tt>errlogRemoveListener(myfunc)</tt> must be modified to use
|
||||
the new, safer routine <tt>errlogRemoveListeners(myfunc, &pvt)</tt> instead.
|
||||
The replacement routine takes a second argument which must be the same private
|
||||
pointer that was passed to <tt>errlogAddListener()</tt> 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.</p>
|
||||
|
||||
<h3>Simplified generation of .dbd files</h3>
|
||||
|
||||
<p>The Perl script <tt>makeIncludeDbd.pl</tt> has been removed and the rules
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user