third_party/mdns: fix a data race

  Fix a data race on accessing 'host' field.

  (I'll add README.google once p@ updates his package to match this.)

Change-Id: I6fee111d13124207a1963dca3f30071c7be49812
diff --git a/go/src/github.com/presotto/go-mdns-sd/mdns.go b/go/src/github.com/presotto/go-mdns-sd/mdns.go
index daf492d..9f65d65 100644
--- a/go/src/github.com/presotto/go-mdns-sd/mdns.go
+++ b/go/src/github.com/presotto/go-mdns-sd/mdns.go
@@ -206,6 +206,10 @@
 	host    string
 }
 
+type updateRequest struct {
+	host string
+}
+
 type watchedService struct {
 	c   *sync.Cond
 	gen int
@@ -230,6 +234,7 @@
 	announce     chan announceRequest
 	goodbye      chan goodbyeRequest
 	lookup       chan lookupRequest
+	update       chan updateRequest
 	refreshAlarm chan struct{}
 	cleanupAlarm chan struct{}
 
@@ -328,6 +333,7 @@
 	s.announce = make(chan announceRequest)
 	s.goodbye = make(chan goodbyeRequest)
 	s.lookup = make(chan lookupRequest)
+	s.update = make(chan updateRequest)
 	s.refreshAlarm = make(chan struct{})
 	s.cleanupAlarm = make(chan struct{})
 
@@ -357,12 +363,11 @@
 			s.Stop()
 			return nil, errors.New("host name in use")
 		}
-		s.hostName = host
-		s.hostFQDN = hostFQDN(host)
+		s.update <- updateRequest{host}
 	}
 
 	// Announce ourselves if the host name is set.
-	if len(s.hostName) > 0 {
+	if len(host) > 0 {
 		s.refreshAlarm <- struct{}{}
 	}
 
@@ -706,6 +711,9 @@
 				mifc.cache.Lookup(req.name, req.rrtype, req.rc)
 			}
 			close(req.rc)
+		case req := <-s.update:
+			s.hostName = req.host
+			s.hostFQDN = hostFQDN(req.host)
 		case <-s.refreshAlarm:
 			// Reannounce all services.  We need to do this before the TTLs run out.  As a side
 			// effect this reannounces the host address RRs.