summaryrefslogtreecommitdiffstats
path: root/plugins/imptcp
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-04-07 15:42:46 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-04-07 15:42:46 +0200
commitd6da57ae0370aeb705f63fd04e575b5ed4684618 (patch)
treed451907714559f5df60eb0cdef6ccbc205c812e4 /plugins/imptcp
parentd8ce489bae3ae072a2ee605cd90fa0530c9f3446 (diff)
parentbd8d972a975ce794dd71c1c8db724991dd4744a0 (diff)
downloadrsyslog-d6da57ae0370aeb705f63fd04e575b5ed4684618.tar.gz
rsyslog-d6da57ae0370aeb705f63fd04e575b5ed4684618.tar.xz
rsyslog-d6da57ae0370aeb705f63fd04e575b5ed4684618.zip
Merge branch 'v5-stable-newstats'
Conflicts: action.c configure.ac doc/imuxsock.html plugins/imklog/imklog.c plugins/imptcp/imptcp.c plugins/imtcp/imtcp.c plugins/imudp/imudp.c plugins/imuxsock/imuxsock.c runtime/glbl.c runtime/glbl.h runtime/net.c runtime/ruleset.c tcpsrv.h tools/syslogd.c
Diffstat (limited to 'plugins/imptcp')
-rw-r--r--plugins/imptcp/imptcp.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/plugins/imptcp/imptcp.c b/plugins/imptcp/imptcp.c
index ec6836c1..e712dc58 100644
--- a/plugins/imptcp/imptcp.c
+++ b/plugins/imptcp/imptcp.c
@@ -97,6 +97,7 @@ typedef struct configSettings_s {
int iKeepAliveProbes;
int iKeepAliveTime;
int bEmitMsgOnClose; /* emit an informational message on close by remote peer */
+ int bSuppOctetFram; /* support octet-counted framing? */
int iAddtlFrameDelim; /* addtl frame delimiter, e.g. for netscreen, default none */
uchar *pszInputName; /* value for inputname property, NULL is OK and handled by core engine */
uchar *lstnIP; /* which IP we should listen on? */
@@ -111,6 +112,7 @@ struct instanceConf_s {
int iKeepAliveProbes;
int iKeepAliveTime;
int bEmitMsgOnClose;
+ int bSuppOctetFram; /* support octet-counted framing? */
int iAddtlFrameDelim;
uchar *pszBindPort; /* port to bind to */
uchar *pszBindAddr; /* IP to bind socket to */
@@ -145,6 +147,7 @@ struct ptcpsrv_s {
ptcpsrv_t *pNext; /* linked list maintenance */
uchar *port; /* Port to listen to */
uchar *lstnIP; /* which IP we should listen on? */
+ sbool bSuppOctetFram;
int iAddtlFrameDelim;
int iKeepAliveIntvl;
int iKeepAliveProbes;
@@ -171,6 +174,7 @@ struct ptcpsess_s {
//--- from tcps_sess.h
int iMsg; /* index of next char to store in msg */
int bAtStrtOfFram; /* are we at the very beginning of a new frame? */
+ sbool bSuppOctetFram; /**< copy from listener, to speed up access */
enum {
eAtStrtFram,
eInOctetCnt,
@@ -191,6 +195,7 @@ struct ptcplstn_s {
ptcpsrv_t *pSrv; /* our server */
ptcplstn_t *prev, *next;
int sock;
+ sbool bSuppOctetFram;
epolld_t *epd;
statsobj_t *stats; /* listener stats */
STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit)
@@ -325,7 +330,9 @@ startupSrv(ptcpsrv_t *pSrv)
continue;
}
#endif
- }
+ } else {
+ isIPv6 = 0;
+ }
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0 ) {
DBGPRINTF("error %d setting tcp socket option\n", errno);
close(sock);
@@ -665,7 +672,7 @@ processDataRcvd(ptcpsess_t *pThis, char c, struct syslogTime *stTime, time_t ttG
DEFiRet;
if(pThis->inputState == eAtStrtFram) {
- if(isdigit((int) c)) {
+ if(pThis->bSuppOctetFram && isdigit((int) c)) {
pThis->inputState = eInOctetCnt;
pThis->iOctetsRemain = 0;
pThis->eFraming = TCP_FRAMING_OCTET_COUNTING;
@@ -805,6 +812,7 @@ initConfigSettings(void)
{
cs.bEmitMsgOnClose = 0;
cs.wrkrMax = 2;
+ cs.bSuppOctetFram = 1;
cs.iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
cs.pszInputName = NULL;
cs.pszBindRuleset = NULL;
@@ -821,7 +829,7 @@ addEPollSock(epolld_type_t typ, void *ptr, int sock, epolld_t **pEpd)
DEFiRet;
epolld_t *epd = NULL;
- CHKmalloc(epd = malloc(sizeof(epolld_t)));
+ CHKmalloc(epd = calloc(sizeof(epolld_t), 1));
epd->typ = typ;
epd->ptr = ptr;
*pEpd = epd;
@@ -883,6 +891,7 @@ addLstn(ptcpsrv_t *pSrv, int sock, int isIPv6)
CHKmalloc(pLstn = malloc(sizeof(ptcplstn_t)));
pLstn->pSrv = pSrv;
+ pLstn->bSuppOctetFram = pSrv->bSuppOctetFram;
pLstn->sock = sock;
/* support statistics gathering */
CHKiRet(statsobj.Construct(&(pLstn->stats)));
@@ -891,6 +900,7 @@ addLstn(ptcpsrv_t *pSrv, int sock, int isIPv6)
isIPv6 ? "IPv6" : "IPv4");
statname[sizeof(statname)-1] = '\0'; /* just to be on the save side... */
CHKiRet(statsobj.SetName(pLstn->stats, statname));
+ STATSCOUNTER_INIT(pLstn->ctrSubmit, pLstn->mutCtrSubmit);
CHKiRet(statsobj.AddCounter(pLstn->stats, UCHAR_CONSTANT("submitted"),
ctrType_IntCtr, &(pLstn->ctrSubmit)));
CHKiRet(statsobj.ConstructFinalize(pLstn->stats));
@@ -922,6 +932,7 @@ addSess(ptcplstn_t *pLstn, int sock, prop_t *peerName, prop_t *peerIP)
CHKmalloc(pSess->pMsg = malloc(iMaxLine * sizeof(uchar)));
pSess->pLstn = pLstn;
pSess->sock = sock;
+ pSess->bSuppOctetFram = pLstn->bSuppOctetFram;
pSess->inputState = eAtStrtFram;
pSess->iMsg = 0;
pSess->bAtStrtOfFram = 1;
@@ -1013,6 +1024,7 @@ static rsRetVal addInstance(void __attribute__((unused)) *pVal, uchar *pNewVal)
CHKmalloc(inst->pszInputName = ustrdup(cs.pszInputName));
}
inst->pBindRuleset = NULL;
+ inst->bSuppOctetFram = cs.bSuppOctetFram;
inst->bKeepAlive = cs.bKeepAlive;
inst->iKeepAliveIntvl = cs.iKeepAliveTime;
inst->iKeepAliveProbes = cs.iKeepAliveProbes;
@@ -1045,6 +1057,7 @@ addListner(modConfData_t __attribute__((unused)) *modConf, instanceConf_t *inst)
pthread_mutex_init(&pSrv->mutSessLst, NULL);
pSrv->pSess = NULL;
pSrv->pLstn = NULL;
+ pSrv->bSuppOctetFram = inst->bSuppOctetFram;
pSrv->bKeepAlive = inst->bKeepAlive;
pSrv->iKeepAliveIntvl = inst->iKeepAliveTime;
pSrv->iKeepAliveProbes = inst->iKeepAliveProbes;
@@ -1530,6 +1543,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
cs.iKeepAliveProbes = 0;
cs.iKeepAliveTime = 0;
cs.iKeepAliveIntvl = 0;
+ cs.bSuppOctetFram = 1;
cs.iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
free(cs.pszInputName);
cs.pszInputName = NULL;
@@ -1586,6 +1600,8 @@ CODEmodInit_QueryRegCFSLineHdlr
NULL, &cs.iKeepAliveTime, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpserverkeepalive_intvl"), 0, eCmdHdlrInt,
NULL, &cs.iKeepAliveIntvl, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpserversupportoctetcountedframing"), 0, eCmdHdlrBinary,
+ NULL, &cs.bSuppOctetFram, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpservernotifyonconnectionclose"), 0,
eCmdHdlrBinary, NULL, &cs.bEmitMsgOnClose, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpserveraddtlframedelimiter"), 0, eCmdHdlrInt,