static void proxy_io(IOCHAN i, int event);
-static struct http_channel *http_create(http_server_t http_server,
- const char *addr,
- struct conf_server *server);
+static struct http_channel *http_channel_create(http_server_t http_server,
+ const char *addr,
+ struct conf_server *server);
static void http_destroy(IOCHAN i);
static http_server_t http_server_create(void);
static void http_server_incref(http_server_t hs);
YAZ_MUTEX mutex;
int listener_socket;
int ref_count;
+ http_sessions_t http_sessions;
struct sockaddr_in *proxy_addr;
};
iochan_destroy(i);
}
-static struct http_channel *http_create(http_server_t hs,
- const char *addr,
- struct conf_server *server)
+static struct http_channel *http_channel_create(http_server_t hs,
+ const char *addr,
+ struct conf_server *server)
{
struct http_channel *r;
}
http_server_incref(hs);
r->http_server = hs;
+ r->http_sessions = hs->http_sessions;
r->server = server;
r->proxy = 0;
r->iochan = 0;
yaz_log(YLOG_DEBUG, "New command connection");
c = iochan_create(s, http_io, EVENT_INPUT | EVENT_EXCEPT);
- ch = http_create(server->http_server, inet_ntoa(addr.sin_addr), server);
+ ch = http_channel_create(server->http_server, inet_ntoa(addr.sin_addr),
+ server);
ch->iochan = c;
iochan_setdata(c, ch);
hs->ref_count = 1;
hs->http_buf_freelist = 0;
hs->http_channel_freelist = 0;
+ hs->http_sessions = 0;
return hs;
}
xfree(c);
c = c_next;
}
+ http_sessions_destroy(hs->http_sessions);
xfree(hs->proxy_addr);
yaz_mutex_destroy(&hs->mutex);
xfree(hs);
assert(server->http_server->mutex == 0);
yaz_mutex_create(&server->http_server->mutex);
+ server->http_server->http_sessions = http_sessions_create();
}
/*
typedef struct http_channel_observer_s *http_channel_observer_t;
typedef struct http_server *http_server_t;
+typedef struct http_sessions *http_sessions_t;
struct http_channel
{
http_channel_observer_t observers;
struct conf_server *server;
http_server_t http_server;
+ http_sessions_t http_sessions;
};
struct http_proxy // attached to iochan for proxy connection
void http_command(struct http_channel *c);
+http_sessions_t http_sessions_create(void);
+void http_sessions_destroy(http_sessions_t hs);
+
#endif
/*
static struct http_session *session_list = 0; /* thread pr */
+
+struct http_sessions {
+ struct http_session *session_list;
+ YAZ_MUTEX mutex;
+};
+
+http_sessions_t http_sessions_create(void)
+{
+ http_sessions_t hs = xmalloc(sizeof(*hs));
+ hs->session_list = 0;
+ yaz_mutex_create(&hs->mutex);
+ return hs;
+}
+
+void http_sessions_destroy(http_sessions_t hs)
+{
+ if (hs)
+ {
+ yaz_mutex_destroy(&hs->mutex);
+ /* should remove session_list too */
+ xfree(hs);
+ }
+}
+
void http_session_destroy(struct http_session *s);
static void session_timeout(IOCHAN i, int event)