Replace some read/write instances with send/recv to work properly on win32.

svn:r1324
This commit is contained in:
Nick Mathewson 2009-06-05 19:52:13 +00:00
parent a43a1c2b23
commit d1ffba1d7c
6 changed files with 13 additions and 11 deletions

View File

@ -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:

View 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;

View 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();

View 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 */

View 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 */

View 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");