]> git.sur5r.net Git - bacula/bacula/commitdiff
Implemented prompt and heartbeat messages.
authorNicolas Boichat <nicolas@boichat.ch>
Sat, 24 Apr 2004 20:08:52 +0000 (20:08 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Sat, 24 Apr 2004 20:08:52 +0000 (20:08 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1292 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/console_thread.cpp
bacula/src/wx-console/csprint.h

index 7bf327a705b7f566ef3b716f871d8e390ea310b8..d459f2fa5c2c5199151821dd65ad1c43d5066a6a 100644 (file)
@@ -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;
 }
index eee4a147fbb2dbac719b2b160004bb93c1b01578..6f762557547e5185eba7bf74487dd66b5d335e15 100644 (file)
@@ -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 */