summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-01-28 11:00:21 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-01-28 11:00:21 +0100
commita4a94ddfc0dc2256d7a3bc79ed8f9489de9f0f9b (patch)
tree579dd1579e7f1bec892a5e8ae734cccf25db444b
parentb621be0936468eacd19f55c9ff43c7598a4a6701 (diff)
downloadrsyslog-a4a94ddfc0dc2256d7a3bc79ed8f9489de9f0f9b.tar.gz
rsyslog-a4a94ddfc0dc2256d7a3bc79ed8f9489de9f0f9b.tar.xz
rsyslog-a4a94ddfc0dc2256d7a3bc79ed8f9489de9f0f9b.zip
interim commit: current debug state of new imptcp
I need to verify the concept used in a simpler environment, and this means I probably need to freeze the (non-working) state here for a couple of days.
-rw-r--r--runtime/debug.c40
-rw-r--r--tcpsrv.c14
2 files changed, 37 insertions, 17 deletions
diff --git a/runtime/debug.c b/runtime/debug.c
index 3f1c23bd..a017fc30 100644
--- a/runtime/debug.c
+++ b/runtime/debug.c
@@ -843,12 +843,15 @@ do_dbgprint(uchar *pszObjName, char *pszMsg, size_t lenMsg)
static int bWasNL = 0;
char pszThrdName[64]; /* 64 is to be on the safe side, anything over 20 is bad... */
char pszWriteBuf[32*1024];
+ size_t lenCopy;
+ size_t offsWriteBuf = 0;
size_t lenWriteBuf;
struct timespec t;
# if _POSIX_TIMERS <= 0
struct timeval tv;
# endif
+#if 0
/* The bWasNL handler does not really work. It works if no thread
* switching occurs during non-NL messages. Else, things are messed
* up. Anyhow, it works well enough to provide useful help during
@@ -859,8 +862,8 @@ do_dbgprint(uchar *pszObjName, char *pszMsg, size_t lenMsg)
*/
if(ptLastThrdID != pthread_self()) {
if(!bWasNL) {
- if(stddbg != -1) write(stddbg, "\n", 1);
- if(altdbg != -1) write(altdbg, "\n", 1);
+ pszWriteBuf[0] = '\n';
+ offsWriteBuf = 1;
bWasNL = 1;
}
ptLastThrdID = pthread_self();
@@ -881,25 +884,28 @@ do_dbgprint(uchar *pszObjName, char *pszMsg, size_t lenMsg)
t.tv_sec = tv.tv_sec;
t.tv_nsec = tv.tv_usec * 1000;
# endif
- lenWriteBuf = snprintf(pszWriteBuf, sizeof(pszWriteBuf),
+ lenWriteBuf = snprintf(pszWriteBuf+offsWriteBuf, sizeof(pszWriteBuf) - offsWriteBuf,
"%4.4ld.%9.9ld:", (long) (t.tv_sec % 10000), t.tv_nsec);
- if(stddbg != -1) write(stddbg, pszWriteBuf, lenWriteBuf);
- if(altdbg != -1) write(altdbg, pszWriteBuf, lenWriteBuf);
+ offsWriteBuf += lenWriteBuf;
}
- lenWriteBuf = snprintf(pszWriteBuf, sizeof(pszWriteBuf), "%s: ", pszThrdName);
- // use for testing: lenWriteBuf = snprintf(pszWriteBuf, sizeof(pszWriteBuf), "{%ld}%s: ", (long) syscall(SYS_gettid), pszThrdName);
- if(stddbg != -1) write(stddbg, pszWriteBuf, lenWriteBuf);
- if(altdbg != -1) write(altdbg, pszWriteBuf, lenWriteBuf);
+ lenWriteBuf = snprintf(pszWriteBuf + offsWriteBuf, sizeof(pszWriteBuf) - offsWriteBuf, "%s: ", pszThrdName);
+ offsWriteBuf += lenWriteBuf;
/* print object name header if we have an object */
if(pszObjName != NULL) {
- lenWriteBuf = snprintf(pszWriteBuf, sizeof(pszWriteBuf), "%s: ", pszObjName);
- if(stddbg != -1) write(stddbg, pszWriteBuf, lenWriteBuf);
- if(altdbg != -1) write(altdbg, pszWriteBuf, lenWriteBuf);
+ lenWriteBuf = snprintf(pszWriteBuf + offsWriteBuf, sizeof(pszWriteBuf) - offsWriteBuf, "%s: ", pszObjName);
+ offsWriteBuf += lenWriteBuf;
}
}
- if(stddbg != -1) write(stddbg, pszMsg, lenMsg);
- if(altdbg != -1) write(altdbg, pszMsg, lenMsg);
+#endif
+ if(lenMsg > sizeof(pszWriteBuf) - offsWriteBuf)
+ lenCopy = sizeof(pszWriteBuf) - offsWriteBuf;
+ else
+ lenCopy = lenMsg;
+ memcpy(pszWriteBuf + offsWriteBuf, pszMsg, lenCopy);
+ offsWriteBuf += lenCopy;
+ if(stddbg != -1) write(stddbg, pszWriteBuf, offsWriteBuf);
+ if(altdbg != -1) write(altdbg, pszWriteBuf, offsWriteBuf);
bWasNL = (pszMsg[lenMsg - 1] == '\n') ? 1 : 0;
}
@@ -923,12 +929,12 @@ dbgprint(obj_t *pObj, char *pszMsg, size_t lenMsg)
pszObjName = obj.GetName(pObj);
}
- pthread_mutex_lock(&mutdbgprint);
- pthread_cleanup_push(dbgMutexCancelCleanupHdlr, &mutdbgprint);
+// pthread_mutex_lock(&mutdbgprint);
+// pthread_cleanup_push(dbgMutexCancelCleanupHdlr, &mutdbgprint);
do_dbgprint(pszObjName, pszMsg, lenMsg);
- pthread_cleanup_pop(1);
+// pthread_cleanup_pop(1);
}
#pragma GCC diagnostic warning "-Wempty-body"
diff --git a/tcpsrv.c b/tcpsrv.c
index 3f078b6e..da5182e1 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -548,6 +548,7 @@ doReceive(tcpsrv_t *pThis, tcps_sess_t **ppSess, nspoll_t *pPoll)
errno = 0;
errmsg.LogError(0, iRet, "netstream session %p will be closed due to error\n",
(*ppSess)->pStrm);
+abort();
CHKiRet(closeSess(pThis, ppSess, pPoll));
break;
}
@@ -612,6 +613,8 @@ dbgprintf("XXX: worker %p idling\n", pthread_self());
return NULL;
}
+#warning remove include
+#include <stdio.h>
/* Process a workset, that is handle io. We become activated
* from either select or epoll handler. We split the workload
@@ -625,6 +628,16 @@ processWorkset(tcpsrv_t *pThis, nspoll_t *pPoll, int numEntries, nsd_epworkset_t
int origEntries = numEntries;
DEFiRet;
+{ /* chck workset for dupes */
+int k, j;
+for(k = 0 ; k < numEntries ; ++k)
+ for(j = k+1 ; j < numEntries ; ++j) {
+ if(workset[k].pUsr == workset[j].pUsr) {
+ fprintf(stderr, "workset duplicate %d:%d:%p\n", k, j, workset[k].pUsr);
+ fflush(stderr);
+ }
+ }
+}
dbgprintf("tcpsrv: ready to process %d event entries\n", numEntries);
while(numEntries > 0) {
@@ -632,6 +645,7 @@ processWorkset(tcpsrv_t *pThis, nspoll_t *pPoll, int numEntries, nsd_epworkset_t
ABORT_FINALIZE(RS_RET_FORCE_TERM);
dbgprintf("XXX: num entries during processing %d\n", numEntries);
if(numEntries == 1) {
+ //|| workset[numEntries-1].pUsr == pThis->ppLstn) {
dbgprintf("XXX: processWorkset 1\n");
/* process self, save context switch */
processWorksetItem(pThis, pPoll, workset[numEntries-1].id, workset[numEntries-1].pUsr);