summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf.c1
-rw-r--r--dirty.h40
-rw-r--r--runtime/glbl.h (renamed from glbl.h)0
-rw-r--r--runtime/msg.c11
-rw-r--r--runtime/net.c4
-rw-r--r--runtime/srUtils.h1
-rw-r--r--runtime/srutils.c46
-rw-r--r--tools/omfile.c2
-rw-r--r--tools/syslogd.c53
9 files changed, 67 insertions, 91 deletions
diff --git a/conf.c b/conf.c
index 721ea4a7..dad9ebf2 100644
--- a/conf.c
+++ b/conf.c
@@ -505,7 +505,6 @@ rsRetVal cflineParseTemplateName(uchar** pp, omodStringRequest_t *pOMSR, int iEn
} else {
/* template specified, pick it up */
if(rsCStrConstruct(&pStrB) != RS_RET_OK) {
- glblHadMemShortage = 1;
iRet = RS_RET_OUT_OF_MEMORY;
goto finalize_it;
}
diff --git a/dirty.h b/dirty.h
index 5783daf8..f0664639 100644
--- a/dirty.h
+++ b/dirty.h
@@ -29,33 +29,14 @@
#define MAXLINE 2048 /* maximum line length */
-#define MSG_PARSE_HOSTNAME 1
-#define MSG_DONT_PARSE_HOSTNAME 0
-
/* Flags to logmsg().
*/
#define NOFLAG 0x000 /* no flag is set (to be used when a flag must be specified and none is required) */
#define INTERNAL_MSG 0x001 /* msg generated by logmsgInternal() --> special handling */
-#define SYNC_FILE 0x002 /* do fsync on file after printing */
+/* NO LONGER USED: #define SYNC_FILE 0x002 / * do fsync on file after printing */
#define ADDDATE 0x004 /* add a date to the message */
#define MARK 0x008 /* this message is a mark */
-#ifdef USE_NETZIP
-/* config param: minimum message size to try compression. The smaller
- * the message, the less likely is any compression gain. We check for
- * gain before we submit the message. But to do so we still need to
- * do the (costly) compress() call. The following setting sets a size
- * for which no call to compress() is done at all. This may result in
- * a few more bytes being transmited but better overall performance.
- * Note: I have not yet checked the minimum UDP packet size. It might be
- * that we do not save anything by compressing very small messages, because
- * UDP might need to pad ;)
- * rgerhards, 2006-11-30
- */
-#define MIN_SIZE_FOR_COMPRESS 60
-#endif
-
-extern int glblHadMemShortage; /* indicates if we had memory shortage some time during the run */
extern int DisableDNS;
extern char **StripDomains;
extern char *LocalDomain;
@@ -65,8 +46,10 @@ extern int family;
extern int bDropMalPTRMsgs;
extern int option_DisallowWarning;
+#define MSG_PARSE_HOSTNAME 1
+#define MSG_DONT_PARSE_HOSTNAME 0
+
rsRetVal submitMsg(msg_t *pMsg);
-int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep);
rsRetVal logmsgInternal(int pri, char *msg, int flags);
rsRetVal parseAndSubmitMessage(char *hname, char *msg, int len, int bParseHost, int flags, flowControl_t flowCtlType);
@@ -89,4 +72,19 @@ extern int bReduceRepeatMsgs;
#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \
(f)->f_repeatcount = MAXREPEAT; \
}
+#ifdef USE_NETZIP
+/* config param: minimum message size to try compression. The smaller
+ * the message, the less likely is any compression gain. We check for
+ * gain before we submit the message. But to do so we still need to
+ * do the (costly) compress() call. The following setting sets a size
+ * for which no call to compress() is done at all. This may result in
+ * a few more bytes being transmited but better overall performance.
+ * Note: I have not yet checked the minimum UDP packet size. It might be
+ * that we do not save anything by compressing very small messages, because
+ * UDP might need to pad ;)
+ * rgerhards, 2006-11-30
+ */
+#define MIN_SIZE_FOR_COMPRESS 60
+#endif
+
#endif /* #ifndef DIRTY_H_INCLUDED */
diff --git a/glbl.h b/runtime/glbl.h
index 5385006a..5385006a 100644
--- a/glbl.h
+++ b/runtime/glbl.h
diff --git a/runtime/msg.c b/runtime/msg.c
index e5ed19c6..96bd8cc5 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -685,7 +685,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszTIMESTAMP3164 == NULL) {
if((pM->pszTIMESTAMP3164 = malloc(16)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -697,7 +696,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszTIMESTAMP_MySQL == NULL) {
if((pM->pszTIMESTAMP_MySQL = malloc(15)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -709,7 +707,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszTIMESTAMP_PgSQL == NULL) {
if((pM->pszTIMESTAMP_PgSQL = malloc(21)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -721,7 +718,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszTIMESTAMP3164 == NULL) {
if((pM->pszTIMESTAMP3164 = malloc(16)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -733,7 +729,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszTIMESTAMP3339 == NULL) {
if((pM->pszTIMESTAMP3339 = malloc(33)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return ""; /* TODO: check this: can it cause a free() of constant memory?) */
}
@@ -755,7 +750,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszRcvdAt3164 == NULL) {
if((pM->pszRcvdAt3164 = malloc(16)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -767,7 +761,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszRcvdAt_MySQL == NULL) {
if((pM->pszRcvdAt_MySQL = malloc(15)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -779,7 +772,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszRcvdAt_PgSQL == NULL) {
if((pM->pszRcvdAt_PgSQL = malloc(21)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -791,7 +783,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszRcvdAt3164 == NULL) {
if((pM->pszRcvdAt3164 = malloc(16)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -803,7 +794,6 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
MsgLock(pM);
if(pM->pszRcvdAt3339 == NULL) {
if((pM->pszRcvdAt3339 = malloc(33)) == NULL) {
- glblHadMemShortage = 1;
MsgUnlock(pM);
return "";
}
@@ -1499,7 +1489,6 @@ static uchar *getNOW(eNOWType eNow)
struct syslogTime t;
if((pBuf = (uchar*) malloc(sizeof(uchar) * tmpBUFSIZE)) == NULL) {
- glblHadMemShortage = 1;
return NULL;
}
diff --git a/runtime/net.c b/runtime/net.c
index 70e7d6f6..cf033383 100644
--- a/runtime/net.c
+++ b/runtime/net.c
@@ -131,7 +131,6 @@ static rsRetVal AddAllowedSenderEntry(struct AllowedSenders **ppRoot, struct All
assert(iAllow != NULL);
if((pEntry = (struct AllowedSenders*) calloc(1, sizeof(struct AllowedSenders))) == NULL) {
- glblHadMemShortage = 1;
return RS_RET_OUT_OF_MEMORY; /* no options left :( */
}
@@ -275,7 +274,6 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS
iSignificantBits = 32;
allowIP.flags = 0;
if((allowIP.addr.NetAddr = malloc(res->ai_addrlen)) == NULL) {
- glblHadMemShortage = 1;
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
memcpy(allowIP.addr.NetAddr, res->ai_addr, res->ai_addrlen);
@@ -292,7 +290,6 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS
allowIP.flags = 0;
if((allowIP.addr.NetAddr = malloc(sizeof(struct sockaddr_in)))
== NULL) {
- glblHadMemShortage = 1;
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
SIN(allowIP.addr.NetAddr)->sin_family = AF_INET;
@@ -314,7 +311,6 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS
iSignificantBits = 128;
allowIP.flags = 0;
if((allowIP.addr.NetAddr = malloc(res->ai_addrlen)) == NULL) {
- glblHadMemShortage = 1;
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
memcpy(allowIP.addr.NetAddr, res->ai_addr, res->ai_addrlen);
diff --git a/runtime/srUtils.h b/runtime/srUtils.h
index 81d20357..bfce4cbb 100644
--- a/runtime/srUtils.h
+++ b/runtime/srUtils.h
@@ -91,6 +91,7 @@ void mutexCancelCleanup(void *arg);
void srSleep(int iSeconds, int iuSeconds);
char *rs_strerror_r(int errnum, char *buf, size_t buflen);
int decodeSyslogName(uchar *name, syslogName_t *codetab);
+int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep);
/* mutex operations */
/* some macros to cancel-safe lock a mutex (it will automatically be released
diff --git a/runtime/srutils.c b/runtime/srutils.c
index f1208c26..cf36493a 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -505,5 +505,51 @@ int decodeSyslogName(uchar *name, syslogName_t *codetab)
}
+/**
+ * getSubString
+ *
+ * Copy a string byte by byte until the occurrence
+ * of a given separator.
+ *
+ * \param ppSrc Pointer to a pointer of the source array of characters. If a
+ separator detected the Pointer points to the next char after the
+ separator. Except if the end of the string is dedected ('\n').
+ Then it points to the terminator char.
+ * \param pDst Pointer to the destination array of characters. Here the substing
+ will be stored.
+ * \param DstSize Maximum numbers of characters to store.
+ * \param cSep Separator char.
+ * \ret int Returns 0 if no error occured.
+ *
+ * rgerhards, 2008-02-12: some notes are due... I will once again fix this function, this time
+ * so that it treats ' ' as a request for whitespace. But in general, the function and its callers
+ * should be changed over time, this is not really very good code...
+ */
+int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep)
+{
+ uchar *pSrc = *ppSrc;
+ int iErr = 0; /* 0 = no error, >0 = error */
+ while((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0' && DstSize>1) {
+ *pDst++ = *(pSrc)++;
+ DstSize--;
+ }
+ /* check if the Dst buffer was to small */
+ if ((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0') {
+ dbgprintf("in getSubString, error Src buffer > Dst buffer\n");
+ iErr = 1;
+ }
+ if (*pSrc == '\0' || *pSrc == '\n')
+ /* this line was missing, causing ppSrc to be invalid when it
+ * was returned in case of end-of-string. rgerhards 2005-07-29
+ */
+ *ppSrc = pSrc;
+ else
+ *ppSrc = pSrc+1;
+ *pDst = '\0';
+ return iErr;
+}
+
+
+
/* vim:set ai:
*/
diff --git a/tools/omfile.c b/tools/omfile.c
index 6bdd17eb..4b5eb280 100644
--- a/tools/omfile.c
+++ b/tools/omfile.c
@@ -281,7 +281,6 @@ int resolveFileSizeLimit(instanceData *pData)
*/
if((pCmd = (uchar*)strdup((char*)pData->f_sizeLimitCmd)) == NULL) {
/* there is not much we can do - we make syslogd close the file in this case */
- glblHadMemShortage = 1;
return 1;
}
@@ -481,7 +480,6 @@ static int prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsg
/* we need to allocate memory for the cache structure */
pCache[iFirstFree] = (dynaFileCacheEntry*) calloc(1, sizeof(dynaFileCacheEntry));
if(pCache[iFirstFree] == NULL) {
- glblHadMemShortage = TRUE;
dbgprintf("prepareDynfile(): could not alloc mem, discarding this request\n");
return -1;
}
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 95a23e99..a356c338 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -248,9 +248,6 @@ static pid_t myPid; /* our pid for use in self-generated messages, e.g. on start
/* mypid is read-only after the initial fork() */
static int restart = 0; /* do restart (config read) - multithread safe */
-int glblHadMemShortage = 0; /* indicates if we had memory shortage some time during the run */
-
-
static int bParseHOSTNAMEandTAG = 1; /* global config var: should the hostname and tag be
* parsed inside message - rgerhards, 2006-03-13 */
static int bFinished = 0; /* used by termination signal handler, read-only except there
@@ -488,7 +485,6 @@ selectorConstruct(selector_t **ppThis)
assert(ppThis != NULL);
if((pThis = (selector_t*) calloc(1, sizeof(selector_t))) == NULL) {
- glblHadMemShortage = 1;
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
CHKiRet(llInit(&pThis->llActList, actionDestruct, NULL, NULL));
@@ -669,7 +665,7 @@ rsRetVal printline(char *hname, char *msg, int bParseHost, int flags, flowContro
if(MsgSetUxTradMsg(pMsg, p) != 0)
ABORT_FINALIZE(RS_RET_ERR);
- logmsg(pMsg, flags | SYNC_FILE);
+ logmsg(pMsg, flags);
finalize_it:
RETiRet;
@@ -1926,8 +1922,6 @@ die(int sig)
tplDeleteAll();
remove_pid(PidFile);
- if(glblHadMemShortage)
- dbgprintf("Had memory shortage at least once during the run.\n");
/* de-init some modules */
modExitIminternal();
@@ -2466,51 +2460,6 @@ void sighup_handler()
}
-/**
- * getSubString
- *
- * Copy a string byte by byte until the occurrence
- * of a given separator.
- *
- * \param ppSrc Pointer to a pointer of the source array of characters. If a
- separator detected the Pointer points to the next char after the
- separator. Except if the end of the string is dedected ('\n').
- Then it points to the terminator char.
- * \param pDst Pointer to the destination array of characters. Here the substing
- will be stored.
- * \param DstSize Maximum numbers of characters to store.
- * \param cSep Separator char.
- * \ret int Returns 0 if no error occured.
- *
- * rgerhards, 2008-02-12: some notes are due... I will once again fix this function, this time
- * so that it treats ' ' as a request for whitespace. But in general, the function and its callers
- * should be changed over time, this is not really very good code...
- */
-int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep)
-{
- uchar *pSrc = *ppSrc;
- int iErr = 0; /* 0 = no error, >0 = error */
- while((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0' && DstSize>1) {
- *pDst++ = *(pSrc)++;
- DstSize--;
- }
- /* check if the Dst buffer was to small */
- if ((cSep == ' ' ? !isspace(*pSrc) : *pSrc != cSep) && *pSrc != '\n' && *pSrc != '\0') {
- dbgprintf("in getSubString, error Src buffer > Dst buffer\n");
- iErr = 1;
- }
- if (*pSrc == '\0' || *pSrc == '\n')
- /* this line was missing, causing ppSrc to be invalid when it
- * was returned in case of end-of-string. rgerhards 2005-07-29
- */
- *ppSrc = pSrc;
- else
- *ppSrc = pSrc+1;
- *pDst = '\0';
- return iErr;
-}
-
-
/* this function pulls all internal messages from the buffer
* and puts them into the processing engine.
* We can only do limited error handling, as this would not