diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-11-21 16:34:48 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-11-21 16:34:48 +0000 |
commit | 3bb7ad8246bca95c89d68a8b0402b8482489c877 (patch) | |
tree | 798656b4722649346cbd43a0a328041832666237 /cfsysline.c | |
parent | bb6bfca3dfa6a5d3500e51459b38bb6d0ca6a4b2 (diff) | |
download | rsyslog-3bb7ad8246bca95c89d68a8b0402b8482489c877.tar.gz rsyslog-3bb7ad8246bca95c89d68a8b0402b8482489c877.tar.xz rsyslog-3bb7ad8246bca95c89d68a8b0402b8482489c877.zip |
- added an identifier to command handler table - need to identify which
command handler entries need to be removed when module is unloaded
- added support so that linkedlist key can be used for owner handle
- enhanced llExecFunc to support deletion of list elements (on behalf of
user function being called, slight interface change)
- enhanced linkedlist class so that list elements can now be deleted based
on the key value they have
- created entry point so that CfSysLine handlers are removed on modExit()
Diffstat (limited to 'cfsysline.c')
-rw-r--r-- | cfsysline.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/cfsysline.c b/cfsysline.c index 96a2c396..196dc254 100644 --- a/cfsysline.c +++ b/cfsysline.c @@ -662,6 +662,50 @@ rsRetVal unregCfSysLineHdlrs(void) } +/* helper function for unregCfSysLineHdlrs4Owner(). This is used to see if there is + * a handler of this owner inside the element and, if so, remove it. Please note that + * it keeps track of a pointer to the last linked list entry, as this is needed to + * remove an entry from the list. + * rgerhards, 2007-11-21 + */ +DEFFUNC_llExecFunc(unregHdlrsHeadExec) +{ + DEFiRet; + cslCmd_t *pListHdr = (cslCmd_t*) pData; + int iNumElts; + + /* first find element */ + iRet = llFindAndDelete(&(pListHdr->llCmdHdlrs), pParam); + + /* now go back and check how many elements are left */ + CHKiRet(llGetNumElts(&(pListHdr->llCmdHdlrs), &iNumElts)); + + if(iNumElts == 0) { + /* nothing left in header, so request to delete it */ + iRet = RS_RET_OK_DELETE_LISTENTRY; + } + +finalize_it: + return iRet; +} +/* unregister and destroy cfSysLineHandlers for a specific owner. This method is + * most importantly used before unloading a loadable module providing some handlers. + * The full list of handlers is searched. If the to-be removed handler was the only + * handler for a directive name, the directive header, too, is deleted. + * rgerhards, 2007-11-21 + */ +rsRetVal unregCfSysLineHdlrs4Owner(void *pOwnerCookie) +{ + DEFiRet; + /* we need to walk through all directive names, as the linked list + * class does not provide a way to just search the lower-level handlers. + */ + iRet = llExecFunc(&llCmdList, unregHdlrsHeadExec, pOwnerCookie); + + return iRet; +} + + /* process a cfsysline command (based on handler structure) * param "p" is a pointer to the command line after the command. Should be * updated. @@ -738,7 +782,7 @@ void dbgPrintCfSysLineHandlers(void) printf("\t\ttype : %d\n", pCmdHdlr->eType); printf("\t\tpData: 0x%x\n", (unsigned) pCmdHdlr->pData); printf("\t\tHdlr : 0x%x\n", (unsigned) pCmdHdlr->cslCmdHdlr); - printf("\t\tOwner: 0x%x\n", (unsigned) llCookieCmd->pKey); + printf("\t\tOwner: 0x%x\n", (unsigned) llCookieCmdHdlr->pKey); printf("\n"); } } |