summaryrefslogtreecommitdiffstats
path: root/tcpsrv.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-05-25 10:47:22 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-05-25 10:47:22 +0200
commiteb1615068c6a704287eda732d287280df4cc4c44 (patch)
treebf5d8b9cfcdf4203839faf03535149e6ad66f8fc /tcpsrv.c
parent7adb9877f0c08f929d89f436103dfade03e8ea07 (diff)
downloadrsyslog-eb1615068c6a704287eda732d287280df4cc4c44.tar.gz
rsyslog-eb1615068c6a704287eda732d287280df4cc4c44.tar.xz
rsyslog-eb1615068c6a704287eda732d287280df4cc4c44.zip
added new testing module imdiag
which enables to talk to the rsyslog core at runtime. The current implementation is only a beginning, but can be expanded over time
Diffstat (limited to 'tcpsrv.c')
-rw-r--r--tcpsrv.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/tcpsrv.c b/tcpsrv.c
index bbd95058..249eeecf 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -380,14 +380,15 @@ SessAccept(tcpsrv_t *pThis, tcpLstnPortList_t *pLstnInfo, tcps_sess_t **ppSess,
errno = 0;
errmsg.LogError(0, RS_RET_MAX_SESS_REACHED, "too many tcp sessions - dropping incoming request");
ABORT_FINALIZE(RS_RET_MAX_SESS_REACHED);
- } else {
- /* we found a free spot and can construct our session object */
- CHKiRet(tcps_sess.Construct(&pSess));
- CHKiRet(tcps_sess.SetTcpsrv(pSess, pThis));
- CHKiRet(tcps_sess.SetLstnInfo(pSess, pLstnInfo));
}
- /* OK, we have a "good" index... */
+ /* we found a free spot and can construct our session object */
+ CHKiRet(tcps_sess.Construct(&pSess));
+ CHKiRet(tcps_sess.SetTcpsrv(pSess, pThis));
+ CHKiRet(tcps_sess.SetLstnInfo(pSess, pLstnInfo));
+ if(pThis->OnMsgReceive != NULL)
+ CHKiRet(tcps_sess.SetOnMsgReceive(pSess, pThis->OnMsgReceive));
+
/* get the host name */
CHKiRet(netstrm.GetRemoteHName(pNewStrm, &fromHostFQDN));
CHKiRet(netstrm.GetRemoteIP(pNewStrm, &fromHostIP));
@@ -568,6 +569,7 @@ finalize_it: /* this is a very special case - this time only we do not exit the
BEGINobjConstruct(tcpsrv) /* be sure to specify the object type also in END macro! */
pThis->iSessMax = TCPSESS_MAX_DEFAULT; /* TODO: useful default ;) */
pThis->addtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
+ pThis->OnMsgReceive = NULL;
ENDobjConstruct(tcpsrv)
@@ -713,6 +715,16 @@ SetUsrP(tcpsrv_t *pThis, void *pUsr)
RETiRet;
}
+static rsRetVal
+SetOnMsgReceive(tcpsrv_t *pThis, rsRetVal (*OnMsgReceive)(tcps_sess_t*, uchar*, int))
+{
+ DEFiRet;
+ assert(OnMsgReceive != NULL);
+ pThis->OnMsgReceive = OnMsgReceive;
+ RETiRet;
+}
+
+
/* Set additional framing to use (if any) -- rgerhards, 2008-12-10 */
static rsRetVal
@@ -731,7 +743,6 @@ SetInputName(tcpsrv_t *pThis, uchar *name)
{
uchar *pszName;
DEFiRet;
-dbgprintf("XXX: SetInputName: %s\n", name);
ISOBJ_TYPE_assert(pThis, tcpsrv);
if(name == NULL)
pszName = NULL;
@@ -843,6 +854,7 @@ CODESTARTobjQueryInterface(tcpsrv)
pIf->SetCBOnDestruct = SetCBOnDestruct;
pIf->SetCBOnRegularClose = SetCBOnRegularClose;
pIf->SetCBOnErrClose = SetCBOnErrClose;
+ pIf->SetOnMsgReceive = SetOnMsgReceive;
finalize_it:
ENDobjQueryInterface(tcpsrv)