Hi Hemant,
On Thu, Nov 2, 2017 at 12:08 PM, Hemant Chaudhary
<hemantdude.chaudhary@gmail.com > wrote:
>
> For my product I need to run apache as single process. As httpd -X works for
> me. But the issue is to stop httpd -X, we need to kill process. While
> killing the process, semaphore exists in kernel directory.
As Luca said, the default semaphore mechanism (i.e. if not changed by
./configure) used by httpd is "sysvsem", and it indeed leaks a
descriptor when not exiting properly (or from debug mode).
The easier way to use another mechanism is the Mutex directive, for instance:
Mutex pthread default
defined globally will use a mechanism which does not have this issue.
If you really want to stay with "sysvsem" mechanism, the following
patch will do it for the debug mode too:
Index: server/mpm/event/event.c
============================================================ =======
--- server/mpm/event/event.c (revision 1814101)
+++ server/mpm/event/event.c (working copy)
@@ -691,6 +691,7 @@ static void clean_child_exit(int code)
if (one_process) {
event_note_child_killed(/* slot */ 0, 0, 0);
+ atexit(apr_terminate);
}
exit(code);
Index: server/mpm/prefork/prefork.c
============================================================ =======
--- server/mpm/prefork/prefork.c (revision 1814101)
+++ server/mpm/prefork/prefork.c (working copy)
@@ -229,6 +229,7 @@ static void clean_child_exit(int code)
if (one_process) {
prefork_note_child_killed(/* slot */ 0, 0, 0);
+ atexit(apr_terminate);
}
ap_mpm_pod_close(my_bucket->pod);
Index: server/mpm/worker/worker.c
============================================================ =======
--- server/mpm/worker/worker.c (revision 1814101)
+++ server/mpm/worker/worker.c (working copy)
@@ -435,6 +435,7 @@ static void clean_child_exit(int code)
if (one_process) {
worker_note_child_killed(/* slot */ 0, 0, 0);
+ atexit(apr_terminate);
}
exit(code);
_
>
> Therefore I commented following lines in worker.c
>
> if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i",
> i),ap_proc_mutex_create(&all_buckets[i].mutex,NULL, AP_ACCEPT_MUTEX_TYPE, This can't work, the mutex will be used later on so it will crash.
> id, s, pconf, 0))))) {
> ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv, (startup ?
> NULL : s), "could not create accept mutex");
> return !OK;
>
> After commenting above line, when I am starting httpd -X, it is giving
> signal 31 error.
Thus this change is incomplete, and the complete one is probably more
complex than the changes proposed above.
>
> What should I change if I want to start apache in debug mode and not to
> create semaphore ?
I don't think suppressing this mutex (or any other process/global
mutex which your configuration may need, soon or later...) is wise.
You should go with avoiding the leak (as proposed above).
Regards,
Yann.
------------------------------------------------------------ ---------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx