I got the onion router to work under windows!

Bruce Montrose montrose at itd.nrl.navy.mil
Tue Jul 29 14:43:23 UTC 2003

Aside from the missing stdint.h that I mentioned before, there was another
problem that only occurred when the Windows onion router was chosen as an
exit node. The problem was caused by the Windows onion router not detecting
when the connection was closed.

Upon further investigation I discovered that the poll() function was
behaving quite differently when a connection was closed under Windows. More
precisely, under Windows poll() would put POLLHUP into revents instead of
POLLIN as it did under the many different LINUX distributions that I tested
this on. So to get the onion router to work properly under Windows, I simply
added a second condition that would allow the calling of conn_read()
whenever POLLHUP was put into revents by poll() in main.c like this:

        if(poll_array[i].revents & POLLIN ||
           poll_array[i].revents & POLLHUP ) /* something to read */
          conn_read(i); /* this also blows away broken connections */

I have attached a little test program that demonstrates this peculiar
behavior of the poll() function. Here is the output of the test program when
I ran it under Windows and Linux:

[montrose at kiwi]$ !gcc
gcc -o bug bug.c -lpthread
[montrose at kiwi]$ ./bug
close: POLLHUP
shutdown: POLLHUP

[montrose at ced]$ !gcc
gcc -o bug bug.c -lpthread
[montrose at ced]$ ./bug
close: POLLIN 
shutdown: POLLIN

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug.c
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20030729/ea89a6c5/attachment.asc>

More information about the tor-dev mailing list