uv_buf -> uv_buf_t
This commit is contained in:
parent
c6edabdba8
commit
2b8812ffe1
@ -39,7 +39,7 @@ typedef struct {
|
|||||||
} pinger_t;
|
} pinger_t;
|
||||||
|
|
||||||
typedef struct buf_s {
|
typedef struct buf_s {
|
||||||
uv_buf uv_buf;
|
uv_buf_t uv_buf_t;
|
||||||
struct buf_s* next;
|
struct buf_s* next;
|
||||||
} buf_t;
|
} buf_t;
|
||||||
|
|
||||||
@ -52,26 +52,26 @@ static int completed_pingers = 0;
|
|||||||
static int64_t start_time;
|
static int64_t start_time;
|
||||||
|
|
||||||
|
|
||||||
static uv_buf buf_alloc(uv_handle_t* handle, size_t size) {
|
static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) {
|
||||||
buf_t* ab;
|
buf_t* ab;
|
||||||
|
|
||||||
ab = buf_freelist;
|
ab = buf_freelist;
|
||||||
|
|
||||||
if (ab != NULL) {
|
if (ab != NULL) {
|
||||||
buf_freelist = ab->next;
|
buf_freelist = ab->next;
|
||||||
return ab->uv_buf;
|
return ab->uv_buf_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
ab = (buf_t*) malloc(size + sizeof *ab);
|
ab = (buf_t*) malloc(size + sizeof *ab);
|
||||||
ab->uv_buf.len = size;
|
ab->uv_buf_t.len = size;
|
||||||
ab->uv_buf.base = ((char*) ab) + sizeof *ab;
|
ab->uv_buf_t.base = ((char*) ab) + sizeof *ab;
|
||||||
|
|
||||||
return ab->uv_buf;
|
return ab->uv_buf_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void buf_free(uv_buf uv_buf) {
|
static void buf_free(uv_buf_t uv_buf_t) {
|
||||||
buf_t* ab = (buf_t*) (uv_buf.base - sizeof *ab);
|
buf_t* ab = (buf_t*) (uv_buf_t.base - sizeof *ab);
|
||||||
|
|
||||||
ab->next = buf_freelist;
|
ab->next = buf_freelist;
|
||||||
buf_freelist = ab;
|
buf_freelist = ab;
|
||||||
@ -101,7 +101,7 @@ static void pinger_write_cb(uv_req_t *req, int status) {
|
|||||||
|
|
||||||
static void pinger_write_ping(pinger_t* pinger) {
|
static void pinger_write_ping(pinger_t* pinger) {
|
||||||
uv_req_t *req;
|
uv_req_t *req;
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
|
|
||||||
buf.base = (char*)&PING;
|
buf.base = (char*)&PING;
|
||||||
buf.len = strlen(PING);
|
buf.len = strlen(PING);
|
||||||
@ -120,7 +120,7 @@ static void pinger_shutdown_cb(uv_handle_t* handle, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
|
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
pinger_t* pinger;
|
pinger_t* pinger;
|
||||||
|
|
||||||
|
|||||||
@ -41,8 +41,8 @@ static void maybe_connect_some();
|
|||||||
static uv_req_t* req_alloc();
|
static uv_req_t* req_alloc();
|
||||||
static void req_free(uv_req_t* uv_req);
|
static void req_free(uv_req_t* uv_req);
|
||||||
|
|
||||||
static uv_buf buf_alloc(uv_handle_t* handle, size_t size);
|
static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size);
|
||||||
static void buf_free(uv_buf uv_buf);
|
static void buf_free(uv_buf_t uv_buf_t);
|
||||||
|
|
||||||
|
|
||||||
static struct sockaddr_in server_addr;
|
static struct sockaddr_in server_addr;
|
||||||
@ -121,7 +121,7 @@ void close_cb(uv_handle_t* handle, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void read_cb(uv_handle_t* handle, int bytes, uv_buf buf) {
|
static void read_cb(uv_handle_t* handle, int bytes, uv_buf_t buf) {
|
||||||
ASSERT(bytes >= 0);
|
ASSERT(bytes >= 0);
|
||||||
|
|
||||||
buf_free(buf);
|
buf_free(buf);
|
||||||
@ -132,7 +132,7 @@ static void read_cb(uv_handle_t* handle, int bytes, uv_buf buf) {
|
|||||||
|
|
||||||
|
|
||||||
static void write_cb(uv_req_t *req, int status) {
|
static void write_cb(uv_req_t *req, int status) {
|
||||||
uv_buf* buf = (uv_buf*) req->data;
|
uv_buf_t* buf = (uv_buf_t*) req->data;
|
||||||
|
|
||||||
ASSERT(status == 0);
|
ASSERT(status == 0);
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ static void write_cb(uv_req_t *req, int status) {
|
|||||||
|
|
||||||
static void do_write(uv_handle_t* handle) {
|
static void do_write(uv_handle_t* handle) {
|
||||||
uv_req_t* req;
|
uv_req_t* req;
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
buf.base = (char*) &write_buffer;
|
buf.base = (char*) &write_buffer;
|
||||||
@ -298,7 +298,7 @@ static void req_free(uv_req_t* uv_req) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct buf_list_s {
|
typedef struct buf_list_s {
|
||||||
uv_buf uv_buf;
|
uv_buf_t uv_buf_t;
|
||||||
struct buf_list_s* next;
|
struct buf_list_s* next;
|
||||||
} buf_list_t;
|
} buf_list_t;
|
||||||
|
|
||||||
@ -306,25 +306,25 @@ typedef struct buf_list_s {
|
|||||||
static buf_list_t* buf_freelist = NULL;
|
static buf_list_t* buf_freelist = NULL;
|
||||||
|
|
||||||
|
|
||||||
static uv_buf buf_alloc(uv_handle_t* handle, size_t size) {
|
static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) {
|
||||||
buf_list_t* buf;
|
buf_list_t* buf;
|
||||||
|
|
||||||
buf = buf_freelist;
|
buf = buf_freelist;
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
buf_freelist = buf->next;
|
buf_freelist = buf->next;
|
||||||
return buf->uv_buf;
|
return buf->uv_buf_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = (buf_list_t*) malloc(size + sizeof *buf);
|
buf = (buf_list_t*) malloc(size + sizeof *buf);
|
||||||
buf->uv_buf.len = (unsigned int)size;
|
buf->uv_buf_t.len = (unsigned int)size;
|
||||||
buf->uv_buf.base = ((char*) buf) + sizeof *buf;
|
buf->uv_buf_t.base = ((char*) buf) + sizeof *buf;
|
||||||
|
|
||||||
return buf->uv_buf;
|
return buf->uv_buf_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void buf_free(uv_buf uv_buf) {
|
static void buf_free(uv_buf_t uv_buf_t) {
|
||||||
buf_list_t* buf = (buf_list_t*) (uv_buf.base - sizeof *buf);
|
buf_list_t* buf = (buf_list_t*) (uv_buf_t.base - sizeof *buf);
|
||||||
|
|
||||||
buf->next = buf_freelist;
|
buf->next = buf_freelist;
|
||||||
buf_freelist = buf;
|
buf_freelist = buf;
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uv_req_t req;
|
uv_req_t req;
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
} write_req_t;
|
} write_req_t;
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ static uv_handle_t server;
|
|||||||
|
|
||||||
|
|
||||||
static void after_write(uv_req_t* req, int status);
|
static void after_write(uv_req_t* req, int status);
|
||||||
static void after_read(uv_handle_t* handle, int nread, uv_buf buf);
|
static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf);
|
||||||
static void on_close(uv_handle_t* peer, int status);
|
static void on_close(uv_handle_t* peer, int status);
|
||||||
static void on_accept(uv_handle_t* handle);
|
static void on_accept(uv_handle_t* handle);
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ static void after_shutdown(uv_req_t* req, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void after_read(uv_handle_t* handle, int nread, uv_buf buf) {
|
static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf) {
|
||||||
write_req_t *wr;
|
write_req_t *wr;
|
||||||
uv_req_t* req;
|
uv_req_t* req;
|
||||||
|
|
||||||
@ -156,8 +156,8 @@ static int echo_stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf echo_alloc(uv_handle_t* handle, size_t suggested_size) {
|
static uv_buf_t echo_alloc(uv_handle_t* handle, size_t suggested_size) {
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
buf.base = (char*) malloc(suggested_size);
|
buf.base = (char*) malloc(suggested_size);
|
||||||
buf.len = suggested_size;
|
buf.len = suggested_size;
|
||||||
return buf;
|
return buf;
|
||||||
|
|||||||
@ -120,8 +120,8 @@ static void close_cb(uv_handle_t* handle, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf = {0, 0};
|
uv_buf_t buf = {0, 0};
|
||||||
FATAL("alloc should not be called");
|
FATAL("alloc should not be called");
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,8 +36,8 @@ static void close_cb(uv_handle_t* handle, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf = {0, 0};
|
uv_buf_t buf = {0, 0};
|
||||||
FATAL("alloc should not be called");
|
FATAL("alloc should not be called");
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,7 +58,7 @@ static void shutdown_cb(uv_req_t* req, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
|
static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
|
||||||
ASSERT(nested == 0 && "read_cb must be called from a fresh stack");
|
ASSERT(nested == 0 && "read_cb must be called from a fresh stack");
|
||||||
|
|
||||||
printf("Read. nread == %d\n", nread);
|
printf("Read. nread == %d\n", nread);
|
||||||
@ -138,7 +138,7 @@ static void write_cb(uv_req_t* req, int status) {
|
|||||||
|
|
||||||
|
|
||||||
static void connect_cb(uv_req_t* req, int status) {
|
static void connect_cb(uv_req_t* req, int status) {
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
|
|
||||||
puts("Connected. Write some data to echo server...");
|
puts("Connected. Write some data to echo server...");
|
||||||
|
|
||||||
@ -162,8 +162,8 @@ static void connect_cb(uv_req_t* req, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
buf.len = size;
|
buf.len = size;
|
||||||
buf.base = (char*) malloc(size);
|
buf.base = (char*) malloc(size);
|
||||||
ASSERT(buf.base);
|
ASSERT(buf.base);
|
||||||
|
|||||||
@ -46,8 +46,8 @@ static void on_connect(uv_req_t *req, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf = {0, 0};
|
uv_buf_t buf = {0, 0};
|
||||||
FATAL("alloc should not be called");
|
FATAL("alloc should not be called");
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,7 @@ static void start_server() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
|
static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
|
||||||
/* The server will not send anything, it should close gracefully. */
|
/* The server will not send anything, it should close gracefully. */
|
||||||
ASSERT(handle != NULL);
|
ASSERT(handle != NULL);
|
||||||
ASSERT(nread == -1);
|
ASSERT(nread == -1);
|
||||||
@ -151,8 +151,8 @@ static void client_connect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
buf.base = (char*)malloc(size);
|
buf.base = (char*)malloc(size);
|
||||||
buf.len = size;
|
buf.len = size;
|
||||||
return buf;
|
return buf;
|
||||||
|
|||||||
@ -313,8 +313,8 @@ static void prepare_1_close_cb(uv_handle_t* handle, int status){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf rv = { 0, 0 };
|
uv_buf_t rv = { 0, 0 };
|
||||||
FATAL("alloc_cb should never be called in this test");
|
FATAL("alloc_cb should never be called in this test");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,7 @@ static void pinger_after_write(uv_req_t *req, int status) {
|
|||||||
|
|
||||||
static void pinger_write_ping(pinger_t* pinger) {
|
static void pinger_write_ping(pinger_t* pinger) {
|
||||||
uv_req_t *req;
|
uv_req_t *req;
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
|
|
||||||
buf.base = (char*)&PING;
|
buf.base = (char*)&PING;
|
||||||
buf.len = strlen(PING);
|
buf.len = strlen(PING);
|
||||||
@ -85,7 +85,7 @@ static void pinger_write_ping(pinger_t* pinger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
|
static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
pinger_t* pinger;
|
pinger_t* pinger;
|
||||||
|
|
||||||
@ -156,8 +156,8 @@ static void pinger_new() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
buf.base = (char*)malloc(size);
|
buf.base = (char*)malloc(size);
|
||||||
buf.len = size;
|
buf.len = size;
|
||||||
return buf;
|
return buf;
|
||||||
|
|||||||
@ -72,7 +72,7 @@ static void shutdown_cb(uv_req_t* req, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
|
static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
|
||||||
ASSERT(handle != NULL);
|
ASSERT(handle != NULL);
|
||||||
|
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
@ -110,7 +110,7 @@ static void write_cb(uv_req_t* req, int status) {
|
|||||||
|
|
||||||
|
|
||||||
static void connect_cb(uv_req_t* req, int status) {
|
static void connect_cb(uv_req_t* req, int status) {
|
||||||
uv_buf send_bufs[CHUNKS_PER_WRITE];
|
uv_buf_t send_bufs[CHUNKS_PER_WRITE];
|
||||||
uv_handle_t* handle;
|
uv_handle_t* handle;
|
||||||
int i, j, r;
|
int i, j, r;
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ static void connect_cb(uv_req_t* req, int status) {
|
|||||||
ASSERT(req != NULL);
|
ASSERT(req != NULL);
|
||||||
|
|
||||||
uv_req_init(req, handle, write_cb);
|
uv_req_init(req, handle, write_cb);
|
||||||
r = uv_write(req, (uv_buf*)&send_bufs, CHUNKS_PER_WRITE);
|
r = uv_write(req, (uv_buf_t*)&send_bufs, CHUNKS_PER_WRITE);
|
||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +155,8 @@ static void connect_cb(uv_req_t* req, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
buf.base = (char*)malloc(size);
|
buf.base = (char*)malloc(size);
|
||||||
buf.len = size;
|
buf.len = size;
|
||||||
return buf;
|
return buf;
|
||||||
|
|||||||
@ -54,8 +54,8 @@ static void dummy_timeout_cb(uv_req_t *req, int64_t skew, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
|
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
|
||||||
uv_buf buf = {0, 0};
|
uv_buf_t buf = {0, 0};
|
||||||
FATAL("alloc should not be called");
|
FATAL("alloc should not be called");
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
18
uv-unix.c
18
uv-unix.c
@ -509,10 +509,10 @@ void uv__write(uv_handle_t* handle) {
|
|||||||
|
|
||||||
assert(req->handle == handle);
|
assert(req->handle == handle);
|
||||||
|
|
||||||
/* Cast to iovec. We had to have our own uv_buf instead of iovec
|
/* Cast to iovec. We had to have our own uv_buf_t instead of iovec
|
||||||
* because Windows's WSABUF is not an iovec.
|
* because Windows's WSABUF is not an iovec.
|
||||||
*/
|
*/
|
||||||
assert(sizeof(uv_buf) == sizeof(struct iovec));
|
assert(sizeof(uv_buf_t) == sizeof(struct iovec));
|
||||||
struct iovec* iov = (struct iovec*) &(req->bufs[req->write_index]);
|
struct iovec* iov = (struct iovec*) &(req->bufs[req->write_index]);
|
||||||
int iovcnt = req->bufcnt - req->write_index;
|
int iovcnt = req->bufcnt - req->write_index;
|
||||||
|
|
||||||
@ -541,7 +541,7 @@ void uv__write(uv_handle_t* handle) {
|
|||||||
|
|
||||||
/* The loop updates the counters. */
|
/* The loop updates the counters. */
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
uv_buf* buf = &(req->bufs[req->write_index]);
|
uv_buf_t* buf = &(req->bufs[req->write_index]);
|
||||||
size_t len = buf->len;
|
size_t len = buf->len;
|
||||||
|
|
||||||
assert(req->write_index < req->bufcnt);
|
assert(req->write_index < req->bufcnt);
|
||||||
@ -607,7 +607,7 @@ void uv__read(uv_handle_t* handle) {
|
|||||||
*/
|
*/
|
||||||
while (handle->read_cb && uv_flag_is_set(handle, UV_READING)) {
|
while (handle->read_cb && uv_flag_is_set(handle, UV_READING)) {
|
||||||
assert(alloc_cb);
|
assert(alloc_cb);
|
||||||
uv_buf buf = alloc_cb(handle, 64 * 1024);
|
uv_buf_t buf = alloc_cb(handle, 64 * 1024);
|
||||||
|
|
||||||
assert(buf.len > 0);
|
assert(buf.len > 0);
|
||||||
assert(buf.base);
|
assert(buf.base);
|
||||||
@ -813,7 +813,7 @@ int uv_connect(uv_req_t* req, struct sockaddr* addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static size_t uv__buf_count(uv_buf bufs[], int bufcnt) {
|
static size_t uv__buf_count(uv_buf_t bufs[], int bufcnt) {
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -826,9 +826,9 @@ static size_t uv__buf_count(uv_buf bufs[], int bufcnt) {
|
|||||||
|
|
||||||
|
|
||||||
/* The buffers to be written must remain valid until the callback is called.
|
/* The buffers to be written must remain valid until the callback is called.
|
||||||
* This is not required for the uv_buf array.
|
* This is not required for the uv_buf_t array.
|
||||||
*/
|
*/
|
||||||
int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) {
|
int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt) {
|
||||||
uv_handle_t* handle = req->handle;
|
uv_handle_t* handle = req->handle;
|
||||||
assert(handle->fd >= 0);
|
assert(handle->fd >= 0);
|
||||||
|
|
||||||
@ -836,8 +836,8 @@ int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) {
|
|||||||
req->type = UV_WRITE;
|
req->type = UV_WRITE;
|
||||||
|
|
||||||
/* TODO: Don't malloc for each write... */
|
/* TODO: Don't malloc for each write... */
|
||||||
req->bufs = malloc(sizeof(uv_buf) * bufcnt);
|
req->bufs = malloc(sizeof(uv_buf_t) * bufcnt);
|
||||||
memcpy(req->bufs, bufs, bufcnt * sizeof(uv_buf));
|
memcpy(req->bufs, bufs, bufcnt * sizeof(uv_buf_t));
|
||||||
req->bufcnt = bufcnt;
|
req->bufcnt = bufcnt;
|
||||||
|
|
||||||
req->write_index = 0;
|
req->write_index = 0;
|
||||||
|
|||||||
@ -35,14 +35,14 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char* base;
|
char* base;
|
||||||
size_t len;
|
size_t len;
|
||||||
} uv_buf;
|
} uv_buf_t;
|
||||||
|
|
||||||
|
|
||||||
#define uv_req_private_fields \
|
#define uv_req_private_fields \
|
||||||
int write_index; \
|
int write_index; \
|
||||||
ev_timer timer; \
|
ev_timer timer; \
|
||||||
ngx_queue_t queue; \
|
ngx_queue_t queue; \
|
||||||
uv_buf* bufs; \
|
uv_buf_t* bufs; \
|
||||||
int bufcnt;
|
int bufcnt;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
8
uv-win.c
8
uv-win.c
@ -751,7 +751,7 @@ static void uv_queue_accept(uv_handle_t* handle) {
|
|||||||
|
|
||||||
static void uv_queue_read(uv_handle_t* handle) {
|
static void uv_queue_read(uv_handle_t* handle) {
|
||||||
uv_req_t *req;
|
uv_req_t *req;
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
int result;
|
int result;
|
||||||
DWORD bytes, flags;
|
DWORD bytes, flags;
|
||||||
|
|
||||||
@ -926,7 +926,7 @@ int uv_connect(uv_req_t* req, struct sockaddr* addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static size_t uv_count_bufs(uv_buf bufs[], int count) {
|
static size_t uv_count_bufs(uv_buf_t bufs[], int count) {
|
||||||
size_t bytes = 0;
|
size_t bytes = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -938,7 +938,7 @@ static size_t uv_count_bufs(uv_buf bufs[], int count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt) {
|
int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt) {
|
||||||
int result;
|
int result;
|
||||||
DWORD bytes, err;
|
DWORD bytes, err;
|
||||||
uv_handle_t* handle = req->handle;
|
uv_handle_t* handle = req->handle;
|
||||||
@ -1021,7 +1021,7 @@ int uv_shutdown(uv_req_t* req) {
|
|||||||
static void uv_tcp_return_req(uv_handle_t* handle, uv_req_t* req) {
|
static void uv_tcp_return_req(uv_handle_t* handle, uv_req_t* req) {
|
||||||
BOOL success;
|
BOOL success;
|
||||||
DWORD bytes, flags, err;
|
DWORD bytes, flags, err;
|
||||||
uv_buf buf;
|
uv_buf_t buf;
|
||||||
|
|
||||||
assert(handle->type == UV_TCP);
|
assert(handle->type == UV_TCP);
|
||||||
|
|
||||||
|
|||||||
6
uv-win.h
6
uv-win.h
@ -33,13 +33,13 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It should be possible to cast uv_buf[] to WSABUF[]
|
* It should be possible to cast uv_buf_t[] to WSABUF[]
|
||||||
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
|
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
|
||||||
*/
|
*/
|
||||||
typedef struct uv_buf {
|
typedef struct uv_buf_t {
|
||||||
ULONG len;
|
ULONG len;
|
||||||
char* base;
|
char* base;
|
||||||
} uv_buf;
|
} uv_buf_t;
|
||||||
|
|
||||||
#define uv_req_private_fields \
|
#define uv_req_private_fields \
|
||||||
union { \
|
union { \
|
||||||
|
|||||||
8
uv.h
8
uv.h
@ -48,11 +48,11 @@ typedef struct uv_req_s uv_req_t;
|
|||||||
* For uv_close_cb, -1 means that the handle was closed due to an error.
|
* For uv_close_cb, -1 means that the handle was closed due to an error.
|
||||||
* Error details can be obtained by calling uv_last_error().
|
* Error details can be obtained by calling uv_last_error().
|
||||||
*
|
*
|
||||||
* In the case of uv_read_cb the uv_buf returned should be freed by the
|
* In the case of uv_read_cb the uv_buf_t returned should be freed by the
|
||||||
* user.
|
* user.
|
||||||
*/
|
*/
|
||||||
typedef uv_buf (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);
|
typedef uv_buf_t (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);
|
||||||
typedef void (*uv_read_cb)(uv_handle_t *handle, int nread, uv_buf buf);
|
typedef void (*uv_read_cb)(uv_handle_t *handle, int nread, uv_buf_t buf);
|
||||||
typedef void (*uv_write_cb)(uv_req_t* req, int status);
|
typedef void (*uv_write_cb)(uv_req_t* req, int status);
|
||||||
typedef void (*uv_connect_cb)(uv_req_t* req, int status);
|
typedef void (*uv_connect_cb)(uv_req_t* req, int status);
|
||||||
typedef void (*uv_shutdown_cb)(uv_req_t* req, int status);
|
typedef void (*uv_shutdown_cb)(uv_req_t* req, int status);
|
||||||
@ -219,7 +219,7 @@ int uv_accept(uv_handle_t* server, uv_handle_t* client,
|
|||||||
int uv_read_start(uv_handle_t* handle, uv_read_cb cb);
|
int uv_read_start(uv_handle_t* handle, uv_read_cb cb);
|
||||||
int uv_read_stop(uv_handle_t* handle);
|
int uv_read_stop(uv_handle_t* handle);
|
||||||
|
|
||||||
int uv_write(uv_req_t* req, uv_buf bufs[], int bufcnt);
|
int uv_write(uv_req_t* req, uv_buf_t bufs[], int bufcnt);
|
||||||
|
|
||||||
/* Timer methods */
|
/* Timer methods */
|
||||||
int uv_timeout(uv_req_t* req, int64_t timeout);
|
int uv_timeout(uv_req_t* req, int64_t timeout);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user