Ticket #40 (closed enhancement: fixed)

Opened 7 years ago

Last modified 4 years ago

host name number incrementing on collision

Reported by: chris Owned by: lennart
Milestone: Avahi 0.6.13 Component: avahi-client
Keywords: Cc:

Description

We've been testing Avahi on a few of our products and have a little problem when we have multiple devices with the same host name on the same network segement.

The device host names are set to their product IDs, which all happen to end in a zero. When we have two or more on the same network, Avahi correctly detects the name is already taken and starts appending incremental numbers to the hostname. Unfortunately, that turns a host name like B000 into B001.

Would it be possible to change this action so a hyphen is added first, and then the incremental numbering? Apple uses this in their explaination of Naming in the Bonjour Overview PDF.

Thanks.

Attachments

name_collision_no_seperator.patch Download (0.6 KB) - added by anonymous 7 years ago.

Change History

Changed 7 years ago by sebest

  • milestone set to Avahi 0.6.11

Yes, it would be possible, and really easy to implement.

Making it configurable in daemon.conf collision_separator="-"

it would default to "", to keep the current behaviour.

Would you submit a patch that implement this functionnality?

Changed 7 years ago by chris

Thanks for the response.

Isn't it a pretty minor thing to put in the daemon conf file? It's not like anything should depend on this action, so I wonder if it's really necessary to keep the default behaviour?

I had a quick look at the code... avahi_alternative_host_name() is defined in avahi-common (used by both daemon and core), so would it really be possible to have that reference the daemon conf file?

Changed 7 years ago by anonymous

Changed 7 years ago by chris

That super simple patch I just attached gets the behavior I want, but will break down if the first default hostname has a pattern of something like abc-000 to begin with.

As avahi_alternative_host_name() can be called repetitively, it might need a decent reworking to always compare against the original hostname.

Changed 7 years ago by sebest

  • priority changed from major to minor

hello chris,

and thanx for the patch, we'll review this issue and see if it will be fixed in the next release.

do you really need this functionnality built-in avahi or could you rely on your patch?

Changed 7 years ago by lennart

Hmm, I don't consider this a real bug. Anyway, since this caused trouble for you and Bonjour seems to have a different behaviour here, I'd be willing to follow their lead.

I assume you meant this file with "Bonjour Overview PDF", right?

 http://developer.apple.com/documentation/Cocoa/Conceptual/NetServices/NetServices.pdf

Am I blind? I don't see where they suggest the "-2" scheme for host names. (For service names yes - but for host names?)

BTW, your patch has a flaw: it breaks the function when an empty string is passed! (But don't bother, I can fix that ;-))

Changed 7 years ago by anonymous

Hmm, I don't consider this a real bug. Anyway, since this caused trouble for you and Bonjour seems to have a different behaviour here, I'd be willing to follow their lead.

I wouldn't have necessarily called it bug either, but I think appending the number would be better behavior than modifying the original hostname.

Am I blind? I don't see where they suggest the "-2" scheme for host names. (For service names yes - but for host names?)

Near the top of page 13, in the 'Naming' section. Of course its just an example, not an implementation recommendation.

BTW, your patch has a flaw: it breaks the function when an empty string is passed! (But don't bother, I can fix that ;-))

I'm actually still pretty new to programming, so I have a feeling I'm going to get shot down here... but I can't see where it breaks? In the original, I think a '\0' string would result in a "2" returned, after my patch it'll be "-2"... both not very useful. Looking forward to your fix anyway :-)

Changed 7 years ago by chris

Just checked on my mac at home... it does append a hyphen first.

Oh... and it seems my patch does cause a nice segmentation fault... sorry about that.

Changed 7 years ago by lennart

  • status changed from new to assigned
  • milestone changed from Avahi 0.6.11 to Avahi 0.6.12

Changed 7 years ago by lennart

  • milestone changed from Avahi 0.6.12 to Avahi 0.6.13

Changed 7 years ago by lennart

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

(In [1250]) follow Bonjour's hostname number incrementing algorithm for handling conflicts. On collision the name "foobar" will now become "foobar-2" and not "foobar2". (closes #40)

Note: See TracTickets for help on using tickets.