summaryrefslogtreecommitdiffstats
path: root/plugins/omelasticsearch
diff options
context:
space:
mode:
authorAndre Lorbach <alorbach@adiscon.com>2013-07-24 11:10:01 +0200
committerAndre Lorbach <alorbach@adiscon.com>2013-07-24 11:10:01 +0200
commit372c7264a598e72f6b9e8f734c9ea6a4a9427c8b (patch)
treea4446d4c85ce006fa36e0d136ed4487600410ec7 /plugins/omelasticsearch
parent030e8360702c2c5e227fa70b257f8b3fd048333b (diff)
downloadrsyslog-372c7264a598e72f6b9e8f734c9ea6a4a9427c8b.tar.gz
rsyslog-372c7264a598e72f6b9e8f734c9ea6a4a9427c8b.tar.bz2
rsyslog-372c7264a598e72f6b9e8f734c9ea6a4a9427c8b.zip
Fixed another issue related to http://bugzilla.adiscon.com/show_bug.cgi?id=464
Added check for empty batch data in endTransaction function. Avoids sending an unneeded curlPost, can happen when elasticsearch is shutdown while sending data to.
Diffstat (limited to 'plugins/omelasticsearch')
-rw-r--r--plugins/omelasticsearch/omelasticsearch.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/omelasticsearch/omelasticsearch.c b/plugins/omelasticsearch/omelasticsearch.c
index b98a7828..aea8e321 100644
--- a/plugins/omelasticsearch/omelasticsearch.c
+++ b/plugins/omelasticsearch/omelasticsearch.c
@@ -651,12 +651,17 @@ ENDdoAction
BEGINendTransaction
- char *cstr;
+ char *cstr = NULL;
CODESTARTendTransaction
dbgprintf("omelasticsearch: endTransaction init\n");
- cstr = es_str2cstr(pData->batch.data, NULL);
- dbgprintf("omelasticsearch: endTransaction, batch: '%s'\n", cstr);
- CHKiRet(curlPost(pData, (uchar*) cstr, strlen(cstr), NULL));
+ /* End Transaction only if batch data is not empty */
+ if (pData->batch.data != NULL ) {
+ cstr = es_str2cstr(pData->batch.data, NULL);
+ dbgprintf("omelasticsearch: endTransaction, batch: '%s'\n", cstr);
+ CHKiRet(curlPost(pData, (uchar*) cstr, strlen(cstr), NULL));
+ }
+ else
+ dbgprintf("omelasticsearch: endTransaction, pData->batch.data is NULL, nothing to send. \n");
finalize_it:
free(cstr);
dbgprintf("omelasticsearch: endTransaction done with %d\n", iRet);