Re: [users@httpd] Apache creates Semaphore
Hi Hemant, On Fri, Nov 10, 2017 at 6:13 AM, Hemant Chaudharywrote: > > Yes kill -Term works for me even without patch of code. Good. > I have one more doubt, I checked with ipcs command that there is only entry > of semaphore and no entry in shared memory. > > If I have nothing in shared memory then why am I using semaphore? > What are the critical section in apache for which it requires semaphores. The IPC semaphore is for synchronization between processes, not necessarily around a shared memory. Here, for instance, it's to serialize the access of the listeners to each (shared) listening socket. Regards, Yann. - To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [users@httpd] Apache creates Semaphore
Hi, Yes kill -Term works for me even without patch of code. I have one more doubt, I checked with ipcs command that there is only entry of semaphore and no entry in shared memory. If I have nothing in shared memory then why am I using semaphore? What are the critical section in apache for which it requires semaphores. Thanks Hemant On Fri, Nov 3, 2017 at 5:17 PM, Yann Ylavicwrote: > On Fri, Nov 3, 2017 at 12:42 PM, Hemant Chaudhary > wrote: > > > > I killed as kill -9 process_id_of_httpd > > Well, you don't let httpd cleanup anything before exiting by doing > this (it's simply killed immediately). > Why kill with no arg (i.e. kill -TERM) wouldn't be enough? > > - > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > >
Re: [users@httpd] Apache creates Semaphore
On Fri, Nov 3, 2017 at 12:42 PM, Hemant Chaudharywrote: > > I killed as kill -9 process_id_of_httpd Well, you don't let httpd cleanup anything before exiting by doing this (it's simply killed immediately). Why kill with no arg (i.e. kill -TERM) wouldn't be enough? - To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [users@httpd] Apache creates Semaphore
Hi I build httpd by myself from source code on HPE nonstop. On Nov 3, 2017 5:12 PM, "Yann Ylavic"wrote: > On Fri, Nov 3, 2017 at 7:09 AM, Hemant Chaudhary > wrote: > > > > 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') > > What system is it? > Did you build httpd by yourself or it's from some distro? > > - > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > >
Re: [users@httpd] Apache creates Semaphore
On Fri, Nov 3, 2017 at 7:09 AM, Hemant Chaudharywrote: > > 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') What system is it? Did you build httpd by yourself or it's from some distro? - To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [users@httpd] Apache creates Semaphore
Hi I killed as kill -9 process_id_of_httpd On Nov 3, 2017 5:05 PM, "Yann Ylavic"wrote: > Hi Hemant, > > On Fri, Nov 3, 2017 at 12:01 PM, Hemant Chaudhary > wrote: > > I tried with the patch of code you have asked for prefork.c and worker.c. > > But If I am closing apache gracefully then semaphore is not in shared > > location but if I am killing process then still semaphore is there in > shared > > location. > > How do you kill httpd? "kill -TERM" should work... "kill -KILL" is a > bit, well overkill :p > > Regards, > Yann. > > - > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > >
Re: [users@httpd] Apache creates Semaphore
Hi Hemant, On Fri, Nov 3, 2017 at 12:01 PM, Hemant Chaudharywrote: > I tried with the patch of code you have asked for prefork.c and worker.c. > But If I am closing apache gracefully then semaphore is not in shared > location but if I am killing process then still semaphore is there in shared > location. How do you kill httpd? "kill -TERM" should work... "kill -KILL" is a bit, well overkill :p Regards, Yann. - To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [users@httpd] Apache creates Semaphore
Hi, I tried with the patch of code you have asked for prefork.c and worker.c. But If I am closing apache gracefully then semaphore is not in shared location but if I am killing process then still semaphore is there in shared location. Is there any way I get rid of semaphore because I want to run single process only. Thanks hemant On Fri, Nov 3, 2017 at 2:56 AM, Yann Ylavicwrote: > Hi Hemant, > > On Thu, Nov 2, 2017 at 12:08 PM, Hemant Chaudhary > 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(_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-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > >
Re: [users@httpd] Apache creates Semaphore
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 Ylavicwrote: > Hi Hemant, > > On Thu, Nov 2, 2017 at 12:08 PM, Hemant Chaudhary > 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(_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-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > >
Re: [users@httpd] Apache creates Semaphore
Hi Hemant, On Thu, Nov 2, 2017 at 12:08 PM, Hemant Chaudharywrote: > > 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(_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-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [users@httpd] Apache creates Semaphore
Hi Luca, If I choose to go with MPM and to spawn single process then it will create parent process and then child process where parent process monitor the server and child process serve the request. But I need only one process which works for both as parent and child which is achieved in httpd -X. httpd -X creates one process which monitor apache as well as serves the request. Is it possible to disable mutex while configuring apache, so that it will not create semaphores ? Thanks Hemant On Thu, Nov 2, 2017 at 5:09 PM, Luca Toscanowrote: > Hi Hemant, > > as indicated in https://httpd.apache.org/docs/2.4/mod/core.html#mutex you > can use different kind of mutex implementations and experiment with them. > From your description though it seems to me that your approach of killing > httpd leads to semaphore leaking, something that would be avoided with a > graceful shutdown. I would encourage you to not use httpd -X but to > configure your mpm to spawn one process only (note that you might need > svn.apache.org/r1748336 or httpd >= 2.4.21). > > Hope that helps, > > Luca > > > 2017-11-02 12:08 GMT+01:00 Hemant Chaudhary com>: > >> Hi Yann, >> >> 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. >> If I repeat for 10-15 times, then it will give error like no space >> available on device. >> To solve this error, either I need to explicitly kill each semaphore id >> and then start. So I thought not to create semaphore itself. >> Therefore I commented following lines in worker.c >> >> if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i", >> i),ap_proc_mutex_create(_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. When starting with httpd, its only starting parent and >> killing child processes with signal 31 error. >> >> What should I change if I want to start apache in debug mode and not to >> create semaphore ? >> >> Thanks >> Hemant >> >> >> >> On Thu, Nov 2, 2017 at 4:01 PM, Yann Ylavic wrote: >> >>> Hi Hemant, >>> >>> On Thu, Nov 2, 2017 at 5:47 AM, Hemant Chaudhary >>> wrote: >>> > >>> > Semaphore is used in multi process environment to share resources >>> within >>> > processes. But when I am starting apache in debug mode i:e single >>> process >>> > then still it creates semaphore. May I know the reason why it is >>> creating >>> > semaphore in debug mode also. >>> >>> The debug mode has no particular code optimization or walkout, >>> precisely because we want to be able to diagnose potential bugs for >>> the non-debug case. >>> >>> Regards, >>> Yann. >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org >>> For additional commands, e-mail: users-h...@httpd.apache.org >>> >>> >> >
Re: [users@httpd] Apache creates Semaphore
Hi Hemant, as indicated in https://httpd.apache.org/docs/2.4/mod/core.html#mutex you can use different kind of mutex implementations and experiment with them. >From your description though it seems to me that your approach of killing httpd leads to semaphore leaking, something that would be avoided with a graceful shutdown. I would encourage you to not use httpd -X but to configure your mpm to spawn one process only (note that you might need svn.apache.org/r1748336 or httpd >= 2.4.21). Hope that helps, Luca 2017-11-02 12:08 GMT+01:00 Hemant Chaudhary: > Hi Yann, > > 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. > If I repeat for 10-15 times, then it will give error like no space > available on device. > To solve this error, either I need to explicitly kill each semaphore id > and then start. So I thought not to create semaphore itself. > Therefore I commented following lines in worker.c > > if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i", > i),ap_proc_mutex_create(_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. When starting with httpd, its only starting parent and > killing child processes with signal 31 error. > > What should I change if I want to start apache in debug mode and not to > create semaphore ? > > Thanks > Hemant > > > > On Thu, Nov 2, 2017 at 4:01 PM, Yann Ylavic wrote: > >> Hi Hemant, >> >> On Thu, Nov 2, 2017 at 5:47 AM, Hemant Chaudhary >> wrote: >> > >> > Semaphore is used in multi process environment to share resources within >> > processes. But when I am starting apache in debug mode i:e single >> process >> > then still it creates semaphore. May I know the reason why it is >> creating >> > semaphore in debug mode also. >> >> The debug mode has no particular code optimization or walkout, >> precisely because we want to be able to diagnose potential bugs for >> the non-debug case. >> >> Regards, >> Yann. >> >> - >> To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org >> For additional commands, e-mail: users-h...@httpd.apache.org >> >> >
Re: [users@httpd] Apache creates Semaphore
Hi Yann, 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. If I repeat for 10-15 times, then it will give error like no space available on device. To solve this error, either I need to explicitly kill each semaphore id and then start. So I thought not to create semaphore itself. Therefore I commented following lines in worker.c if ((rv = SAFE_ACCEPT((apr_snprintf(id, sizeof id, "%i", i),ap_proc_mutex_create(_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. When starting with httpd, its only starting parent and killing child processes with signal 31 error. What should I change if I want to start apache in debug mode and not to create semaphore ? Thanks Hemant On Thu, Nov 2, 2017 at 4:01 PM, Yann Ylavicwrote: > Hi Hemant, > > On Thu, Nov 2, 2017 at 5:47 AM, Hemant Chaudhary > wrote: > > > > Semaphore is used in multi process environment to share resources within > > processes. But when I am starting apache in debug mode i:e single process > > then still it creates semaphore. May I know the reason why it is creating > > semaphore in debug mode also. > > The debug mode has no particular code optimization or walkout, > precisely because we want to be able to diagnose potential bugs for > the non-debug case. > > Regards, > Yann. > > - > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > >
Re: [users@httpd] Apache creates Semaphore
Hi Hemant, On Thu, Nov 2, 2017 at 5:47 AM, Hemant Chaudharywrote: > > Semaphore is used in multi process environment to share resources within > processes. But when I am starting apache in debug mode i:e single process > then still it creates semaphore. May I know the reason why it is creating > semaphore in debug mode also. The debug mode has no particular code optimization or walkout, precisely because we want to be able to diagnose potential bugs for the non-debug case. Regards, Yann. - To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org