Make unix work again

This commit is contained in:
Ryan Dahl 2011-03-31 09:02:07 -07:00
parent 3b0175c135
commit e5d9ef954d
3 changed files with 16 additions and 8 deletions

View File

@ -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));
}

View File

@ -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;

2
ol.h
View File

@ -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: