summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-10-01 13:59:48 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2010-10-01 13:59:48 +0000
commit255895a58b3f2a54fecf971da700caf265b4e1f0 (patch)
tree6f8f7a3d6249d667c51c83b8dbe582fb1ba71010 /plugins
parent9696cdef34f5d033564138fb9d4afb87daa6b1be (diff)
downloadrsyslog-255895a58b3f2a54fecf971da700caf265b4e1f0.tar.gz
rsyslog-255895a58b3f2a54fecf971da700caf265b4e1f0.tar.xz
rsyslog-255895a58b3f2a54fecf971da700caf265b4e1f0.zip
omhdfs: more improvements
finally this looks almost production ready for files where no directory path needs to be created
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imuxsock/imuxsock.c4
-rw-r--r--plugins/omhdfs/Makefile.am3
-rw-r--r--plugins/omhdfs/omhdfs.c47
3 files changed, 36 insertions, 18 deletions
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 24bcebb7..ad2d61c8 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -278,7 +278,7 @@ addLstnSocketName(void __attribute__((unused)) *pVal, uchar *pNewVal)
}
CHKiRet(prop.ConstructFinalize(listeners[nfd].hostName));
if(ratelimitInterval > 0) {
- if((listeners[nfd].ht = create_hashtable(1000, hash_from_key_fn, key_equals_fn)) == NULL) {
+ if((listeners[nfd].ht = create_hashtable(1000, hash_from_key_fn, key_equals_fn, NULL)) == NULL) {
/* in this case, we simply turn of rate-limiting */
dbgprintf("imuxsock: turning off rate limiting because we could not "
"create hash table\n");
@@ -755,7 +755,7 @@ CODESTARTwillRun
if(pLogSockName != NULL)
listeners[0].sockName = pLogSockName;
if(ratelimitIntervalSysSock > 0) {
- if((listeners[0].ht = create_hashtable(1000, hash_from_key_fn, key_equals_fn)) == NULL) {
+ if((listeners[0].ht = create_hashtable(1000, hash_from_key_fn, key_equals_fn, NULL)) == NULL) {
/* in this case, we simply turn of rate-limiting */
dbgprintf("imuxsock: turning off rate limiting because we could not "
"create hash table\n");
diff --git a/plugins/omhdfs/Makefile.am b/plugins/omhdfs/Makefile.am
index 2e7ef8ea..95e6b102 100644
--- a/plugins/omhdfs/Makefile.am
+++ b/plugins/omhdfs/Makefile.am
@@ -1,7 +1,6 @@
pkglib_LTLIBRARIES = omhdfs.la
omhdfs_la_SOURCES = omhdfs.c
-#omhdfs_la_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS) -I/usr/lib/jvm/java-6-sun/include -I/usr/lib/jvm/java-6-sun/include/linux
omhdfs_la_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS) $(JAVA_INCLUDES)
omhdfs_la_LDFLAGS = -module -avoid-version -lhdfs $(JAVA_LIBS)
-omhdfs_la_LIBADD =
+omhdfs_la_LIBADD = $(RSRT_LIBS)
diff --git a/plugins/omhdfs/omhdfs.c b/plugins/omhdfs/omhdfs.c
index eaca90e4..734c28cd 100644
--- a/plugins/omhdfs/omhdfs.c
+++ b/plugins/omhdfs/omhdfs.c
@@ -61,6 +61,7 @@ static struct hashtable *files; /* holds all file objects that we know */
/* globals for default values */
static uchar *fileName = NULL;
static uchar *hdfsHost = NULL;
+static uchar *dfltTplName = NULL; /* default template name to use */
int hdfsPort = 0;
/* end globals for default values */
@@ -176,10 +177,10 @@ fileObjAddUser(file_t *pFile)
++pFile->nUsers;
if(pFile->nUsers == 2)
pthread_mutex_init(&pFile->mut, NULL);
- dbgprintf("omhdfs: file %s now being used by %d actions\n", pFile->name, pFile->nUsers);
+ DBGPRINTF("omhdfs: file %s now being used by %d actions\n", pFile->name, pFile->nUsers);
}
-static inline rsRetVal
+static rsRetVal
fileObjDestruct(file_t **ppFile)
{
file_t *pFile = *ppFile;
@@ -193,6 +194,18 @@ fileObjDestruct(file_t **ppFile)
return RS_RET_OK;
}
+/* this function is to be used as destructor for the
+ * hash table code.
+ */
+static void
+fileObjDestruct4Hashtable(void *ptr)
+{
+ dbgprintf("omfile: fileObjDestruct4Hashtable called\n");
+ file_t *pFile = (file_t*) ptr;
+ fileObjDestruct(&pFile);
+}
+
+
static inline rsRetVal
fileOpen(file_t *pFile)
{
@@ -261,6 +274,8 @@ finalize_it:
static inline rsRetVal
fileClose(file_t *pFile)
{
+ DEFiRet;
+
if(pFile->nUsers > 1)
d_pthread_mutex_lock(&pFile->mut);
if(pFile->fh != NULL) {
@@ -271,7 +286,7 @@ fileClose(file_t *pFile)
if(pFile->nUsers > 1)
d_pthread_mutex_unlock(&pFile->mut);
- return RS_RET_OK;
+ RETiRet;
}
/* ---END FILE OBJECT---------------------------------------------------- */
@@ -285,7 +300,8 @@ ENDcreateInstance
BEGINfreeInstance
CODESTARTfreeInstance
- fileObjDestruct(&pData->pFile);
+ if(pData->pFile != NULL)
+ fileObjDestruct(&pData->pFile);
ENDfreeInstance
@@ -315,8 +331,8 @@ CODESTARTparseSelectorAct
p += sizeof(":omhdfs:") - 1; /* eat indicator sequence (-1 because of '\0'!) */
CHKiRet(createInstance(&pData));
CODE_STD_STRING_REQUESTparseSelectorAct(1)
- CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, 0, (uchar*) "RSYSLOG_FileFormat"));
- //(pszFileDfltTplName == NULL) ? (uchar*)"RSYSLOG_FileFormat" : pszFileDfltTplName));
+ CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, 0,
+ (dfltTplName == NULL) ? (uchar*)"RSYSLOG_FileFormat" : dfltTplName));
if(fileName == NULL) {
errmsg.LogError(0, RS_RET_ERR_HDFS_OPEN, "omhdfs: no file name specified, can not continue");
@@ -327,17 +343,18 @@ CODESTARTparseSelectorAct
if(pFile == NULL) {
/* we need a new file object, this one not seen before */
CHKiRet(fileObjConstruct(&pFile));
- CHKmalloc(pFile->name = (uchar*)strdup((char*)fileName));
+ CHKmalloc(pFile->name = fileName);
CHKmalloc(keybuf = ustrdup(fileName));
+ fileName = NULL; /* re-set, data passed to file object */
+ CHKmalloc(pFile->hdfsHost = strdup((hdfsHost == NULL) ? "default" : (char*) hdfsHost));
+ pFile->hdfsPort = hdfsPort;
+ fileOpen(pFile);
r = hashtable_insert(files, keybuf, pFile);
if(r == 0)
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
fileObjAddUser(pFile);
- CHKmalloc(pFile->hdfsHost = strdup((hdfsHost == NULL) ? "default" : (char*) hdfsHost));
- pFile->hdfsPort = hdfsPort;
- fileOpen(pFile);
if(pFile->fh == NULL){
errmsg.LogError(0, RS_RET_ERR_HDFS_OPEN, "omhdfs: failed to open %s - retrying later", pFile->name);
iRet = RS_RET_SUSPENDED;
@@ -390,11 +407,13 @@ CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION;
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
- CHKmalloc(files = create_hashtable(20, hash_from_string, key_equals_string));
+ CHKmalloc(files = create_hashtable(20, hash_from_string, key_equals_string,
+ fileObjDestruct4Hashtable));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"omhdfsfilename", 0, eCmdHdlrGetWord, NULL, &fileName, NULL));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"omhdfshost", 0, eCmdHdlrGetWord, NULL, &hdfsHost, NULL));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"omhdfsport", 0, eCmdHdlrInt, NULL, &hdfsPort, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"omhdfsfilename", 0, eCmdHdlrGetWord, NULL, &fileName, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"omhdfshost", 0, eCmdHdlrGetWord, NULL, &hdfsHost, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"omhdfsport", 0, eCmdHdlrInt, NULL, &hdfsPort, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"omhdfsdefaulttemplate", 0, eCmdHdlrGetWord, NULL, &dfltTplName, NULL));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
CODEmodInit_QueryRegCFSLineHdlr
ENDmodInit