'bzr serve --port localhost:0' fails to allocate a dynamic port

Bug #664376 reported by John Szakmeister
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
High
Unassigned
Breezy
Triaged
Medium
Unassigned

Bug Description

According to the 'bzr serve -h', specifying a port number of 0 should result in a dynamically allocated port. However, on Mac OS X, I get the following error:
    bzr: ERROR: socket.gaierror: [Errno 8] nodename nor servname provided, or not known

It turns out the socket.getaddrinfo() line in bzrlib.smart.server.SmartTCPServer.start_server() is raising an error because the port number is 0. Unfortunately, I'm not sure what the right answer is here.

Tags: hpss mac
Revision history for this message
Vincent Ladeuil (vila) wrote :

Which OS/bzr version are you using ?

Almost all our tests use '0' to ask the system to assign a free port number. It's pretty weird that you get such an error here.

Do you use IPV6 ? (I can't remember if you can easily disable it on OSX).
The bug is propably pretty shallow but needs to be either diagnosed on your host or reproduced somewhere else.

Also, a traceback will help.

Changed in bzr:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Vincent Ladeuil (vila) wrote :

An additional note: why do you want to use 0 here ? It makes it harder for the clients to connect to it since they should find the port first...

Revision history for this message
John Szakmeister (jszakmeister) wrote : Re: [Bug 664376] Re: 'bzr serve --port localhost:0' fails to allocate a dynamic port

On Thu, Oct 21, 2010 at 6:34 AM, Vincent Ladeuil
<email address hidden> wrote:
> An additional note: why do you want to use 0 here ? It makes it harder
> for the clients to connect to it since they should find the port
> first...

I don't. :-) I decided to investigate why the test was failing,
discovered that's the reason. 'bzr serve -h' says it dynamically
allocates a port, and it doesn't (at least on Mac OS X). Hence the
bug. I've got no practical purpose for such a feature. :-) I filed
two bugs so we can track the issues separately (should the test be
fixed independent of supporting 0 as a port number, etc).

HTH!

-John

Revision history for this message
John A Meinel (jameinel) wrote :

We use 0 so that we don't clash with any other services that might be running.

'bzr serve' prints out what port it is running on, so we spawn it, read what port to talk to it, and go on with our lives.

Other methods of doing this are, allocate a socket but don't actually listen to it. Then you know it is available and force it on the child process.

Jelmer Vernooij (jelmer)
tags: added: hpss
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
Jelmer Vernooij (jelmer)
tags: added: mac
removed: check-for-breezy
Changed in brz:
status: New → Triaged
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.