about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-08-10 13:53:07 -0700
committerEric Wong <normalperson@yhbt.net>2007-08-10 14:03:56 -0700
commit441c38ab0fa9d0ef899134e8d6a46c55b10e1ab1 (patch)
tree66059b1d45747bd179589304a673fec0e0295af6
parentf2518dcf1723495ef2bdd34ea36eb30a581f2ca6 (diff)
downloaddavid-441c38ab0fa9d0ef899134e8d6a46c55b10e1ab1.tar.gz
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.
-rw-r--r--david.c9
-rw-r--r--http_1.0.txt1
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
 
-