+int handle_goodbye(char *buf, int l, uint32_t addr)
+{
+ int i;
+ slave *s;
+
+ // Is this a slave we have state information for?
+ if ((s = find_slave(addr)))
+ {
+ log(0, "Received goodbye for slave %s\n", s->hostname);
+ ll_delete(slaves, s);
+ for (i = 0; i < s->num_tunnels; i++)
+ if (s->tunnels[i]) free(s->tunnels[i]);
+ for (i = 0; i < s->num_sessions; i++)
+ if (s->sessions[i]) free(s->sessions[i]);
+ if (s->hostname) free(s->hostname);
+ free(s);
+ }
+
+ return 0;
+}
+