diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-11 17:57:17 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-11 17:57:17 +0200 |
commit | da5caafa90336d4b193a4174e06c19939502b0d0 (patch) | |
tree | 3d6c85337775e472bb4635ff3c9a8bf3206437ed | |
parent | e988e9ff58cdb80a5b9875eaca56a745019230a1 (diff) | |
download | rsyslog-da5caafa90336d4b193a4174e06c19939502b0d0.tar.gz rsyslog-da5caafa90336d4b193a4174e06c19939502b0d0.tar.bz2 rsyslog-da5caafa90336d4b193a4174e06c19939502b0d0.zip |
imudp: reduce resource usage
we utilize the imudp main thread to act as a worker itself
-rw-r--r-- | plugins/imudp/imudp.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index 310221b2..95f9a9a5 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -1120,7 +1120,9 @@ wrkr(void *myself) } /* This function is called to gather input. - * In essence, it just starts the pool of workers. + * In essence, it just starts the pool of workers. To save resources, + * we run one of the workers on our own thread -- otherwise that thread would + * just idle around and wait for the workers to finish. */ BEGINrunInput int i; @@ -1128,13 +1130,18 @@ BEGINrunInput CODESTARTrunInput pthread_attr_init(&wrkrThrdAttr); pthread_attr_setstacksize(&wrkrThrdAttr, 4096*1024); - for(i = 0 ; i < runModConf->wrkrMax ; ++i) { + for(i = 0 ; i < runModConf->wrkrMax - 1 ; ++i) { wrkrInfo[i].pThrd = pThrd; wrkrInfo[i].id = i; pthread_create(&wrkrInfo[i].tid, &wrkrThrdAttr, wrkr, &(wrkrInfo[i])); } pthread_attr_destroy(&wrkrThrdAttr); - for(i = 0 ; i < runModConf->wrkrMax ; ++i) { + + wrkrInfo[i].pThrd = pThrd; + wrkrInfo[i].id = i; + wrkr(&wrkrInfo[i]); + + for(i = 0 ; i < runModConf->wrkrMax - 1 ; ++i) { pthread_join(wrkrInfo[i].tid, NULL); } ENDrunInput |