akhilravidas / distcc

Automatically exported from code.google.com/p/distcc
GNU General Public License v2.0
0 stars 0 forks source link

Remove duplicate hosts from zeroconf list #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
(Originally posted as a comment in issue 34, but I thought that might get
lost, since the issue is closed.)

When using zeroconf/avahi, hosts with multiple IP addresses (e.g. either
IPv4+IPv6 or wired+wireless) show up more than once.  The attached patch
filters the duplicates out by service name.

For example, on my machine:

$ avahi-browse -t _distcc._tcp
+ wlan IPv6 distcc@averatec
+ wlan IPv4 distcc@averatec
+ wired IPv6 distcc@averatec
+ wired IPv4 distcc@acerlin
+ wired IPv4 distcc@averatec

$ export DISTCC_HOSTS=+zeroconf

Without the patch, I get:

$ distcc --show-hosts
[fe80::221:85ff:fe7b:6468]:3632/8
192.168.1.114:3632/8
[fe80::221:85ff:fe4a:4151]:3632/8
192.168.2.17:3632/8
192.168.2.23:3632/4

After the patch, the 'distcc@averatec' entries are collapsed into one:

$ distcc --show-hosts
192.168.2.17:3632/8
192.168.2.23:3632/4

Patch is against svn@662.

-- Ben

Original issue reported on code.google.com by benizi on 8 Apr 2009 at 5:14

Attachments:

GoogleCodeExporter commented 9 years ago
The code has a bug; it can access b->host after calling free_host(b).

Some more comments for the new function would help, e.g. explaining why.  (The 
bug
description is clear enough, but the code should have a similar explanation 
too. 
Future maintainers will be looking at the code, not at the bug description.)

Also, I would prefer more descriptive variable names, e.g. host1, host2, prev 
rather
than a, b, p.

Otherwise, this looks fine.

Original comment by fergus.h...@gmail.com on 8 Apr 2009 at 5:31

GoogleCodeExporter commented 9 years ago
*slaps forehead*.  Yep, missed that bug.

I took the hint for variable names from remove_service (which uses 'h' and 
'p'). 
Changed to host1, host2, and prev.

Original comment by benizi on 8 Apr 2009 at 6:29

Attachments:

GoogleCodeExporter commented 9 years ago
Looks good to me now, thanks!

Do you want to go and and commit it?
I've made you a member of the "distcc" project, so you should have the right
permissions now.

(Please run "make check" first.)

Original comment by fergus.h...@gmail.com on 8 Apr 2009 at 6:54

GoogleCodeExporter commented 9 years ago
Fixed in SVN revision 673.  Thanks!

Original comment by fergus.h...@gmail.com on 14 Apr 2009 at 8:33