Merge branch 'bug1983-port-tor-fw-helper-to-windows' into bug2046

Conflicts:
	configure.in
	src/tools/tor-fw-helper/Makefile.am
	src/tools/tor-fw-helper/tor-fw-helper-upnp.c
	src/tools/tor-fw-helper/tor-fw-helper.c
This commit is contained in:
Steven Murdoch 2011-08-22 17:53:17 +01:00
commit 6443a756df
10 changed files with 35 additions and 11 deletions

5
changes/bug3752 Normal file
View File

@ -0,0 +1,5 @@
o Major bugfixes:
- The IOCP backend now works even when the user has not specified
the (internal, debbuging-only) _UseFilteringSSLBufferevents option.
Fixes part of bug 3752; bugfix on 0.2.3.1-alpha.

View File

@ -325,6 +325,7 @@ dnl Where do you live, libevent? And how do we call you?
if test "$bwin32" = true; then
TOR_LIB_WS32=-lws2_32
TOR_LIB_IPHLPAPI=-liphlpapi
# Some of the cargo-cults recommend -lwsock32 as well, but I don't
# think it's actually necessary.
TOR_LIB_GDI=-lgdi32
@ -334,6 +335,7 @@ else
fi
AC_SUBST(TOR_LIB_WS32)
AC_SUBST(TOR_LIB_GDI)
AC_SUBST(TOR_LIB_IPHLPAPI)
dnl We need to do this before we try our disgusting hack below.
AC_CHECK_HEADERS([sys/types.h])
@ -559,7 +561,7 @@ dnl There are no packages for Debian or Redhat as of this patch
if test "$upnp" = "true"; then
AC_DEFINE(MINIUPNPC, 1, [Define to 1 if we are building with UPnP.])
TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc -lws2_32 -liphlpapi],
TOR_SEARCH_LIBRARY(libminiupnpc, $trylibminiupnpcdir, [-lminiupnpc $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
[#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>],

View File

@ -164,6 +164,16 @@ struct event_base *the_event_base = NULL;
#endif
#endif
#ifdef USE_BUFFEREVENTS
static int using_iocp_bufferevents = 0;
int
tor_libevent_using_iocp_bufferevents(void)
{
return using_iocp_bufferevents;
}
#endif
/** Initialize the Libevent library and set up the event base. */
void
tor_libevent_initialize(tor_libevent_cfg *torcfg)
@ -187,6 +197,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
if (! torcfg->disable_iocp) {
evthread_use_windows_threads();
event_config_set_flag(cfg, EVENT_BASE_FLAG_STARTUP_IOCP);
using_iocp_bufferevents = 1;
}
#endif

View File

@ -73,6 +73,7 @@ const char *tor_libevent_get_version_str(void);
#ifdef USE_BUFFEREVENTS
#define TOR_LIBEVENT_TICKS_PER_SECOND 3
const struct timeval *tor_libevent_get_one_tick_timeout(void);
int tor_libevent_using_iocp_bufferevents(void);
#endif
#endif

View File

@ -1892,7 +1892,7 @@ tor_tls_init_bufferevent(tor_tls_t *tls, struct bufferevent *bufev_in,
const enum bufferevent_ssl_state state = receiving ?
BUFFEREVENT_SSL_ACCEPTING : BUFFEREVENT_SSL_CONNECTING;
if (filter) {
if (filter || tor_libevent_using_iocp_bufferevents()) {
/* Grab an extra reference to the SSL, since BEV_OPT_CLOSE_ON_FREE
means that the SSL will get freed too.

View File

@ -1054,14 +1054,14 @@ fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto)
#ifdef USE_BUFFEREVENTS
/** Try to read <b>n</b> bytes from <b>buf</b> at <b>pos</b> (which may be
* NULL for the start of the buffer), copying the data only if necessary. Set
* *<b>data_out</b> to a pointer to the desired bytes. Set <b>free_out</b> to 1
* if we needed to malloc *<b>data</b> because the original bytes were
* *<b>data_out</b> to a pointer to the desired bytes. Set <b>free_out</b>
* to 1 if we needed to malloc *<b>data</b> because the original bytes were
* noncontiguous; 0 otherwise. Return the number of bytes actually available
* at *<b>data_out</b>.
*/
static ssize_t
inspect_evbuffer(struct evbuffer *buf, char **data_out, size_t n, int *free_out,
struct evbuffer_ptr *pos)
inspect_evbuffer(struct evbuffer *buf, char **data_out, size_t n,
int *free_out, struct evbuffer_ptr *pos)
{
int n_vecs, i;
@ -1657,9 +1657,9 @@ fetch_from_evbuffer_socks(struct evbuffer *buf, socks_request_t *req,
if (res == 0 && n_drain == 0 && want_length <= last_wanted) {
/* If we drained nothing, and we didn't ask for more than last time,
* we're stuck in a loop. That's bad. It shouldn't be possible, but
* let's make sure. */
log_warn(LD_BUG, "We seem to be caught in a parse loop; breaking out");
* then we probably wanted more data than the buffer actually had,
* and we're finding out that we're not satisified with it. It's
* time to break until we have more data. */
break;
}

View File

@ -4166,3 +4166,4 @@ connection_free_all(void)
bufferevent_rate_limit_group_free(global_rate_limit);
#endif
}

View File

@ -25,7 +25,7 @@ endif
if MINIUPNPC
miniupnpc_ldflags = @TOR_LDFLAGS_libminiupnpc@
miniupnpc_ldadd = -lminiupnpc -lm -liphlpapi
miniupnpc_ldadd = -lminiupnpc -lm @TOR_LIB_IPHLPAPI@
miniupnpc_cppflags = @TOR_CPPFLAGS_libminiupnpc@
else
miniupnpc_ldflags =

View File

@ -9,7 +9,9 @@
#include "orconfig.h"
#ifdef MINIUPNPC
#ifdef MS_WINDOWS
#define STATICLIB
#endif
#include <stdint.h>
#include <string.h>
#include <stdio.h>

View File

@ -236,7 +236,8 @@ network_init(void)
int r;
r = WSAStartup(0x101, &WSAData);
if (r) {
fprintf(stderr, "E: Error initializing Windows network layer - code was %d", r);
fprintf(stderr, "E: Error initializing Windows network layer "
"- code was %d", r);
return -1;
}
/* WSAData.iMaxSockets might show the max sockets we're allowed to use.
@ -256,6 +257,7 @@ main(int argc, char **argv)
backends_t backend_state;
memset(&tor_fw_options, 0, sizeof(tor_fw_options));
memset(&backend_state, 0, sizeof(backend_state));
while (1) {
int option_index = 0;