diff options
-rw-r--r-- | action.c | 10 | ||||
-rw-r--r-- | action.h | 3 | ||||
-rw-r--r-- | runtime/Makefile.am | 2 | ||||
-rw-r--r-- | runtime/sync.c | 55 | ||||
-rw-r--r-- | runtime/sync.h | 48 | ||||
-rw-r--r-- | tools/syslogd.c | 4 |
6 files changed, 8 insertions, 114 deletions
@@ -305,7 +305,7 @@ rsRetVal actionDestruct(action_t *pThis) if(pThis->f_pMsg != NULL) msgDestruct(&pThis->f_pMsg); - SYNC_OBJ_TOOL_EXIT(pThis); + pthread_mutex_destroy(&pThis->mutAction); pthread_mutex_destroy(&pThis->mutActExec); d_free(pThis->pszName); d_free(pThis->ppTpl); @@ -344,8 +344,8 @@ rsRetVal actionConstruct(action_t **ppThis) pThis->bRepMsgHasMsg = 0; pThis->tLastOccur = datetime.GetTime(NULL); /* done once per action on startup only */ pthread_mutex_init(&pThis->mutActExec, NULL); + pthread_mutex_init(&pThis->mutAction, NULL); INIT_ATOMIC_HELPER_MUT(pThis->mutCAS); - SYNC_OBJ_TOOL_INIT(pThis); /* indicate we have a new action */ ++iActionNbr; @@ -1800,10 +1800,10 @@ doSubmitToActionQComplexBatch(action_t *pAction, batch_t *pBatch) { DEFiRet; - LockObj(pAction); - pthread_cleanup_push(mutexCancelCleanup, pAction->Sync_mut); + d_pthread_mutex_lock(&pAction->mutAction); + pthread_cleanup_push(mutexCancelCleanup, &pAction->mutAction); iRet = helperSubmitToActionQComplexBatch(pAction, pBatch); - UnlockObj(pAction); + d_pthread_mutex_unlock(&pAction->mutAction); pthread_cleanup_pop(0); /* remove mutex cleanup handler */ RETiRet; @@ -26,7 +26,6 @@ #define ACTION_H_INCLUDED 1 #include "syslogd-types.h" -#include "sync.h" #include "queue.h" /* external data - this is to be removed when we change the action @@ -85,7 +84,7 @@ struct action_s { * processed - it is also used to detect duplicates. */ qqueue_t *pQueue; /* action queue */ - SYNC_OBJ_TOOL; /* required for mutex support */ + pthread_mutex_t mutAction; /* primary action mutex */ pthread_mutex_t mutActExec; /* mutex to guard actual execution of doAction for single-threaded modules */ uchar *pszName; /* action name (for documentation) */ DEF_ATOMIC_HELPER_MUT(mutCAS); diff --git a/runtime/Makefile.am b/runtime/Makefile.am index ac4f4279..e504b1fd 100644 --- a/runtime/Makefile.am +++ b/runtime/Makefile.am @@ -53,8 +53,6 @@ librsyslog_la_SOURCES = \ apc.h \ statsobj.c \ statsobj.h \ - sync.c \ - sync.h \ stream.c \ stream.h \ var.c \ diff --git a/runtime/sync.c b/runtime/sync.c deleted file mode 100644 index 46b5ce4c..00000000 --- a/runtime/sync.c +++ /dev/null @@ -1,55 +0,0 @@ -/* synrchonization-related stuff. In theory, that should - * help porting to something different from pthreads. - * - * Copyright 2007-2012 Adiscon GmbH. - * - * This file is part of the rsyslog runtime library. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * -or- - * see COPYING.ASL20 in the source distribution - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "config.h" - -#include <stdlib.h> - -#include "rsyslog.h" -#include "sync.h" -#include "debug.h" - - -void -SyncObjInit(pthread_mutex_t **mut) -{ - *mut = (pthread_mutex_t *) MALLOC(sizeof (pthread_mutex_t)); - pthread_mutex_init(*mut, NULL); -} - - -/* This function destroys the mutex and also sets the mutex object - * to NULL. While the later is not strictly necessary, it is a good - * aid when debugging problems. As this function is not exepected to - * be called quite frequently, the additional overhead can well be - * accepted. If this changes over time, setting to NULL may be - * reconsidered. - rgerhards, 2007-11-12 - */ -void -SyncObjExit(pthread_mutex_t **mut) -{ - if(*mut != NULL) { - pthread_mutex_destroy(*mut); - free(*mut); - *mut = NULL; - } -} diff --git a/runtime/sync.h b/runtime/sync.h deleted file mode 100644 index a2c8f122..00000000 --- a/runtime/sync.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Definitions syncrhonization-related stuff. In theory, that should - * help porting to something different from pthreads. - * - * Copyright 2007-2012 Adiscon GmbH. - * - * This file is part of the rsyslog runtime library. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * -or- - * see COPYING.ASL20 in the source distribution - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INCLUDED_SYNC_H -#define INCLUDED_SYNC_H - -#include <pthread.h> - -/* SYNC_OBJ_TOOL definition must be placed in object to be synced! - * SYNC_OBJ_TOOL_INIT must be called upon of object construction and - * SUNC_OBJ_TOOL_EXIT must be called upon object destruction - */ -#define SYNC_OBJ_TOOL pthread_mutex_t *Sync_mut -#define SYNC_OBJ_TOOL_INIT(x) SyncObjInit(&((x)->Sync_mut)) -#define SYNC_OBJ_TOOL_EXIT(x) SyncObjExit(&((x)->Sync_mut)) - -/* If we run in non-debug (release) mode, we use inline code for the mutex - * operations. If we run in debug mode, we use functions, because they - * are better to trace in the stackframe. - */ -#define LockObj(x) d_pthread_mutex_lock((x)->Sync_mut) -#define UnlockObj(x) d_pthread_mutex_unlock((x)->Sync_mut) - -void SyncObjInit(pthread_mutex_t **mut); -void SyncObjExit(pthread_mutex_t **mut); -extern void lockObj(pthread_mutex_t *mut); -extern void unlockObj(pthread_mutex_t *mut); - -#endif /* #ifndef INCLUDED_SYNC_H */ diff --git a/tools/syslogd.c b/tools/syslogd.c index 4cfbd377..2e7a1e23 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -695,7 +695,7 @@ DEFFUNC_llExecFunc(flushRptdMsgsActions) assert(pAction != NULL); BEGINfunc - LockObj(pAction); + d_pthread_mutex_lock(&pAction->mutAction); /* TODO: time() performance: the call below could be moved to * the beginn of the llExec(). This makes it slightly less correct, but * in an acceptable way. -- rgerhards, 2008-09-16 @@ -707,7 +707,7 @@ DEFFUNC_llExecFunc(flushRptdMsgsActions) actionWriteToAction(pAction); BACKOFF(pAction); } - UnlockObj(pAction); + d_pthread_mutex_unlock(&pAction->mutAction); ENDfunc return RS_RET_OK; /* we ignore errors, we can not do anything either way */ |