Browse Source

Extend management socket state

Distinguish between management socket connected and
ready for interaction with the server. The former can
happen even if the server is connected to another client
and thus non-responsive.

Use manage.connected = 1 in place of true when connected
and = 2 when handshake with server completed and ready for
input.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/519/head
Selva Nair 2 years ago
parent
commit
0baf486cb4
  1. 7
      manage.c
  2. 2
      openvpn.c
  3. 2
      options.h

7
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();

2
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);

2
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 */

Loading…
Cancel
Save