From d1ffba1d7ce3979e8aefbdd0a26036fe974e5242 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 5 Jun 2009 19:52:13 +0000 Subject: [PATCH] Replace some read/write instances with send/recv to work properly on win32. svn:r1324 --- ChangeLog | 2 ++ test/bench.c | 6 +++--- test/bench_cascade.c | 6 +++--- test/regress_et.c | 4 ++-- test/test-eof.c | 4 ++-- test/test-weof.c | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea9e2f27..b8a0cc34 100644 --- 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: diff --git a/test/bench.c b/test/bench.c index c065bb97..9e57d16a 100644 --- a/test/bench.c +++ b/test/bench.c @@ -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; diff --git a/test/bench_cascade.c b/test/bench_cascade.c index e9984ae5..d0607645 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -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(); diff --git a/test/regress_et.c b/test/regress_et.c index 54e2a3d3..c1930a44 100644 --- a/test/regress_et.c +++ b/test/regress_et.c @@ -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 */ diff --git a/test/test-eof.c b/test/test-eof.c index 5706aed6..099242c4 100644 --- a/test/test-eof.c +++ b/test/test-eof.c @@ -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 */ diff --git a/test/test-weof.c b/test/test-weof.c index 73af086b..c5444f76 100644 --- a/test/test-weof.c +++ b/test/test-weof.c @@ -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"); -- 2.40.0