On 18.11.2011 21:30, Andreas Piesk wrote:
>
> Rainer, have you found some time to look at the issue?
>
> what about the idea to use one mutex for both operations? i mean, wouldn't
> replacing the mutexes
> mutLoadUnload and mutObjGlobalOp with a single mutex, type
> PTHREAD_MUTEX_RECURSIVE, solve the problem?
>
i fixed the problem with the attached patch against 5.8.6.
it may not be an optimal solution but at least rsyslog doesn't hang anymore at
bootup.
regards,
-ap
diff -Purp rsyslog-5.8.6/runtime/modules.c rsyslog-5.8.6.mod/runtime/modules.c
--- rsyslog-5.8.6/runtime/modules.c 2011-10-21 11:53:02.000000000 +0200
+++ rsyslog-5.8.6.mod/runtime/modules.c 2011-11-25 19:14:34.491976989 +0100
@@ -74,6 +74,9 @@ DEFobjCurrIf(strgen)
*/
static pthread_mutex_t mutLoadUnload;
+/* mutObjGlobalOp defined in obj.c */
+extern pthread_mutex_t mutObjGlobalOp;
+
static modInfo_t *pLoadedModules = NULL; /* list of currently-loaded
modules */
static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */
@@ -667,6 +670,9 @@ modUnlinkAndDestroy(modInfo_t **ppThis)
pThis = *ppThis;
assert(pThis != NULL);
+ /* acquire mutObjGlobalOp before &mutLoadUnload to prevent deadlocks */
+ pthread_mutex_lock(&mutObjGlobalOp);
+
pthread_mutex_lock(&mutLoadUnload);
/* first check if we are permitted to unload */
@@ -704,6 +710,10 @@ modUnlinkAndDestroy(modInfo_t **ppThis)
finalize_it:
pthread_mutex_unlock(&mutLoadUnload);
+
+ /* release obj lock */
+ pthread_mutex_unlock(&mutObjGlobalOp);
+
RETiRet;
}
@@ -779,6 +789,9 @@ Load(uchar *pModName)
assert(pModName != NULL);
dbgprintf("Requested to load module '%s'\n", pModName);
+ /* acquire mutObjGlobalOp before &mutLoadUnload to prevent deadlocks */
+ pthread_mutex_lock(&mutObjGlobalOp);
+
pthread_mutex_lock(&mutLoadUnload);
iModNameLen = strlen((char *) pModName);
@@ -904,6 +917,10 @@ Load(uchar *pModName)
finalize_it:
pthread_mutex_unlock(&mutLoadUnload);
+
+ /* release obj lock */
+ pthread_mutex_unlock(&mutObjGlobalOp);
+
RETiRet;
}
diff -Purp rsyslog-5.8.6/runtime/obj.c rsyslog-5.8.6.mod/runtime/obj.c
--- rsyslog-5.8.6/runtime/obj.c 2011-10-21 11:53:02.000000000 +0200
+++ rsyslog-5.8.6.mod/runtime/obj.c 2011-11-24 22:26:12.284684402 +0100
@@ -99,7 +99,7 @@ DEFobjCurrIf(module)
DEFobjCurrIf(errmsg)
DEFobjCurrIf(strm)
static objInfo_t *arrObjInfo[OBJ_NUM_IDS]; /* array with object information
pointers */
-static pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of
the object system */
+pthread_mutex_t mutObjGlobalOp; /* mutex to guard global operations of
the object system */
/* cookies for serialized lines */
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/