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&word2=advertize) > 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? > int virNetServerAddService(virNetServerPtr srv, > - virNetServerServicePtr svc) > + virNetServerServicePtr svc, > + const char *mdnsEntryName ATTRIBUTE_UNUSED) > { > virNetServerLock(srv); > > if (VIR_EXPAND_N(srv->services, srv->nservices, 1) < 0) > goto no_memory; > > +#if HAVE_AVAHI > + if (mdnsEntryName) { Here's a counter-example where you check for NULL first, for comparison. Nothing else jumped out at me. -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list