diff options
Diffstat (limited to 'src/Steer.c')
-rw-r--r-- | src/Steer.c | 24 |
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; } |