+static void http_fire_observers(struct http_channel *c)
+{
+ http_channel_observer_t p = c->observers;
+ while (p)
+ {
+ p->destroy(p->data, c);
+ p = p->next;
+ }
+}
+
+static void http_destroy_observers(struct http_channel *c)
+{
+ while (c->observers)
+ {
+ http_channel_observer_t obs = c->observers;
+ c->observers = obs->next;
+ xfree(obs);
+ }
+}
+
+http_channel_observer_t http_add_observer(struct http_channel *c, void *data,
+ http_channel_destroy_t des)
+{
+ http_channel_observer_t obs = xmalloc(sizeof(*obs));
+ obs->chan = c;
+ obs->data = data;
+ obs->destroy= des;
+ obs->next = c->observers;
+ c->observers = obs;
+ return obs;
+}
+
+void http_remove_observer(http_channel_observer_t obs)
+{
+ struct http_channel *c = obs->chan;
+ http_channel_observer_t found, *p = &c->observers;
+ while (*p != obs)
+ p = &(*p)->next;
+ found = *p;
+ assert(found);
+ *p = (*p)->next;
+ xfree(found);
+}
+
+struct http_channel *http_channel_observer_chan(http_channel_observer_t obs)
+{
+ return obs->chan;
+}
+