>Switching to setjmp/longjmp does appear to work well with apache and gcc.
>But that leaves me wondering if I need to worry about thread-safety.
>Is using setjmp/longjmp with Worker or Windoze MPM asking for trouble?
>And if so, is there an alternative approach I could try?
Please refer to this discussion about thread safety of setjmp/longjmp:
http://groups.google.com/[EMAIL PROTECTED]
And... in perchild.c, I found setjmp/longjmp is used unsafely
(one jmpbuffer is shared by all threads).
Tsuyoshi SASAMOTO
[EMAIL PROTECTED]
--- httpd-2.0/server/mpm/experimental/perchild/perchild.c Tue Mar 16 08:08:41
2004
+++ httpd-2.0/server/mpm/experimental/perchild/perchild.c Wed Jul 21 04:26:15
2004
@@ -137,7 +137,7 @@
static int requests_this_child;
static int num_listensocks = 0;
static ap_pod_t *pod;
-static jmp_buf jmpbuffer;
+static jmp_buf *jmpbuffers;
struct child_info_t {
uid_t uid;
@@ -617,7 +617,7 @@
bodylen = strlen(body);
headers = iov.iov_base;
- headerslen = body - headers;
+ headerslen = body - 1 - headers;
bucket = apr_bucket_heap_create(body, bodylen, NULL, alloc);
APR_BRIGADE_INSERT_HEAD(bb, bucket);
@@ -758,7 +758,7 @@
}
}
apr_thread_mutex_unlock(idle_thread_count_mutex);
- if (setjmp(jmpbuffer) != 1) {
+ if (setjmp(jmpbuffers[thread_num]) != 1) {
process_socket(ptrans, csd, conn_id, bucket_alloc);
}
else {
@@ -1668,6 +1668,8 @@
}
ap_child_table = (ap_ctable *)apr_pcalloc(p, server_limit * sizeof(ap_ctable));
+ jmpbuffers = (jmp_buf *)apr_palloc(p, thread_limit * sizeof(jmp_buf));
+
return OK;
}
@@ -1704,7 +1706,7 @@
ap_server_conf, "Could not pass request to proper "
"child, request will not be honored.");
}
- longjmp(jmpbuffer, 1);
+ longjmp(jmpbuffers[thread_num], 1);
}
return OK;
}