summaryrefslogtreecommitdiffstats
path: root/plugins/imttcp
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-01-24 15:26:59 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-01-24 15:26:59 +0100
commit5ebe39b5d993a9ad2a1b21bcb723c313fb1ba8f6 (patch)
treebd74b4e6cf3fdea4f23ff5385487359437117d28 /plugins/imttcp
parenta1cb41145208ab6855a123c615d2e4ecef787fbe (diff)
downloadrsyslog-5ebe39b5d993a9ad2a1b21bcb723c313fb1ba8f6.tar.gz
rsyslog-5ebe39b5d993a9ad2a1b21bcb723c313fb1ba8f6.tar.xz
rsyslog-5ebe39b5d993a9ad2a1b21bcb723c313fb1ba8f6.zip
thread leak fixed (but not in a clean way)
Diffstat (limited to 'plugins/imttcp')
-rw-r--r--plugins/imttcp/imttcp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/imttcp/imttcp.c b/plugins/imttcp/imttcp.c
index e2faca71..6bba2288 100644
--- a/plugins/imttcp/imttcp.c
+++ b/plugins/imttcp/imttcp.c
@@ -169,6 +169,7 @@ struct epolld_s {
/* global data */
static ttcpsrv_t *pSrvRoot = NULL;
static int iMaxLine; /* maximum size of a single message */
+pthread_attr_t sessThrdAttr; /* Attribute for session threads; read only after startup */
/* forward definitions */
static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal);
@@ -707,7 +708,7 @@ addSess(ttcpsrv_t *pSrv, int sock, prop_t *peerName, prop_t *peerIP)
pthread_mutex_unlock(&pSrv->mutSess);
/* finally run session handler */
- pthread_create(&pSess->tid, NULL, sessThrd, (void*) pSess);
+ pthread_create(&pSess->tid, &sessThrdAttr, sessThrd, (void*) pSess);
finalize_it:
RETiRet;
@@ -995,7 +996,7 @@ shutdownSrv(ttcpsrv_t *pSrv)
pSess = pSess->next;
pthread_kill(tid, SIGTTIN);
DBGPRINTF("imttcp: termination request for session thread %x\n", (unsigned) tid);
- pthread_join(tid, NULL);
+ //pthread_join(tid, NULL);
DBGPRINTF("imttcp: session thread %x terminated \n", (unsigned) tid);
}
}
@@ -1018,6 +1019,8 @@ ENDafterRun
BEGINmodExit
CODESTARTmodExit
+ pthread_attr_destroy(&sessThrdAttr);
+
/* release objects we used */
objRelease(glbl, CORE_COMPONENT);
objRelease(prop, CORE_COMPONENT);
@@ -1061,6 +1064,11 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(datetime, CORE_COMPONENT));
CHKiRet(objUse(ruleset, CORE_COMPONENT));
+ /* initialize "read-only" thread attributes */
+ pthread_attr_init(&sessThrdAttr);
+ pthread_attr_setdetachstate(&sessThrdAttr, PTHREAD_CREATE_DETACHED);
+ pthread_attr_setstacksize(&sessThrdAttr, 200*1024);
+
/* register config file handlers */
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputttcpserverrun"), 0, eCmdHdlrGetWord,
addTCPListener, NULL, STD_LOADABLE_MODULE_ID, eConfObjGlobal));