summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-10-04 13:58:41 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2010-10-04 13:58:41 +0200
commite40cb595a2da943483124fae8f215a397add9fca (patch)
tree9958d817c3d648e0d6bb0aafd12485afa9aac49e
parentd5f16404f93d54afddebb9fb683469fc712d2335 (diff)
downloadrsyslog-e40cb595a2da943483124fae8f215a397add9fca.tar.gz
rsyslog-e40cb595a2da943483124fae8f215a397add9fca.tar.xz
rsyslog-e40cb595a2da943483124fae8f215a397add9fca.zip
omhdfs: support for HUP added
-rw-r--r--plugins/omhdfs/omhdfs.c42
-rw-r--r--runtime/Makefile.am6
-rw-r--r--runtime/hashtable.c (renamed from runtime/hashtable/hashtable.c)0
-rw-r--r--runtime/hashtable_itr.c (renamed from runtime/hashtable/hashtable_itr.c)2
-rw-r--r--runtime/hashtable_itr.h (renamed from runtime/hashtable/hashtable_itr.h)4
-rw-r--r--runtime/hashtable_private.h (renamed from runtime/hashtable/hashtable_private.h)0
6 files changed, 41 insertions, 13 deletions
diff --git a/plugins/omhdfs/omhdfs.c b/plugins/omhdfs/omhdfs.c
index 42ed834f..eefea722 100644
--- a/plugins/omhdfs/omhdfs.c
+++ b/plugins/omhdfs/omhdfs.c
@@ -47,6 +47,7 @@
#include "unicode-helper.h"
#include "errmsg.h"
#include "hashtable.h"
+#include "hashtable_itr.h"
MODULE_TYPE_OUTPUT
@@ -200,7 +201,6 @@ fileObjDestruct(file_t **ppFile)
static void
fileObjDestruct4Hashtable(void *ptr)
{
- dbgprintf("omfile: fileObjDestruct4Hashtable called\n");
file_t *pFile = (file_t*) ptr;
fileObjDestruct(&pFile);
}
@@ -214,6 +214,7 @@ fileOpen(file_t *pFile)
assert(pFile->fh == NULL);
if(pFile->nUsers > 1)
d_pthread_mutex_lock(&pFile->mut);
+
DBGPRINTF("omhdfs: try to connect to HDFS at host '%s', port %d\n",
pFile->hdfsHost, pFile->hdfsPort);
pFile->fs = hdfsConnect(pFile->hdfsHost, pFile->hdfsPort);
@@ -256,6 +257,17 @@ fileWrite(file_t *pFile, uchar *buf)
assert(pFile->fh != NULL);
if(pFile->nUsers > 1)
d_pthread_mutex_lock(&pFile->mut);
+
+ /* open file if not open. This must be done *here* and while mutex-protected
+ * because of HUP handling (which is async to normal processing!).
+ */
+ if(pFile->fh == NULL) {
+ fileOpen(pFile);
+ if(pFile->fh == NULL) {
+ ABORT_FINALIZE(RS_RET_SUSPENDED);
+ }
+ }
+
lenWrite = strlen((char*) buf);
tSize num_written_bytes = hdfsWrite(pFile->fs, pFile->fh, buf, lenWrite);
if((unsigned) num_written_bytes != lenWrite) {
@@ -321,15 +333,8 @@ ENDtryResume
BEGINdoAction
CODESTARTdoAction
- DBGPRINTF(" (%s)\n", pData->pFile->name);
- if(pData->pFile->fh == NULL) {
- fileOpen(pData->pFile);
- if(pData->pFile->fh == NULL) {
- ABORT_FINALIZE(RS_RET_SUSPENDED);
- }
- }
+ DBGPRINTF("omuxsock: action to to write to %s\n", pData->pFile->name);
iRet = fileWrite(pData->pFile, ppString[0]);
-finalize_it:
ENDdoAction
@@ -382,6 +387,24 @@ CODE_STD_FINALIZERparseSelectorAct
ENDparseSelectorAct
+BEGINdoHUP
+ file_t *pFile;
+ struct hashtable_itr *itr;
+CODESTARTdoHUP
+ /* Iterator constructor only returns a valid iterator if
+ * the hashtable is not empty */
+ itr = hashtable_iterator(files);
+ if(hashtable_count(files) > 0)
+ {
+ do {
+ pFile = (file_t *) hashtable_iterator_value(itr);
+ fileClose(pFile);
+ DBGPRINTF("imuxsock: HUP, closing file %s\n", pFile->name);
+ } while (hashtable_iterator_advance(itr));
+ }
+ENDdoHUP
+
+
/* Reset config variables for this module to default values.
* rgerhards, 2007-07-17
*/
@@ -415,6 +438,7 @@ ENDmodExit
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
+CODEqueryEtryPt_doHUP
ENDqueryEtryPt
diff --git a/runtime/Makefile.am b/runtime/Makefile.am
index 5a0c4437..93817e75 100644
--- a/runtime/Makefile.am
+++ b/runtime/Makefile.am
@@ -95,9 +95,11 @@ librsyslog_la_SOURCES = \
../parse.c \
../parse.h \
\
- hashtable/hashtable.c \
+ hashtable.c \
hashtable.h \
- hashtable/hashtable_private.h \
+ hashtable_itr.c \
+ hashtable_itr.h \
+ hashtable_private.h \
\
../outchannel.c \
../outchannel.h \
diff --git a/runtime/hashtable/hashtable.c b/runtime/hashtable.c
index 41fc60fe..41fc60fe 100644
--- a/runtime/hashtable/hashtable.c
+++ b/runtime/hashtable.c
diff --git a/runtime/hashtable/hashtable_itr.c b/runtime/hashtable_itr.c
index 5dced841..967287f1 100644
--- a/runtime/hashtable/hashtable_itr.c
+++ b/runtime/hashtable_itr.c
@@ -38,6 +38,7 @@ hashtable_iterator(struct hashtable *h)
/* key - return the key of the (key,value) pair at the current position */
/* value - return the value of the (key,value) pair at the current position */
+#if 0 /* these are now inline functions! */
void *
hashtable_iterator_key(struct hashtable_itr *i)
{ return i->e->k; }
@@ -45,6 +46,7 @@ hashtable_iterator_key(struct hashtable_itr *i)
void *
hashtable_iterator_value(struct hashtable_itr *i)
{ return i->e->v; }
+#endif
/*****************************************************************************/
/* advance - advance the iterator to the next element
diff --git a/runtime/hashtable/hashtable_itr.h b/runtime/hashtable_itr.h
index eea699a7..1c206b6e 100644
--- a/runtime/hashtable/hashtable_itr.h
+++ b/runtime/hashtable_itr.h
@@ -28,7 +28,7 @@ hashtable_iterator(struct hashtable *h);
/* hashtable_iterator_key
* - return the value of the (key,value) pair at the current position */
-extern inline void *
+static inline void *
hashtable_iterator_key(struct hashtable_itr *i)
{
return i->e->k;
@@ -37,7 +37,7 @@ hashtable_iterator_key(struct hashtable_itr *i)
/*****************************************************************************/
/* value - return the value of the (key,value) pair at the current position */
-extern inline void *
+static inline void *
hashtable_iterator_value(struct hashtable_itr *i)
{
return i->e->v;
diff --git a/runtime/hashtable/hashtable_private.h b/runtime/hashtable_private.h
index 10b82da4..10b82da4 100644
--- a/runtime/hashtable/hashtable_private.h
+++ b/runtime/hashtable_private.h