summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/msg.c47
-rw-r--r--runtime/nsd_gtls.c5
-rw-r--r--runtime/nsdsel_gtls.c2
-rw-r--r--runtime/queue.c29
-rw-r--r--runtime/vm.c3
5 files changed, 51 insertions, 35 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index cf59f762..a5881f50 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -158,14 +158,40 @@ static void MsgLockingDummy(msg_t __attribute__((unused)) *pMsg)
* where a message may be accessed by multiple threads. This implementation here
* is the version for multiple concurrent acces. It initializes the locking
* structures.
+ * TODO: change to an iRet interface! -- rgerhards, 2008-07-14
*/
static void MsgPrepareEnqueueLockingCase(msg_t *pThis)
{
+ int iErr;
+ BEGINfunc
assert(pThis != NULL);
- pthread_mutexattr_settype(&pThis->mutAttr, PTHREAD_MUTEX_RECURSIVE);
+ iErr = pthread_mutexattr_init(&pThis->mutAttr);
+ if(iErr != 0) {
+ dbgprintf("error initializing mutex attribute in %s:%d, trying to continue\n",
+ __FILE__, __LINE__);
+ }
+ iErr = pthread_mutexattr_settype(&pThis->mutAttr, PTHREAD_MUTEX_RECURSIVE);
+ if(iErr != 0) {
+ dbgprintf("ERROR setting mutex attribute to recursive in %s:%d, trying to continue "
+ "but we will probably either abort or hang soon\n",
+ __FILE__, __LINE__);
+ /* TODO: it makes very little sense to continue here,
+ * but it requires an iRet interface to gracefully shut
+ * down. We should do that over time. -- rgerhards, 2008-07-14
+ */
+ }
pthread_mutex_init(&pThis->mut, &pThis->mutAttr);
+
+ /* we do no longer need the attribute. According to the
+ * POSIX spec, we can destroy it without affecting the
+ * initialized mutex (that used the attribute).
+ * rgerhards, 2008-07-14
+ */
+ pthread_mutexattr_destroy(&pThis->mutAttr);
+ ENDfunc
}
+
/* ... and now the locking and unlocking implementations: */
static void MsgLockLockingCase(msg_t *pThis)
{
@@ -200,11 +226,12 @@ static void MsgDeleteMutexLockingCase(msg_t *pThis)
*/
rsRetVal MsgEnableThreadSafety(void)
{
+ DEFiRet;
funcLock = MsgLockLockingCase;
funcUnlock = MsgUnlockLockingCase;
funcMsgPrepareEnqueue = MsgPrepareEnqueueLockingCase;
funcDeleteMutex = MsgDeleteMutexLockingCase;
- return RS_RET_OK;
+ RETiRet;
}
/* end locking functions */
@@ -652,19 +679,23 @@ char *getMSG(msg_t *pM)
/* Get PRI value in text form */
char *getPRI(msg_t *pM)
{
+ int pri;
+
if(pM == NULL)
return "";
MsgLock(pM);
if(pM->pszPRI == NULL) {
- /* OK, we need to construct it...
- * we use a 5 byte buffer - as of
- * RFC 3164, it can't be longer. Should it
- * still be, snprintf will truncate...
+ /* OK, we need to construct it... we use a 5 byte buffer - as of
+ * RFC 3164, it can't be longer. Should it still be, snprintf will truncate...
+ * Note that we do not use the LOG_MAKEPRI macro. This macro
+ * is a simple add of the two values under FreeBSD 7. So we implement
+ * the logic in our own code. This is a change from a bug
+ * report. -- rgerhards, 2008-07-14
*/
+ pri = pM->iFacility * 8 + pM->iSeverity;
if((pM->pszPRI = malloc(5)) == NULL) return "";
- pM->iLenPRI = snprintf((char*)pM->pszPRI, 5, "%d",
- LOG_MAKEPRI(pM->iFacility, pM->iSeverity));
+ pM->iLenPRI = snprintf((char*)pM->pszPRI, 5, "%d", pri);
}
MsgUnlock(pM);
diff --git a/runtime/nsd_gtls.c b/runtime/nsd_gtls.c
index 3f2817f7..08623da8 100644
--- a/runtime/nsd_gtls.c
+++ b/runtime/nsd_gtls.c
@@ -1394,7 +1394,10 @@ AcceptConnReq(nsd_t *pNsd, nsd_t **ppNew)
if(gnuRet == GNUTLS_E_AGAIN || gnuRet == GNUTLS_E_INTERRUPTED) {
pNew->rtryCall = gtlsRtry_handshake;
dbgprintf("GnuTLS handshake does not complete immediately - setting to retry (this is OK and normal)\n");
- } else if(gnuRet != 0) {
+ } else if(gnuRet == 0) {
+ /* we got a handshake, now check authorization */
+ CHKiRet(gtlsChkPeerAuth(pNew));
+ } else {
ABORT_FINALIZE(RS_RET_TLS_HANDSHAKE_ERR);
}
diff --git a/runtime/nsdsel_gtls.c b/runtime/nsdsel_gtls.c
index 81b90a62..c3a93bee 100644
--- a/runtime/nsdsel_gtls.c
+++ b/runtime/nsdsel_gtls.c
@@ -91,7 +91,6 @@ Add(nsdsel_t *pNsdsel, nsd_t *pNsd, nsdsel_waitOp_t waitOp)
/* if we reach this point, we need no special handling */
CHKiRet(nsdsel_ptcp.Add(pThis->pTcp, pNsdGTLS->pTcp, waitOp));
-RUNLOG_VAR("%d", pThis->iBufferRcvReady);
finalize_it:
RETiRet;
}
@@ -107,7 +106,6 @@ Select(nsdsel_t *pNsdsel, int *piNumReady)
nsdsel_gtls_t *pThis = (nsdsel_gtls_t*) pNsdsel;
ISOBJ_TYPE_assert(pThis, nsdsel_gtls);
-RUNLOG_VAR("%d", pThis->iBufferRcvReady);
if(pThis->iBufferRcvReady > 0) {
/* we still have data ready! */
*piNumReady = pThis->iBufferRcvReady;
diff --git a/runtime/queue.c b/runtime/queue.c
index 24fcee10..00f811a0 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -815,8 +815,8 @@ static rsRetVal qConstructDisk(queue_t *pThis)
* for example file name generation must not be changed as that would break the
* ability to read existing queue files. -- rgerhards, 2008-01-12
*/
-CHKiRet(strmSetiMaxFileSize(pThis->tVars.disk.pWrite, pThis->iMaxFileSize));
-CHKiRet(strmSetiMaxFileSize(pThis->tVars.disk.pRead, pThis->iMaxFileSize));
+ CHKiRet(strmSetiMaxFileSize(pThis->tVars.disk.pWrite, pThis->iMaxFileSize));
+ CHKiRet(strmSetiMaxFileSize(pThis->tVars.disk.pRead, pThis->iMaxFileSize));
finalize_it:
RETiRet;
@@ -849,6 +849,12 @@ static rsRetVal qAddDisk(queue_t *pThis, void* pUsr)
pThis->tVars.disk.sizeOnDisk += nWriteCount;
+ /* we have enqueued the user element to disk. So we now need to destruct
+ * the in-memory representation. The instance will be re-created upon
+ * dequeue. -- rgerhards, 2008-07-09
+ */
+ objDestruct(pUsr);
+
dbgoprint((obj_t*) pThis, "write wrote %lld octets to disk, queue disk size now %lld octets\n",
nWriteCount, pThis->tVars.disk.sizeOnDisk);
@@ -2080,10 +2086,6 @@ finalize_it:
/* enqueue a new user data element
* Enqueues the new element and awakes worker thread.
- * TODO: this code still uses the "discard if queue full" approach from
- * the main queue. This needs to be reconsidered or, better, done via a
- * caller-selectable parameter mode. For the time being, I leave it in.
- * rgerhards, 2008-01-03
*/
rsRetVal
queueEnqObj(queue_t *pThis, flowControl_t flowCtlType, void *pUsr)
@@ -2164,21 +2166,6 @@ queueEnqObj(queue_t *pThis, flowControl_t flowCtlType, void *pUsr)
}
}
-#if 0 // previous code, remove when done with advanced flow control
- /* wait for the queue to be ready... */
- while( (pThis->iMaxQueueSize > 0 && pThis->iQueueSize >= pThis->iMaxQueueSize)
- || (pThis->qType == QUEUETYPE_DISK && pThis->sizeOnDiskMax != 0
- && pThis->tVars.disk.sizeOnDisk > pThis->sizeOnDiskMax)) {
- dbgoprint((obj_t*) pThis, "enqueueMsg: queue FULL - waiting to drain.\n");
- timeoutComp(&t, pThis->toEnq);
- if(pthread_cond_timedwait(&pThis->notFull, pThis->mut, &t) != 0) {
- dbgoprint((obj_t*) pThis, "enqueueMsg: cond timeout, dropping message!\n");
- objDestruct(pUsr);
- ABORT_FINALIZE(RS_RET_QUEUE_FULL);
- }
- }
-#endif
-
/* and finally enqueue the message */
CHKiRet(queueAdd(pThis, pUsr));
queueChkPersist(pThis);
diff --git a/runtime/vm.c b/runtime/vm.c
index bcd331ec..bc6c3dd2 100644
--- a/runtime/vm.c
+++ b/runtime/vm.c
@@ -198,7 +198,6 @@ CODESTARTop(CMP_CONTAINS)
bRes = (rsCStrLocateInSzStr(operand2->val.pStr, rsCStrGetSzStr(operand1->val.pStr)) == -1) ? 0 : 1;
/* we have a result, so let's push it */
-RUNLOG_VAR("%lld", bRes); \
PUSHRESULTop(operand1, bRes);
var.Destruct(&operand2); /* no longer needed */
ENDop(CMP_CONTAINS)
@@ -218,7 +217,6 @@ var.DebugPrint(operand2); \
bRes = (rsCStrCaseInsensitiveLocateInSzStr(operand2->val.pStr, rsCStrGetSzStr(operand1->val.pStr)) == -1) ? 0 : 1;
/* we have a result, so let's push it */
-RUNLOG_VAR("%lld", bRes); \
PUSHRESULTop(operand1, bRes);
var.Destruct(&operand2); /* no longer needed */
ENDop(CMP_CONTAINSI)
@@ -237,7 +235,6 @@ CODESTARTop(CMP_STARTSWITH)
rsCStrLen(operand2->val.pStr)) == 0) ? 1 : 0;
/* we have a result, so let's push it */
-RUNLOG_VAR("%lld", bRes); \
PUSHRESULTop(operand1, bRes);
var.Destruct(&operand2); /* no longer needed */
ENDop(CMP_STARTSWITH)