Fix some bugs/warnings.

personal/stbuehler/wip
Stefan Bühler 15 years ago
parent 1f0b3ac991
commit 8de2c27ec6
  1. 8
      src/base.h
  2. 8
      src/condition_parsers.rl
  3. 3
      src/connection.c
  4. 2
      src/network.c
  5. 1
      src/request.c
  6. 8
      src/server.c

@ -7,6 +7,14 @@
#define GSTR_LEN(x) (x) ? (x)->str : "", (x) ? (x)->len : 0
/* 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

@ -28,9 +28,9 @@
gboolean parse_ipv4(const char *str, guint32 *ip, guint32 *netmask) {
guint8 *data = (guint8*) ip;
const char *p = str, *mark;
const char *p = str, *mark = NULL;
gboolean res = FALSE;
int cs, tmpval, i = 0;
int cs, tmpval = 0, i = 0;
%% write init nocs;
@ -92,9 +92,9 @@ gboolean parse_ipv6(const char *str, guint8 *ip, guint *network) {
guint8 data[4] = {0,0,0,0};
guint16 *predata = (guint16*) ip, postdata[8];
size_t prec = 0, postc = 0;
const char *p = str, *mark;
const char *p = str, *mark = NULL;
gboolean res = FALSE, compressed = FALSE;
int cs, tmpval, i = 0;
int cs, tmpval = 0, i = 0;
%% write init nocs;

@ -139,7 +139,8 @@ connection* connection_new(server *srv) {
con->response_headers_sent = FALSE;
con->expect_100_cont = FALSE;
ev_io_init(&con->sock.watcher, connection_cb, -1, 0);
my_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);
con->local_addr_str = g_string_sized_new(0);

@ -51,7 +51,7 @@ network_status_t network_write(server *srv, connection *con, int fd, chunkqueue
case ECONNRESET:
return NETWORK_STATUS_CONNECTION_CLOSE;
default:
CON_ERROR(srv, con, "oops, read from fd=%d failed: %s (%d)", fd, strerror(errno), errno );
CON_ERROR(srv, con, "oops, write to fd=%d failed: %s (%d)", fd, strerror(errno), errno );
return NETWORK_STATUS_FATAL_ERROR;
}
} else if (0 == r) {

@ -70,6 +70,7 @@ static void bad_request(server *srv, connection *con, int status) {
gboolean request_parse_url(server *srv, connection *con) {
request *req = &con->request;
UNUSED(srv); UNUSED(req);
/* TODO: parse url */
return TRUE;

@ -23,7 +23,7 @@ static void server_closing_socket_cb(int revents, void* arg) {
}
void server_add_closing_socket(server *srv, int fd) {
server_closing_socket *scs = g_slice_new(server_closing_socket);
server_closing_socket *scs = g_slice_new0(server_closing_socket);
shutdown(fd, SHUT_WR);
@ -222,7 +222,8 @@ void server_listen(server *srv, int fd) {
sock->srv = srv;
sock->watcher.data = sock;
fd_init(fd);
ev_io_init(&sock->watcher, server_listen_cb, fd, EV_READ);
my_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);
g_array_append_val(srv->sockets, sock);
@ -245,7 +246,8 @@ static struct ev_signal
sig_w_PIPE;
#define CATCH_SIGNAL(loop, cb, n) do {\
ev_signal_init(&sig_w_##n, cb, SIG##n); \
my_ev_init(&sig_w_##n, cb); \
ev_signal_set(&sig_w_##n, SIG##n); \
ev_signal_start(loop, &sig_w_##n); \
} while (0)

Loading…
Cancel
Save