You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Damiano Barboni <ba...@meeo.it> on 2010/11/25 16:33:41 UTC

[users@httpd] CLOSE_WAIT management with apche2 and mod_python

Hi All,
I’m working with Apache2 and mod_python.

I have a server process that must run a long and heavy data processing.
If the client (the user) decides to stop the data processing, the server
receives the signal and the connection enters in a CLOSE_WAIT status
until the server process has finished. 

Since the resources utilization is high, I would like to manage the
CLOSE_WAIT status and I would like to force the server process to end.
Is there a method to allow the server process to see the connection
status and, in particular, to see if the connection is in CLOSE_WAIT ?

For example, considering the following code:

from mod_python import util
import apache, time, sys

def handler(req):     
    #infinite loop
    while True: 
        time.sleep(2)      
        #open log file
        f = open("/home/damiano/www/test_close_wait.log","a")
        f.write(str(req.connection.aborted))
        f.write("\n")
        f.close()
	
        #exit if connection is in CLOSE_WAIT	
        if req.connection.aborted:
            sys.exit(1)
    
    req.content_type = 'text/html'
    req.write("<p>END</p>")
    
    return apache.OK

The infinite loop can be considered as my data processing. 
req.connection is the connection object associated with the request. 
req.connection.aborted is the element that i have tried to check but,
when the connection changes from ESTABLISHED to CLOSE_WAIT, this
variable does not change and remains to 0 (False).

Does anyone know how to deal with the problem and can help me.

Thanks in advance

Damiano



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] CLOSE_WAIT management with apche2 and mod_python

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 11/25/2010 9:33 AM, Damiano Barboni wrote:
> 
> Since the resources utilization is high, I would like to manage the
> CLOSE_WAIT status and I would like to force the server process to end.

Ending the server process will have ENOEFFECT.  The network socket stack
in the OS entirely owns the CLOSE_WAIT socket to satisfy the configured
MTU, which you can muck with in your kernel/sockets configuration.

That isn't actually an httpd question at all.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org