Replace some read/write instances with send/recv to work properly on win32.
authorNick Mathewson <nickm@torproject.org>
Fri, 5 Jun 2009 19:52:13 +0000 (19:52 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 5 Jun 2009 19:52:13 +0000 (19:52 +0000)
svn:r1324

ChangeLog
test/bench.c
test/bench_cascade.c
test/regress_et.c
test/test-eof.c
test/test-weof.c

index ea9e2f27d08bc8aedbb80f34c303b3261f93db55..b8a0cc34f862dc2381cc119e48492ce069bf9812 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,8 @@ Changes in 2.0.2-alpha:
  o Fix a memory error when freeing a thread-enabled event base with registered events. (Spotted by Joachim Bauch.)
  o Try to contain degree of failure when running on a win32 version so heavily firewalled that we can't fake a socketpair.
  o Activate fd events in a pseudorandom order with O(N) backends, so that we don't systematically favor low fds (select) or earlier-added fds (poll, win32).
+ o Replace some read()/write() instances with send()/recv() to work properly
+ on win32.
 
 
 Changes in 2.0.1-alpha:
index c065bb979145ae7fafd4f79ace20d6c41bffed62..9e57d16aee42e926c7e2fb01decdad21433f7cfc 100644 (file)
@@ -70,11 +70,11 @@ read_cb(int fd, short which, void *arg)
        long idx = (long) arg, widx = idx + 1;
        u_char ch;
 
-       count += read(fd, &ch, sizeof(ch));
+       count += recv(fd, &ch, sizeof(ch), 0);
        if (writes) {
                if (widx >= num_pipes)
                        widx -= num_pipes;
-               write(pipes[2 * widx + 1], "e", 1);
+               send(pipes[2 * widx + 1], "e", 1, 0);
                writes--;
                fired++;
        }
@@ -99,7 +99,7 @@ run_once(void)
        space = num_pipes / num_active;
        space = space * 2;
        for (i = 0; i < num_active; i++, fired++)
-               write(pipes[i * space + 1], "e", 1);
+               send(pipes[i * space + 1], "e", 1, 0);
 
        count = 0;
        writes = num_writes;
index e9984ae579aafbc701a4391fb666ba11bce0e787..d06076455d9eb642008673be4f45c96fc13de16d 100644 (file)
@@ -66,9 +66,9 @@ read_cb(int fd, short which, void *arg)
        char ch;
        long idx = (long) arg;
 
-       read(fd, &ch, sizeof(ch));
+       recv(fd, &ch, sizeof(ch), 0);
        if (idx >= 0)
-               write(idx, "e", 1);
+               send(idx, "e", 1, 0);
        fired++;
 }
 
@@ -109,7 +109,7 @@ run_once(int num_pipes)
        fired = 0;
 
        /* kick everything off with a single write */
-       write(pipes[1], "e", 1);
+       send(pipes[1], "e", 1, 0);
 
        event_dispatch();
 
index 54e2a3d3d5fe5258a4608377a4fca0b5541a2b2b..c1930a44fe8a84c6337b29854f9eb7ab73ad0f83 100644 (file)
@@ -55,7 +55,7 @@ read_cb(int fd, short event, void *arg)
        char buf;
        int len;
 
-       len = read(fd, &buf, sizeof(buf));
+       len = recv(fd, &buf, sizeof(buf), 0);
 
        /*printf("%s: %s %d%s\n", __func__, event & EV_ET ? "etread" : "read",
                 len, len ? "" : " - means EOF");
@@ -95,7 +95,7 @@ test_edgetriggered(void *et)
 
        called = was_et = 0;
 
-       write(pair[0], test, strlen(test)+1);
+       send(pair[0], test, strlen(test)+1, 0);
        shutdown(pair[0], SHUT_WR);
 
        /* Initalize the event library */
index 5706aed6c602b66974580edadf50b66e54b92416..099242c493d2b0ebb13c1056cc03dfe02c6e6bc5 100644 (file)
@@ -35,7 +35,7 @@ read_cb(int fd, short event, void *arg)
        char buf[256];
        int len;
 
-       len = read(fd, buf, sizeof(buf));
+       len = recv(fd, buf, sizeof(buf), 0);
 
        printf("%s: read %d%s\n", __func__,
            len, len ? "" : " - means EOF");
@@ -64,7 +64,7 @@ main (int argc, char **argv)
                return (1);
 
 
-       write(pair[0], test, strlen(test)+1);
+       send(pair[0], test, strlen(test)+1, 0);
        shutdown(pair[0], SHUT_WR);
 
        /* Initalize the event library */
index 73af086be8ed3e92e63baecc5759b38899f5723e..c5444f768a17c67909bbe65e952dcc8b9a439fa3 100644 (file)
@@ -39,7 +39,7 @@ write_cb(int fd, short event, void *arg)
        const char *test = "test string";
        int len;
 
-       len = write(fd, test, strlen(test) + 1);
+       len = send(fd, test, strlen(test) + 1, 0);
 
        printf("%s: write %d%s\n", __func__,
            len, len ? "" : " - means EOF");