aboutsummaryrefslogtreecommitdiff
path: root/src/Steer.c
diff options
context:
space:
mode:
authorgoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-10-25 18:47:25 +0000
committergoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-10-25 18:47:25 +0000
commit67e78d93e56222ee7b8b7e95e66d87f4cc5452f6 (patch)
treead1432408ae003090e78c885c42466e1d95e78cd /src/Steer.c
parent30d58b3a4f747fc7fd732492df06abcc2c5bd6d6 (diff)
Putting a mutex on the steering as there is a potential race condition here
if the http thread steers a parameter at the same time as the main thread dispatches the queue. Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@96 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Steer.c')
-rw-r--r--src/Steer.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Steer.c b/src/Steer.c
index d1da668..2f89e9b 100644
--- a/src/Steer.c
+++ b/src/Steer.c
@@ -17,6 +17,10 @@
#include <stdlib.h>
#include <string.h>
+#ifdef PTHREADS
+#include <pthread.h>
+#endif
+
#ifdef CCTK_MPI
#include "mpi.h"
#endif
@@ -55,6 +59,10 @@ static int SteerParameters(void);
static char *queuebuffer = NULL;
static int queuebuffer_size = 0;
+#ifdef PTHREADS
+static pthread_mutex_t steer_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
/********************************************************************
********************* External Routines **********************
********************************************************************/
@@ -82,6 +90,10 @@ int HTTP_SteerQueue(const char *thorn, const char *parameter, const char *value)
retval = 0;
+#ifdef PTHREADS
+ pthread_mutex_lock(&steer_mutex);
+#endif
+
buffer_length = queuebuffer ? strlen(queuebuffer) : 0;
/* Added length will be lengthof(thorn::par=val\n) */
@@ -110,6 +122,10 @@ int HTTP_SteerQueue(const char *thorn, const char *parameter, const char *value)
thorn,parameter, value);
}
+#ifdef PTHREADS
+ pthread_mutex_unlock(&steer_mutex);
+#endif
+
return retval;
}
@@ -129,10 +145,18 @@ int HTTP_SteerQueue(const char *thorn, const char *parameter, const char *value)
@@*/
int HTTP_SteerDispatch(void)
{
+#ifdef PTHREADS
+ pthread_mutex_lock(&steer_mutex);
+#endif
+
CommunicateBuffer();
SteerParameters();
+#ifdef PTHREADS
+ pthread_mutex_unlock(&steer_mutex);
+#endif
+
return 0;
}