From 611ea6dc35976431b219d7cc92514eed3376f9bc Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sat, 24 Apr 2004 20:08:52 +0000 Subject: [PATCH] Implemented prompt and heartbeat messages. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1292 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/console_thread.cpp | 35 ++++++++++++++++++++---- bacula/src/wx-console/csprint.h | 5 ++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/bacula/src/wx-console/console_thread.cpp b/bacula/src/wx-console/console_thread.cpp index 7bf327a705..d459f2fa5c 100644 --- a/bacula/src/wx-console/console_thread.cpp +++ b/bacula/src/wx-console/console_thread.cpp @@ -63,15 +63,13 @@ console_thread::~console_thread() { * Thread entry point */ void* console_thread::Entry() { -#ifdef HAVE_WIN32 if (WSA_Init() == 0) { - csprint("Windows sockets initialized successfully...\n"); + //csprint("Windows sockets initialized successfully...\n"); } else { csprint("Error while initializing windows sockets...\n"); return 0; } -#endif csprint("Connecting...\n"); @@ -115,10 +113,28 @@ void* console_thread::Entry() { if ((stat = bnet_recv(UA_sock)) >= 0) { csprint(UA_sock->msg); } - else { + else if (stat == BNET_SIGNAL) { + if (UA_sock->msglen == BNET_PROMPT) { + csprint(NULL, CS_PROMPT); + } + else if (UA_sock->msglen == BNET_EOD) { + csprint(NULL, CS_END); + } + else if (UA_sock->msglen == BNET_HEARTBEAT) { + bnet_sig(UA_sock, BNET_HB_RESPONSE); + csprint("<< Heartbeat signal received, answered. >>\n", CS_DEBUG); + } + else { + csprint("<< Unexpected signal received : ", CS_DEBUG); + csprint(bnet_sig_to_ascii(UA_sock), CS_DEBUG); + csprint(">>\n", CS_DEBUG); + } + } + else { /* BNET_HARDEOF || BNET_ERROR */ csprint(NULL, CS_END); + break; } - + if (is_bnet_stop(UA_sock)) { csprint(NULL, CS_END); break; /* error or term */ @@ -128,6 +144,15 @@ void* console_thread::Entry() { csprint(NULL, CS_DISCONNECTED); csprint("Connection terminated\n"); + + UA_sock = NULL; + + if (WSACleanup() == 0) { + //csprint("Windows sockets cleaned up successfully...\n"); + } + else { + csprint("Error while cleaning up windows sockets...\n"); + } return 0; } diff --git a/bacula/src/wx-console/csprint.h b/bacula/src/wx-console/csprint.h index eee4a147fb..6f76255754 100644 --- a/bacula/src/wx-console/csprint.h +++ b/bacula/src/wx-console/csprint.h @@ -28,8 +28,9 @@ #define CS_DATA 1 /* data has been received */ #define CS_END 2 /* no data to receive anymore */ -#define CS_CONNECTED 3 /* the socket is now connected */ -#define CS_DISCONNECTED 4 /* the socket is now disconnected */ +#define CS_PROMPT 3 /* prompt signal received */ +#define CS_CONNECTED 4 /* the socket is now connected */ +#define CS_DISCONNECTED 5 /* the socket is now disconnected */ #define CS_DEBUG 10 /* used to print debug messages */ /* function called by console_thread to send events back to the GUI */ -- 2.39.5