func (t *connTable) handleUpdate(update *connUpdate) { log.Debug("Update received in connTable %p for address %s", t, update.addr) watcher, entry_exists := t.conns[update.addr] if !entry_exists { log.Debug("No connection watcher registered for %s; spawn one", update.addr) watcher = &connWatcher{update.addr, update.conn, timing.NewTimer(c_SOCKET_EXPIRY), timing.Now().Add(c_SOCKET_EXPIRY), t.expiries, make(chan bool)} t.conns[update.addr] = watcher go watcher.loop() } watcher.Update(update.conn) }
// Update the connection associated with a given connWatcher, and reset the // timeout timer. // Must only be called from the connTable goroutine (and in particular, must // *not* be called from the connWatcher goroutine). func (watcher *connWatcher) Update(c *connection) { watcher.expiryTime = timing.Now().Add(c_SOCKET_EXPIRY) watcher.timer.Reset(c_SOCKET_EXPIRY) watcher.conn = c }