diff --git a/ol-unix.c b/ol-unix.c index 1dc83cba..6c4da65e 100644 --- a/ol-unix.c +++ b/ol-unix.c @@ -261,7 +261,7 @@ void ol__read(ol_handle* handle) { } else { ol_err err = ol_err_new(handle, errno); if (cb) { - cb(req, 0, err); + cb(req, 0); } ol_close_error(handle, errno); } @@ -280,7 +280,7 @@ void ol__read(ol_handle* handle) { /* NOTE: call callback AFTER freeing the request data. */ if (cb) { - cb(req, nread, 0); + cb(req, nread); } if (ol_read_reqs_empty(handle)) { @@ -366,7 +366,8 @@ ol_req* ol_req_maybe_alloc(ol_handle* handle, ol_req* in_req) { in_req->_.local = 0; return in_req; } else { - ol_req *req = calloc(sizeof(ol_req), 1); + ol_req *req = malloc(sizeof(ol_req)); + ol_req_init(req, NULL); req->handle = handle; ngx_queue_init(&(req->_.read_reqs)); req->_.local = 1; @@ -431,7 +432,7 @@ int ol_write(ol_handle* handle, ol_req *req, ol_buf* bufs, int bufcnt) { } else { if (req && req->cb) { ol_write_cb cb = req->cb; - cb(req, 0); + cb(req); } return 0; } @@ -464,7 +465,7 @@ int ol_read(ol_handle* handle, ol_req *req_in, ol_buf* bufs, int bufcnt) { ol_err err = ol_err_new(handle, errno); if (cb) { - cb(req_in, nread, err); + cb(req_in, nread); } return err; @@ -473,7 +474,7 @@ int ol_read(ol_handle* handle, ol_req *req_in, ol_buf* bufs, int bufcnt) { if (nread >= 0) { /* Successful read. */ if (cb) { - cb(req_in, nread, 0); + cb(req_in, nread); } return 0; } @@ -517,3 +518,10 @@ void ol_free(ol_handle* handle) { /* lists? */ return; } + + +void ol_req_init(ol_req *req, void *cb) { + req->type = OL_UNKNOWN_REQ; + req->cb = cb; + ngx_queue_init(&(req->_.read_reqs)); +} diff --git a/ol-unix.h b/ol-unix.h index 0f646462..e98edd3f 100644 --- a/ol-unix.h +++ b/ol-unix.h @@ -23,7 +23,7 @@ typedef struct { typedef struct { int local; - ol_req_cb connect_cb; + ol_connect_cb connect_cb; ngx_queue_t read_reqs; ol_buf* read_bufs; int read_bufcnt; diff --git a/ol.h b/ol.h index d9348341..bc593cbd 100644 --- a/ol.h +++ b/ol.h @@ -80,7 +80,7 @@ const char* ol_err_str(ol_err err); void ol_init(); int ol_run(); -void ol_req_init(ol_req *req, void *cb); +void ol_req_init(ol_req* req, void* cb); ol_handle* ol_tcp_handle_new(ol_close_cb close_cb, void* data); /* TODO: