diff --git a/manage.c b/manage.c index c6aa738..682b2e0 100644 --- a/manage.c +++ b/manage.c @@ -65,7 +65,7 @@ OpenManagement(connection_t *c) if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) return FALSE; - c->manage.connected = FALSE; + c->manage.connected = 0; c->manage.sk = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (c->manage.sk == INVALID_SOCKET) { @@ -219,7 +219,7 @@ OnManagement(SOCKET sk, LPARAM lParam) } } else - c->manage.connected = TRUE; + c->manage.connected = 1; break; case FD_READ: @@ -337,6 +337,7 @@ OnManagement(SOCKET sk, LPARAM lParam) { /* delay until management interface accepts input */ Sleep(100); + c->manage.connected = 2; if (rtmsg_handler[ready_]) rtmsg_handler[ready_](c, pos + 5); } @@ -437,7 +438,7 @@ CloseManagement(connection_t *c) } closesocket(c->manage.sk); c->manage.sk = INVALID_SOCKET; - c->manage.connected = FALSE; + c->manage.connected = 0; while (UnqueueCommand(c)) ; WSACleanup(); diff --git a/openvpn.c b/openvpn.c index bab809d..fa727c8 100644 --- a/openvpn.c +++ b/openvpn.c @@ -1787,7 +1787,7 @@ DisconnectDaemon(connection_t *c) { if (c->flags & FLAG_DAEMON_PERSISTENT) { - if (c->manage.connected) + if (c->manage.connected > 1) /* connected and ready for input */ { ManagementCommand(c, "hold on", NULL, regular); ManagementCommand(c, "signal SIGHUP", NULL, regular); diff --git a/options.h b/options.h index 6d2da0e..e7d0904 100644 --- a/options.h +++ b/options.h @@ -146,7 +146,7 @@ struct connection { char *saved_data; size_t saved_size; mgmt_cmd_t *cmd_queue; - BOOL connected; /* True, if management interface has connected */ + DWORD connected; /* 1: management interface connected, 2: connected and ready */ } manage; HANDLE hProcess; /* Handle of openvpn process if directly started */