On 06/22/2011 09:33 AM, Daniel P. Berrange wrote:
> Allow RPC servers to advertize themselves using MDNS,
s/advertize/advertise/ (also in subject line)
(Yes, both spellings are valid, but advertise is by far the more
prevalent, per
http://www.googlefight.com/index.php?lang=en_GB&word1=advertise&w...)
> via Avahi
>
> * src/rpc/virnetserver.c, src/rpc/virnetserver.h: Allow
> registration of MDNS services via avahi
> * src/rpc/virnetserverservice.c, src/rpc/virnetserverservice.h: Add
> API to fetch the listen port number
> * src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add API to
> fetch the local port number
> * src/rpc/virnetservermdns.c, src/rpc/virnetservermdns.h: Represent
> an MDNS advertisement
> ---
> cfg.mk | 3 +
> po/POTFILES.in | 1 +
> src/Makefile.am | 9 +
> src/rpc/virnetserver.c | 47 +++-
> src/rpc/virnetserver.h | 4 +-
> src/rpc/virnetservermdns.c | 614 +++++++++++++++++++++++++++++++++++++++++
> src/rpc/virnetservermdns.h | 109 ++++++++
> src/rpc/virnetserverservice.c | 8 +
> src/rpc/virnetserverservice.h | 2 +
> src/rpc/virnetsocket.c | 6 +
> src/rpc/virnetsocket.h | 2 +
> 11 files changed, 803 insertions(+), 2 deletions(-)
> create mode 100644 src/rpc/virnetservermdns.c
> create mode 100644 src/rpc/virnetservermdns.h
>
> @@ -281,6 +291,19 @@ virNetServerPtr virNetServerNew(size_t min_workers,
> srv->clientInitHook = clientInitHook;
> srv->privileged = geteuid() == 0 ? true : false;
>
> + if (!(srv->mdnsGroupName = strdup(mdnsGroupName))) {
> + virReportOOMError();
> + goto error;
> + }
> +#if HAVE_AVAHI
> + if (srv->mdnsGroupName) {
This conditional is always true, given the fact that you previously
jumped to error if strdup failed. Is that intentional? Or can
mdnsGroupName be NULL on entry, in which case you need to check for NULL
before blindly calling strdup?
Yes, the strdup should have been optional if mdnsGroupName was
NULL on entry.
Daniel
--
|: