Re: Apache creates Semaphore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Yann,

When I am setting Mutex pthread or Mutex Pthread default in httpd.conf, getting following error

AH00526: Syntax error on line 42 of /home/hemant_super/hemant/dev_11oct/conf/httpd.conf:
Invalid Mutex argument pthread (Mutex mechanisms are: 'none', 'default', 'fcntl:/path/to/file', 'file:/path/to/file', 'sysvsem', 'sem')

When I tried with Mutex None, it is giving below error
/home/hemant_super/hemant/dev_11oct/bin: ./httpd -V
AH00526: Syntax error on line 42 of /home/hemant_super/hemant/dev_11oct/conf/httpd.conf:
None is not allowed for mutex type default

Any idea why am I getting this error and how to solve it.

Thanks
Hemant



On Fri, Nov 3, 2017 at 2:56 AM, Yann Ylavic <ylavic.dev@xxxxxxxxx> wrote:
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,
> 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.

This can't work, the mutex will be used later on so it will crash.
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



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux