diff options
Diffstat (limited to 'test/httpget.c')
-rw-r--r-- | test/httpget.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/test/httpget.c b/test/httpget.c index c1e37a3..fed6c06 100644 --- a/test/httpget.c +++ b/test/httpget.c @@ -15,7 +15,7 @@ static void ping_fiber(void *ptr) struct tf_sockaddr host; struct tf_fd fd; char buf[128]; - int bytes = 0, r = 0; + int bytes = 0, r; const char *req = "GET / HTTP/1.0\r\n\r\n"; printf("Lookup %s\n", ctx->hostname); @@ -23,16 +23,19 @@ static void ping_fiber(void *ptr) host.u.in.sin_addr.s_addr = inet_addr(ctx->hostname); host.u.in.sin_port = htons(80); - if (tf_socket(&fd, AF_INET, SOCK_STREAM, 0) < 0) + r = tf_socket(&fd, AF_INET, SOCK_STREAM, 0); + if (r < 0) goto err; - if ((r = tf_connect(&fd, &host, 10000)) < 0) + r = tf_timed(tf_connect(&fd, &host), 10000); + if (r < 0) goto err_close; - if ((r = tf_write_fully(&fd, req, strlen(req), 10000)) < 0) + r = tf_write_fully(&fd, req, strlen(req)); + if (r < 0) goto err_close; - while ((r = tf_read(&fd, buf, sizeof(buf), 10000)) > 0) + while ((r = tf_read(&fd, buf, sizeof(buf))) > 0) bytes += r; err_close: tf_close(&fd); |