From 441c38ab0fa9d0ef899134e8d6a46c55b10e1ab1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 10 Aug 2007 13:53:07 -0700 Subject: Define CONNECT_OFFSET so that it is an out-of-range signed value This was causing queries that hit stricter HTTP servers (Mongrel) to fail since getting a -1 offset during the write would screw things up. Since that bug is gone, remove an extraneous trailing newline in the HTTP 1.0 request. --- david.c | 9 +++++---- http_1.0.txt | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/david.c b/david.c index d946830..903cff0 100644 --- a/david.c +++ b/david.c @@ -55,6 +55,7 @@ static char *http_request; static size_t http_request_size; static struct addrinfo *ap; static int max_fd; +#define CONNECT_OFFSET 0x7fffffff #ifdef TCP_NODELAY static int can_tcp_nodelay = 1; @@ -67,7 +68,7 @@ struct interface { int fd; /* offset: - * 0xffffffff indicates connect() + * CONNECT_OFFSET indicates connect() * < 0 indicates writing * >= 0 indicates reading */ @@ -179,7 +180,7 @@ static void init_interface(const int i) } } interfaces[i].fd = fd; - interfaces[i].offset = 0xffffffff; + interfaces[i].offset = CONNECT_OFFSET; /* fprintf(stderr, "[%d] ready fd: %d\n", i, fd); */ } @@ -210,7 +211,7 @@ static void do_io(void) (now - interfaces[i].last) <= DELAY_SECONDS) continue; if (interfaces[i].offset < 0 || - interfaces[i].offset == 0xffffffff) { + interfaces[i].offset == CONNECT_OFFSET) { FD_SET(interfaces[i].fd, &wfds); } else { FD_SET(interfaces[i].fd, &rfds); @@ -226,7 +227,7 @@ static void do_io(void) continue; if (FD_ISSET(interfaces[i].fd, &wfds)) { ssize_t wr_bytes; - if (interfaces[i].offset == 0xffffffff) { + if (interfaces[i].offset == CONNECT_OFFSET) { int err; size_t err_len = sizeof(err); getsockopt(interfaces[i].fd, SOL_SOCKET, diff --git a/http_1.0.txt b/http_1.0.txt index 345fbfe..59b46cb 100644 --- a/http_1.0.txt +++ b/http_1.0.txt @@ -1,3 +1,2 @@ GET /index.html HTTP/1.0 - -- cgit v1.2.3-24-ge0c7