Commit 324b192f authored by Nick Mathewson's avatar Nick Mathewson 🥔
Browse files

Make Tor use Niels Provos's libevent instead of it's current

poll-but-sometimes-select mess.  This will let us use faster async cores
(like epoll, kpoll, and /dev/poll), and hopefully work better on Windows
too.

There are some fairly nasty changes to main.c here; this will almost
certainly break something.  But hey, that's what alphas are for.


svn:r3341
parent 9b578f2f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ AC_ARG_WITH(ssl-dir,

AC_SEARCH_LIBS(socket, [socket])
AC_SEARCH_LIBS(gethostbyname, [nsl])
AC_SEARCH_LIBS(event_loop, [event], , AC_MSG_ERROR(Libevent library not found. Tor requires libevent to build.))

saved_LIBS="$LIBS"
saved_LDFLAGS="$LDFLAGS"
@@ -139,7 +140,9 @@ AC_SYS_LARGEFILE

dnl The warning message here is no longer strictly accurate.

AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/stat.h sys/poll.h sys/types.h fcntl.h sys/fcntl.h sys/ioctl.h sys/socket.h sys/time.h netinet/in.h arpa/inet.h errno.h assert.h time.h pwd.h grp.h zlib.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h sys/stat.h sys/types.h fcntl.h sys/fcntl.h sys/ioctl.h sys/socket.h sys/time.h netinet/in.h arpa/inet.h errno.h assert.h time.h pwd.h grp.h zlib.h, , AC_MSG_WARN(some headers were not found, compilation may fail))

AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.))

dnl These headers are not essential

+16 −2
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ Tier one:

   - Windows
N    - Make millisecond accuracy work on win32
     - Switch to WSA*Event code as a better poll replacement.  Or maybe just
     X Switch to WSA*Event code as a better poll replacement.  Or maybe just
       do libevent?

   - Code cleanup
@@ -101,10 +101,24 @@ Tier two:
     - Limit number of circuits that we preemptively generate based on past
       behavior; use same limits in circuit_expire_old_circuits().
     - Write limiting; configurable token buckets.
     - Switch to libevent?  Evaluate it first.
     - Make it harder to circumvent bandwidth caps: look at number of bytes
       sent across sockets, not number sent inside TLS stream.

     . Switch to libevent
       o Evaluate libevent
       o Convert socket handling
       o Convert signal handling
       o Convert timers
       o Update configure.in
       o Remove fakepoll
       - Hold-open-until-flushed now works by accident; it should work by
         design.
       - The logic for reading from TLS sockets is likely to overrun the
         bandwidth buckets under heavy load.  (Really, the logic was
         never right in the first place.)  Also, we should audit all users
         of get_pending_bytes().
       - Make sure it works on more platforms.
       - Find a way to make sure we have libevent 1.0 or later.

   - QOI
     - Let more config options (e.g. ORPort) change dynamically.
+2 −2
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ noinst_LIBRARIES = libor.a libor-crypto.a

#CFLAGS  = -Wall -Wpointer-arith -O2

libor_a_SOURCES = log.c fakepoll.c util.c compat.c container.c
libor_a_SOURCES = log.c util.c compat.c container.c
libor_crypto_a_SOURCES = crypto.c aes.c tortls.c torgzip.c

noinst_HEADERS = log.h crypto.h fakepoll.h test.h util.h compat.h aes.h torint.h tortls.h strlcpy.c strlcat.c torgzip.h container.h
noinst_HEADERS = log.h crypto.h test.h util.h compat.h aes.h torint.h tortls.h strlcpy.c strlcat.c torgzip.h container.h
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ const char compat_c_id[] = "$Id$";
#define _GNU_SOURCE

#include "orconfig.h"
#include "fakepoll.h"
#include "compat.h"

#ifdef MS_WINDOWS
+4 −0
Original line number Diff line number Diff line
@@ -115,6 +115,10 @@ int replace_file(const char *from, const char *to);
#define tor_close_socket(s) close(s)
#endif

/* Now that we use libevent, all real sockets are safe for polling ... or
 * if they aren't, libevent will help us. */
#define SOCKET_IS_POLLABLE(fd) ((fd)>=0)

struct in_addr;
int tor_inet_aton(const char *cp, struct in_addr *addr);
int tor_lookup_hostname(const char *name, uint32_t *addr);
Loading