Ticket #65 (closed enhancement: fixed)

Opened 5 years ago

Last modified 5 years ago

API documentation for avahi_client_new

Reported by: jkyro Owned by: lennart
Milestone: Avahi 0.6.17 Component: docs
Keywords: Cc:

Description

The API documentation doesn't tell that the avahi_client_new function also calls the callback provided as parameter.

The expression is "whenever the client state changes", but there's no mention about the creation of the client itself generating a state change that gets handled before the function actually returns. This has the implication that the value stored from avahi_client_new can't be used in the callback.

In my opinion, I'm not expecting the callback to be called until entering the event loop unless stated otherwise.

Example:

static AvahiClient *global_client = NULL;



void my_client_callbcak( AvahiClient *client, AvahiClientState s, void *userdata)
{
    //global_client is NULL the first time this function is called
    ...
}

int main() 
{
    global_client = avahi_client_new(); 

}

Change History

Changed 5 years ago by lathiat

As a point, given the client is passed in with the callback anyway (as the first argument 'client')

You shouldn't be using the global value anyway

Changed 5 years ago by jkyro

Yes, I agree. But I still think the documentation should be more explicit here.

Changed 5 years ago by lathiat

  • owner changed from lennart to lathiat
  • status changed from new to assigned
  • type changed from defect to enhancement
  • milestone set to Avahi 0.7

Yep, you're 100% correct.

Changed 5 years ago by lathiat

This should also be reflected in the entry_group_new code, as we even made this mistake ourselves (Bug #79)

Changed 5 years ago by lennart

  • owner changed from lathiat to lennart
  • status changed from assigned to new
  • milestone changed from Avahi 0.7 to Avahi 0.6.17

Changed 5 years ago by lennart

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

(In [1359]) Fix documentation of avahi_{entry_group|client}_new(): clarify that the specified callback function is called for the first time from withing the avahi_xxx_new() context. (Closes #65)

Note: See TracTickets for help on using tickets.