+void http_observer_set_data2(http_channel_observer_t obs, void *data2)
+{
+ obs->data2 = data2;
+}
+
+http_server_t http_server_create(void)
+{
+ http_server_t hs = xmalloc(sizeof(*hs));
+ hs->mutex = 0;
+ hs->proxy_addr = 0;
+ hs->ref_count = 1;
+ hs->http_buf_freelist = 0;
+ hs->http_channel_freelist = 0;
+ hs->http_sessions = 0;
+ return hs;
+}
+
+void http_server_destroy(http_server_t hs)
+{
+ if (hs)
+ {
+ int r;
+
+ yaz_mutex_enter(hs->mutex); /* OK: hs->mutex may be NULL */
+ r = --(hs->ref_count);
+ yaz_mutex_leave(hs->mutex);
+
+ if (r == 0)
+ {
+ struct http_buf *b = hs->http_buf_freelist;
+ struct http_channel *c = hs->http_channel_freelist;
+ while (b)
+ {
+ struct http_buf *b_next = b->next;
+ xfree(b);
+ b = b_next;
+ }
+ while (c)
+ {
+ struct http_channel *c_next = c->next;
+ nmem_destroy(c->nmem);
+ wrbuf_destroy(c->wrbuf);
+ xfree(c);
+ c = c_next;
+ }
+ http_sessions_destroy(hs->http_sessions);
+ xfree(hs->proxy_addr);
+ yaz_mutex_destroy(&hs->mutex);
+ xfree(hs);
+ }
+ }
+}
+
+void http_server_incref(http_server_t hs)
+{
+ assert(hs);
+ yaz_mutex_enter(hs->mutex);
+ (hs->ref_count)++;
+ yaz_mutex_leave(hs->mutex);
+}
+
+void http_mutex_init(struct conf_server *server)
+{
+ assert(server);
+
+ assert(server->http_server->mutex == 0);
+ pazpar2_mutex_create(&server->http_server->mutex, "http_server");
+ server->http_server->http_sessions = http_sessions_create();
+}
+