[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r17127: {torvm} Remove kludgy sleep around tap device configuration by waiti (torvm/trunk/build/win32/src/torvm-w32)
Author: coderman
Date: 2008-10-16 05:20:47 -0400 (Thu, 16 Oct 2008)
New Revision: 17127
Modified:
torvm/trunk/build/win32/src/torvm-w32/apicommon.c
torvm/trunk/build/win32/src/torvm-w32/torvm.c
Log:
Remove kludgy sleep around tap device configuration by waiting for connect status from the driver to indicate it is ready for endpoint assignment.
Modified: torvm/trunk/build/win32/src/torvm-w32/apicommon.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/apicommon.c 2008-10-16 04:21:28 UTC (rev 17126)
+++ torvm/trunk/build/win32/src/torvm-w32/apicommon.c 2008-10-16 09:20:47 UTC (rev 17127)
@@ -205,7 +205,8 @@
NULL);
if (devfd == INVALID_HANDLE_VALUE)
{
- lerror ("Unable to open net device handle for path: %s", devfstr);
+ /* this is a normal condition for non-ethernet devices */
+ ldebug ("Unable to open net device handle for path: %s", devfstr);
goto cleanup;
}
@@ -256,7 +257,7 @@
NULL);
if (devfd == INVALID_HANDLE_VALUE)
{
- lerror ("Unable to open net device handle for path: %s", devfstr);
+ linfo ("Unable to open net device handle for path: %s", devfstr);
goto cleanup;
}
@@ -284,4 +285,3 @@
}
-
Modified: torvm/trunk/build/win32/src/torvm-w32/torvm.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/torvm.c 2008-10-16 04:21:28 UTC (rev 17126)
+++ torvm/trunk/build/win32/src/torvm-w32/torvm.c 2008-10-16 09:20:47 UTC (rev 17127)
@@ -1090,7 +1090,7 @@
if (getmacaddr (ce->guid, &(ce->macaddr))) {
linfo ("Interface %s => %s mac(%s)", name_data, enum_name, ce->macaddr);
}
- if (isconnected (enum_name)) {
+ if (isconnected (ce->guid)) {
linfo ("Interface %s (%s) is currently connected.", ce->name, ce->macaddr);
ce->isactive = TRUE;
snprintf(tcpip_string,
@@ -1262,9 +1262,6 @@
RegCloseKey (ckey);
}
- else {
- /* printf ("Failed read key %s , errorno: %d", connection_string, status); */
- }
snprintf(connection_string,
sizeof(connection_string),
@@ -1759,12 +1756,14 @@
int numintf;
struct s_rconnelem *connlist = NULL;
struct s_rconnelem *ce = NULL;
+ struct s_rconnelem *tapconn = NULL;
BOOL indebug = FALSE;
BOOL vmnop = FALSE;
BOOL noinit = FALSE;
BOOL foundit = FALSE;
char * cmdline = NULL;
LPTSTR logfile = NULL;
+ DWORD taptimeout = 60; /* the tap device can't be configured until the VM connects it */
if (getosbits() > 32) {
lerror ("Error: only 32bit operating systems are currently supported.");
@@ -1875,6 +1874,10 @@
/* TODO: util method to free structure of list elem */
numintf = loadnetinfo(&connlist);
}
+ tapconn = connlist;
+ while (tapconn && tapconn->istortap != TRUE) {
+ tapconn = tapconn->next;
+ }
if (!installtornpf()) {
lerror ("Unable to install Tor NPF service driver.");
@@ -1954,28 +1957,26 @@
}
/* need to delay long enough to allow qemu to start and open tap device */
- Sleep (2000);
+ if (tapconn) {
+ while ( taptimeout-- && isrunning(&pi) && (! isconnected(tapconn->guid)) ) {
+ ldebug ("Waiting for tap adapter to be connected...");
+ Sleep (1000);
+ }
+ }
+ ldebug ("Done waiting.");
if (! isrunning(&pi)) {
- buildcmdline(ce, FALSE, TRUE, &cmdline);
- launchtorvm(&pi,
- ce->name,
- ce->macaddr,
- NULL,
- cmdline);
- /* need to delay long enough to allow qemu to start and open tap device */
- Sleep (2000);
- if (! isrunning(&pi)) {
- lerror ("Tor VM no tap fallback failed to start properly.");
- goto shutdown;
- }
+ lerror ("Qemu VM failed to start properly.");
+ goto shutdown;
}
- else {
- if (! configtap()) {
- lerror ("Unable to configure tap device. Exiting.");
- goto shutdown;
- }
+ if (! isconnected(tapconn->guid)) {
+ lerror ("Network tap device is not connected to VM.");
+ goto shutdown;
}
+ if (! configtap()) {
+ lerror ("Unable to configure tap device.");
+ goto shutdown;
+ }
waitforit(&pi);