if --listen is passed a hostname which returns duplicate addresses, the second listen attempt will fail, and eventually gearmand will fail too

Bug #918055 reported by Clint Byrum
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
Fix Released
Low
Clint Byrum

Bug Description

Test case:

On linux:

edit /etc/hosts and add *two* entries for 127.0.0.1 localhost

run

gearmand --listen=localhost

This will fail, because it listens on 127.0.0.1 once, then tries again.

$ strace -e trace=bind,connect,listen gearmand/gearmand -vvvvv --listen=localhost
connect(3, {sa_family=AF_FILE, path="/dev/log"}, 110) = 0
bind(7, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
connect(7, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(7, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
bind(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
bind(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
bind(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
listen(7, 32) = 0
bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)

This is an uncommon situation, but one that happens regularly on Ubuntu buildds, causing the entire test suite to fail.

Related branches

Changed in gearmand:
assignee: nobody → Clint Byrum (clint-fewbar)
status: New → In Progress
importance: Undecided → Low
Revision history for this message
Brian Aker (brianaker) wrote :

How does this work for same host, multiple ports?

Revision history for this message
Clint Byrum (clint-fewbar) wrote : Re: [Bug 918055] Re: if --listen is passed a hostname which returns duplicate addresses, the second listen attempt will fail, and eventually gearmand will fail too

Excerpts from Brian Aker's message of Thu Jan 19 17:56:51 UTC 2012:
> How does this work for same host, multiple ports?
>

The command line arguments and structure of the program do not allow
that. If we need to support that at some point, we merely need to add
the port to the key used.

> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/918055
>
> Title:
> if --listen is passed a hostname which returns duplicate addresses,
> the second listen attempt will fail, and eventually gearmand will fail
> too
>
> Status in Gearman Server and Client Libraries:
> In Progress
>
> Bug description:
> Test case:
>
> On linux:
>
> edit /etc/hosts and add *two* entries for 127.0.0.1 localhost
>
> run
>
> gearmand --listen=localhost
>
> This will fail, because it listens on 127.0.0.1 once, then tries
> again.
>
> $ strace -e trace=bind,connect,listen gearmand/gearmand -vvvvv --listen=localhost
> connect(3, {sa_family=AF_FILE, path="/dev/log"}, 110) = 0
> bind(7, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
> connect(7, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
> connect(7, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
> connect(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
> bind(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
> bind(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
> bind(7, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
> listen(7, 32) = 0
> bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
> bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
> bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
> bind(8, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EADDRINUSE (Address already in use)
>
> This is an uncommon situation, but one that happens regularly on
> Ubuntu buildds, causing the entire test suite to fail.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/gearmand/+bug/918055/+subscriptions

Revision history for this message
Brian Aker (brianaker) wrote : Re: [Bug 918055] if --listen is passed a hostname which returns duplicate addresses, the second listen attempt will fail, and eventually gearmand will fail too

Hi,

On Jan 19, 2012, at 12:41 PM, Clint Byrum wrote:

> The command line arguments and structure of the program do not allow
> that. If we need to support that at some point, we merely need to add
> the port to the key used.

Let me go on and put a bind on this so that we check against a host:port pair.

This should go in build soon'ish.

Cheers,
 -Brian

Brian Aker (brianaker)
Changed in gearmand:
status: In Progress → Fix Committed
status: Fix Committed → In Progress
Revision history for this message
Brian Aker (brianaker) wrote :

Fixed in trunk.

Changed in gearmand:
status: In Progress → Fix Committed
Brian Aker (brianaker)
Changed in gearmand:
status: Fix Committed → Fix Released
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.