Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
test: simplify test-tcp-try-write
Browse files Browse the repository at this point in the history
Use a smaller buffer thus making sure that uv_try_write will succeed at
least once
  • Loading branch information
saghul committed Jul 5, 2014
1 parent 40ad12e commit b018dc5
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions test/test-tcp-try-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,18 @@ static void close_cb(uv_handle_t* handle) {


static void connect_cb(uv_connect_t* req, int status) {
static char zeroes[1024];
int r;
uv_buf_t buf;
ASSERT(status == 0);
connect_cb_called++;

do {
buf = uv_buf_init(zeroes, sizeof(zeroes));
buf = uv_buf_init("PING", 4);
r = uv_try_write((uv_stream_t*) &client, &buf, 1);
ASSERT(r > 0 || r == UV_EAGAIN);
if (r > 0) {
bytes_written += r;

/* Partial write */
if (r != (int) sizeof(zeroes))
break;
break;
}
} while (1);
uv_close((uv_handle_t*) &client, close_cb);
Expand Down

0 comments on commit b018dc5

Please sign in to comment.