Commented: (MODPYTHON-195) Possible leaking of Win32 event
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Commented: (MODPYTHON-195) Possible leaking of Win32 event




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Commented: (MODPYTHON-195) Possible leaking of Win32 event  
Graham Dumpleton (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-24-06 06:12 AM

[ http://issues.apache.org/jira/brows...244
4208 ]

Graham Dumpleton commented on MODPYTHON-195:
--------------------------------------------

Jeff provides the following further information. The question is whether the
re is a more accepted way of doing this now as that email was from two years
 ago and that it is dependent on something that change from release to relea
se is a problem. Maybe a si
mple static variable can be used to determine if call has already been made 
since on the restart, the mod_python module should by rights be unloaded fro
m memory which means the static should get reset to 0, thus first call could
 always be setting it to 1
and second call not doing anything it already 1.


Anyway, Jeffs email follows:

I added some logging to python_init in mod_python.c to try to understand wha
t is going on.  Apparently when you run apache as a service on win32 the pyt
hon_init function gets called TWICE on restart (I have no idea why) and the 
first time is somehow spuri
ous (perhaps it is running in the context of the parent process that spawns 
the child process that really services requests?)
yet python_init allocates stuff anyway which never gets freed, for example t
he "interpreters_lock" allocated via
apr_thread_mutex_create(&interpreters_lock, APR_THREAD_MUTEX_UNNESTED, p);


I found this posting on the web
http://mail-archives.apache.org/mod...stoddard.com%3E
which seems to agree that the  ap_hook_post_config callback gets called twic
e on win32 running as a service and suggested this hack:

#ifdef WIN32
/* Do not run post_config in the Windows parent process
* The envar AP_PARENT_PID is set in the env list (by mpm_winnt)
* for the child process.
* **WARNING**:
* This check is not as robust as I would like because the name of
this
* envar is subject to change from release to release.
*/
if (!getenv("AP_PARENT_PID")) {
return OK;
}
#endif

I put this into python_init() just to see what would happen and sure enough,
 the leaking 4 handles went away.  I don't know what to do at this point sin
ce I am uncomfortable with the hack.  Yet clearly python_init() is not expec
ting to be called twice on
restart.  Is this an apache bug or a well-know (heh) feature that modules mu
st protect themselves against?


> Possible leaking of Win32 event handles when Apache restarted.
> --------------------------------------------------------------
>
>                 Key: MODPYTHON-195
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-195
>             Project: mod_python
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.10
>            Reporter: Graham Dumpleton
>
> Jeff Robins in:
>   http://mail-archives.apache.org/mod...dscpl.com.au%3e
> indicates a belief that when an Apache restart is performed on Windows that there 
are a number of Win32 event handles leaked. His belief is that this seems to be link
ed to mod_python.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:56 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register