summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-09-29 14:24:02 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-09-29 14:24:02 +0000
commitf4fce92f28c7c5495929ad60ed24fda9f233d11a (patch)
treed1b36230b9308475be140504929332dfd7e400a7 /src
parent035b6ba84b3180b6432810605d7fc4ee98aea650 (diff)
downloadopenocd+libswd-f4fce92f28c7c5495929ad60ed24fda9f233d11a.tar.gz
openocd+libswd-f4fce92f28c7c5495929ad60ed24fda9f233d11a.tar.bz2
openocd+libswd-f4fce92f28c7c5495929ad60ed24fda9f233d11a.tar.xz
openocd+libswd-f4fce92f28c7c5495929ad60ed24fda9f233d11a.zip
handle single threading
git-svn-id: svn://svn.berlios.de/openocd/trunk@2771 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/server/httpd.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/server/httpd.c b/src/server/httpd.c
index 4705e442..0ddeb97a 100644
--- a/src/server/httpd.c
+++ b/src/server/httpd.c
@@ -34,6 +34,20 @@
#define PAGE_NOT_FOUND "<html><head><title > File not found</title></head><body > File not found</body></html>"
+static pthread_mutex_t mutex;
+
+void openocd_sleep_prelude(void)
+{
+ pthread_mutex_unlock(&mutex);
+}
+
+void openocd_sleep_postlude(void)
+{
+ pthread_mutex_lock(&mutex);
+}
+
+
+
int loadFile(const char *name, void **data, size_t *len);
static const char *appendf(const char *prev, const char *format, ...)
@@ -184,7 +198,9 @@ static void request_completed(void *cls, struct MHD_Connection *connection,
if (r->postprocessor)
{
+ openocd_sleep_postlude();
MHD_destroy_post_processor(r->postprocessor);
+ openocd_sleep_prelude();
}
free(r);
@@ -257,7 +273,7 @@ static int record_arg(void *cls, enum MHD_ValueKind kind, const char *key,
}
-int handle_request(struct MHD_Connection * connection, const char * url)
+static int handle_request(struct MHD_Connection * connection, const char * url)
{
struct MHD_Response * response;
@@ -335,7 +351,7 @@ int handle_request(struct MHD_Connection * connection, const char * url)
}
}
-static int ahc_echo(void * cls, struct MHD_Connection * connection,
+static int ahc_echo_inner(void * cls, struct MHD_Connection * connection,
const char * url, const char * method, const char * version,
const char * upload_data, unsigned int * upload_data_size, void ** ptr)
{
@@ -423,9 +439,23 @@ static int ahc_echo(void * cls, struct MHD_Connection * connection,
return result;
}
-static struct MHD_Daemon * d;
-static pthread_mutex_t mutex;
+static int ahc_echo(void * cls, struct MHD_Connection * connection,
+ const char * url, const char * method, const char * version,
+ const char * upload_data, unsigned int * upload_data_size, void ** ptr)
+{
+ int result;
+
+ openocd_sleep_postlude();
+
+ result = ahc_echo_inner(cls, connection, url, method, version, upload_data, upload_data_size, ptr);
+
+ openocd_sleep_prelude();
+
+ return result;
+}
+
+static struct MHD_Daemon * d;
int httpd_start(void)
{
@@ -464,13 +494,3 @@ void httpd_stop(void)
pthread_mutex_destroy(&mutex);
}
-void openocd_sleep_prelude(void)
-{
- pthread_mutex_unlock(&mutex);
-}
-
-void openocd_sleep_postlude(void)
-{
- pthread_mutex_lock(&mutex);
-}
-