Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #619 (defect)

Opened 2 years ago

Last modified 2 years ago

Long delay on startup

Status: closed (fixed)

Reported by: guest Assigned to: fumanchu
Priority: normal Milestone: 2.2.2
Component: CherryPy code Keywords:
Cc:

On one machine I have found there is a long delay ~40s on startup for Turbogears projects and the toolbox. Two other machines I've tried did not have this problem. The only difference I can think of is the machine with the problem has a wireless network card. It is Windows XP SP2, all patches and I'm using CherryPy 2.2.1.

My investigations show the delay is in the call to socket.getaddrinfo, line 280 of _cpwsgiserver.py. With host='' this delays for 40s. A simple fix is to have host=None instead, which returns immediately. Although getaddrinfo returns different information, this seems to work. I suggest adding the line if host == '': host = None Just before the call to getaddrinfo.

I have made this change on my machine and it fixes the problem.

Attachments

ai_passive.patch (1.0 kB) - added by fumanchu on 12/11/06 20:22:40.
Patch to _cpwsgiserver 2.2.1 to enable AI_PASSIVE and reduce startup time

Change History

12/11/06 18:03:44: Modified by fumanchu

  • description changed.

12/11/06 18:24:55: Modified by fumanchu

Copied from TG list:

If I use None instead of "" it returns
immediately. The results are slightly different:

host = None
    [(2, 1, 0, '', ('127.0.0.1', 8080))]
host = ""
    [(2, 1, 0, '', ('192.168.x.y', 8080))]

12/11/06 19:17:24: Modified by fumanchu

  • owner changed from rdelon to fumanchu.
  • status changed from new to assigned.
  • milestone set to 3.0.

Hmmm. These should not be equivalent. When a CP user specifies host = '', that should mean they wish to bind to INADDR_ANY, so we should probably set AI_PASSIVE in that case:

if host == '':
    info = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
                              socket.SOCK_STREAM, 0, socket.AI_PASSIVE)

which results in the res (2, 1, 0, '', ('0.0.0.0', 8080)). In other words, host='' should not result in '127.0.0.1'.

This concept is further confused in the source code right now because the monitor facilities inside the engine (like wait_for_free_port), and the test suite, both tell their client sides to connect on localhost if server.socket_host==''.

12/11/06 20:18:12: Modified by fumanchu

Long-winded fix for CP3 in [1528].

12/11/06 20:22:40: Modified by fumanchu

  • attachment ai_passive.patch added.

Patch to _cpwsgiserver 2.2.1 to enable AI_PASSIVE and reduce startup time

12/11/06 20:23:41: Modified by fumanchu

Please try the attached patch, which does the same thing but adds the AI_PASSIVE flag.

12/20/06 23:56:40: Modified by fumanchu

  • milestone changed from 3.0 to 2.2.2.

12/28/06 15:29:21: Modified by fumanchu

  • status changed from assigned to closed.
  • resolution set to fixed.

"Fixed" for 2.x in [1573]. Only applied to _cpwsgiserver3; it's not worth changing how socket_host behaves in the default server (and breaking existing deployments).

Hosted by WebFaction

Log in as guest/cpguest to create tickets