[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5866 - GNUnet/src/server
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5866 - GNUnet/src/server |
Date: |
Tue, 11 Dec 2007 22:09:31 -0700 (MST) |
Author: grothoff
Date: 2007-12-11 22:09:30 -0700 (Tue, 11 Dec 2007)
New Revision: 5866
Modified:
GNUnet/src/server/handler.c
Log:
fix
Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2007-12-12 03:40:08 UTC (rev 5865)
+++ GNUnet/src/server/handler.c 2007-12-12 05:09:30 UTC (rev 5866)
@@ -82,7 +82,7 @@
static int bq_firstFull_;
-static int threads_running = GNUNET_NO;
+static volatile int threads_running = GNUNET_NO;
static struct GNUNET_Semaphore *bufferQueueRead_;
@@ -651,6 +651,12 @@
void
core_receive (GNUNET_TransportPacket * mp)
{
+ if (threads_running != GNUNET_YES)
+ {
+ GNUNET_free (mp->msg);
+ GNUNET_free (mp);
+ return;
+ }
if ((mp->tsession != NULL) &&
(0 !=
memcmp (&mp->sender, &mp->tsession->peer,
@@ -664,8 +670,7 @@
if ((threads_running == GNUNET_NO) || (mainShutdownSignal != NULL))
{
#if TRACK_DISCARD
- if (globalLock_ != NULL)
- GNUNET_mutex_lock (globalLock_);
+ GNUNET_mutex_lock (globalLock_);
discarded++;
if (0 == discarded % 64)
GNUNET_GE_LOG (ectx,
@@ -674,8 +679,7 @@
"Accepted: %u discarded: %u blacklisted: %u, ratio:
%f\n",
accepted, discarded, blacklisted,
1.0 * accepted / (blacklisted + discarded + 1));
- if (globalLock_ != NULL)
- GNUNET_mutex_unlock (globalLock_);
+ GNUNET_mutex_unlock (globalLock_);
#endif
}
/* check for blacklisting */
@@ -724,8 +728,7 @@
GNUNET_free (mp->msg);
GNUNET_free (mp);
#if TRACK_DISCARD
- if (globalLock_ != NULL)
- GNUNET_mutex_lock (globalLock_);
+ GNUNET_mutex_lock (globalLock_);
discarded++;
if (0 == discarded % 64)
GNUNET_GE_LOG (ectx,
@@ -734,8 +737,7 @@
"Accepted: %u discarded: %u blacklisted: %u, ratio:
%f\n",
accepted, discarded, blacklisted,
1.0 * accepted / (blacklisted + discarded + 1));
- if (globalLock_ != NULL)
- GNUNET_mutex_unlock (globalLock_);
+ GNUNET_mutex_unlock (globalLock_);
#endif
return;
}
@@ -771,12 +773,6 @@
{
int i;
- globalLock_ = GNUNET_mutex_create (GNUNET_NO);
- for (i = 0; i < QUEUE_LENGTH; i++)
- bufferQueue_[i] = NULL;
- bq_firstFree_ = 0;
- bq_firstFull_ = 0;
-
/* create message handling threads */
threads_running = GNUNET_YES;
for (i = 0; i < THREAD_COUNT; i++)
@@ -811,8 +807,6 @@
}
GNUNET_semaphore_destroy (mainShutdownSignal);
mainShutdownSignal = NULL;
- GNUNET_mutex_destroy (globalLock_);
- globalLock_ = NULL;
}
/**
@@ -821,6 +815,8 @@
void
initHandler (struct GNUNET_GE_Context *e)
{
+ int i;
+
ectx = e;
handlerLock = GNUNET_mutex_create (GNUNET_NO);
transport = requestService ("transport");
@@ -830,6 +826,11 @@
/* initialize sync mechanisms for message handling threads */
bufferQueueRead_ = GNUNET_semaphore_create (0);
bufferQueueWrite_ = GNUNET_semaphore_create (QUEUE_LENGTH);
+ globalLock_ = GNUNET_mutex_create (GNUNET_NO);
+ for (i = 0; i < QUEUE_LENGTH; i++)
+ bufferQueue_[i] = NULL;
+ bq_firstFree_ = 0;
+ bq_firstFull_ = 0;
}
/**
@@ -840,6 +841,8 @@
{
unsigned int i;
+ GNUNET_mutex_destroy (globalLock_);
+ globalLock_ = NULL;
/* free datastructures */
GNUNET_semaphore_destroy (bufferQueueRead_);
bufferQueueRead_ = NULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5866 - GNUnet/src/server,
gnunet <=