Remove "my_ev_init" as we now have -fno-strict-aliasing; workaround was stupid anyway. Move static ev_signal vars into server struct.

personal/stbuehler/wip
Stefan Bühler 14 years ago
parent 90e566be80
commit ecd1082378
  1. 8
      src/base.h
  2. 4
      src/connection.c
  3. 17
      src/server.c
  4. 6
      src/server.h

@ -8,14 +8,6 @@
#define GSTR_LEN(x) (x) ? (x)->str : "", (x) ? (x)->len : 0
#define GSTR_SAFE_STR(x) ((x && x->str) ? x->str : "(null)")
/* we don't use ev_init for now (stupid alias warnings), as ev_init
* just does set some values to zero and calls ev_set_cb.
* But every structure we allacote is initialized with zero, so we don't care
* about that.
* If this ever changes, we can easily use ev_init again.
*/
#define my_ev_init(ev, cb) ev_set_cb(ev, cb)
typedef enum {
HTTP_TRANSFER_ENCODING_IDENTITY,
HTTP_TRANSFER_ENCODING_CHUNKED

@ -144,7 +144,7 @@ connection* connection_new(server *srv) {
con->response_headers_sent = FALSE;
con->expect_100_cont = FALSE;
my_ev_init(&con->sock.watcher, connection_cb);
ev_init(&con->sock.watcher, connection_cb);
ev_io_set(&con->sock.watcher, -1, 0);
con->sock.srv = srv; con->sock.con = con; con->sock.watcher.data = &con->sock;
con->remote_addr_str = g_string_sized_new(0);
@ -167,7 +167,7 @@ connection* connection_new(server *srv) {
con->keep_alive_data.link = NULL;
con->keep_alive_data.timeout = 0;
con->keep_alive_data.max_idle = 0;
my_ev_init(&con->keep_alive_data.watcher, connection_keepalive_cb);
ev_init(&con->keep_alive_data.watcher, connection_keepalive_cb);
con->keep_alive_data.watcher.data = con;
return con;

@ -55,11 +55,6 @@ static void server_setup_free(gpointer _ss) {
g_slice_free(server_setup, _ss);
}
static struct ev_signal
sig_w_INT,
sig_w_TERM,
sig_w_PIPE;
static void sigint_cb(struct ev_loop *loop, struct ev_signal *w, int revents) {
server *srv = (server*) w->data;
UNUSED(revents);
@ -79,10 +74,10 @@ static void sigpipe_cb(struct ev_loop *loop, struct ev_signal *w, int revents) {
}
#define CATCH_SIGNAL(loop, cb, n) do {\
my_ev_init(&sig_w_##n, cb); \
ev_signal_set(&sig_w_##n, SIG##n); \
ev_signal_start(loop, &sig_w_##n); \
sig_w_##n.data = srv; \
ev_init(&srv->sig_w_##n, cb); \
ev_signal_set(&srv->sig_w_##n, SIG##n); \
ev_signal_start(loop, &srv->sig_w_##n); \
srv->sig_w_##n.data = srv; \
ev_unref(loop); /* Signal watchers shouldn't keep loop alive */ \
} while (0)
@ -158,7 +153,7 @@ server* server_new() {
log_init(srv);
g_queue_init(&srv->keep_alive_queue);
my_ev_init(&srv->keep_alive_timer, server_keepalive_cb);
ev_init(&srv->keep_alive_timer, server_keepalive_cb);
srv->keep_alive_timer.data = srv;
return srv;
@ -325,7 +320,7 @@ void server_listen(server *srv, int fd) {
sock->srv = srv;
sock->watcher.data = sock;
fd_init(fd);
my_ev_init(&sock->watcher, server_listen_cb);
ev_init(&sock->watcher, server_listen_cb);
ev_io_set(&sock->watcher, fd, EV_READ);
if (srv->state == SERVER_RUNNING) ev_io_start(srv->loop, &sock->watcher);

@ -40,6 +40,12 @@ struct server {
guint loop_flags;
struct ev_loop *loop;
ev_timer keep_alive_timer;
ev_signal
sig_w_INT,
sig_w_TERM,
sig_w_PIPE;
ev_prepare srv_prepare;
ev_check srv_check;
guint connections_active; /** 0..con_act-1: active connections, con_act..used-1: free connections */
GArray *connections; /** array of (connection*) */

Loading…
Cancel
Save