From 6023ab706b031a54a22700cb147de02304b17a4a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 29 Mar 2009 17:36:11 +0000 Subject: [PATCH] Make bat sock handling a bit more robust git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8643 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/release-3-status.txt | 9 +-------- bacula/src/lib/bsock.c | 3 +++ bacula/src/qt-console/bcomm/dircomm.cpp | 12 +++++++----- bacula/src/qt-console/console/console.cpp | 11 +++++++---- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bacula/release-3-status.txt b/bacula/release-3-status.txt index 9489f35994..e172876e6e 100644 --- a/bacula/release-3-status.txt +++ b/bacula/release-3-status.txt @@ -14,17 +14,10 @@ New features needing documentation: - Regex filtered bsrs Kjetil Torgrim Homme 15Aug08 - Allow Mixed Priorities Kjetil Torgrim Homme 30Jun08 - New configure options --disable-libtool, --docdir, --htmldir, ... +- Virtual Full and Pools Code to be completed before 3.0.0 is released: -1. Fix Exchange plugin bugs 1234,1235,1236,1237 - *1234 fixed. 2. Finish documentation (some noted above) -3. Make plugins work with Accurate -- needs two new API calls - - mark file not deleted - - is file deleted (at end of job) - - Pass accurate flag to Plugin (* this works) - * code implemented not yet intgrated into Exchange plugin -4. Possibly change VirtualFull to use same input and output pool. New features implemented: - Accurate Backup diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index a33a3dc917..788c123726 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -809,6 +809,9 @@ int BSOCK::wait_data_intr(int sec, int usec) fd_set fdset; struct timeval tv; + if (this == NULL) { + return -1; + } FD_ZERO(&fdset); FD_SET((unsigned)m_fd, &fdset); tv.tv_sec = sec; diff --git a/bacula/src/qt-console/bcomm/dircomm.cpp b/bacula/src/qt-console/bcomm/dircomm.cpp index c3de1c6e90..cd1b706d00 100644 --- a/bacula/src/qt-console/bcomm/dircomm.cpp +++ b/bacula/src/qt-console/bcomm/dircomm.cpp @@ -42,9 +42,7 @@ static int tls_pem_callback(char *buf, int size, const void *userdata); -DirComm::DirComm(Console *parent, int conn): -m_notifier(NULL), -m_api_set(false) +DirComm::DirComm(Console *parent, int conn): m_notifier(NULL), m_api_set(false) { m_console = parent; m_sock = NULL; @@ -267,7 +265,11 @@ int DirComm::sock_read() */ int DirComm::read() { - int stat = 0; + int stat = -1; + + if (!m_sock) { + return -1; + } while (m_sock) { for (;;) { if (!m_sock) break; @@ -282,7 +284,7 @@ int DirComm::read() } } if (!m_sock) { - return BNET_HARDEOF; + return -1; } m_sock->msg[0] = 0; stat = sock_read(); diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 25a5b1305f..bc36a8550f 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -194,7 +194,7 @@ bool Console::dir_cmd(QString &cmd, QStringList &results) bool Console::dir_cmd(const char *cmd, QStringList &results) { int conn; - if(availableDirComm(conn)) { + if (availableDirComm(conn)) { dir_cmd(conn, cmd, results); return true; } else { @@ -306,7 +306,7 @@ bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool d int Console::write_dir(const char *msg) { int conn; - if(availableDirComm(conn)) + if (availableDirComm(conn)) write_dir(conn, msg); return conn; } @@ -600,7 +600,10 @@ void Console::discardToPrompt(int conn) displayToPrompt(conn); } else { while (!dircomm->m_at_prompt) { - stat=dircomm->read(); + stat = dircomm->read(); + if (stat < 0) { + break; + } } } if (mainWin->m_commDebug) Pmsg2(000, "endDiscardToPrompt=%d %s\n", stat, m_dir->name()); @@ -621,7 +624,7 @@ void Console::discardToPrompt(int conn) int Console::notifyOff() { int conn = 0; - if(availableDirComm(conn)) + if (availableDirComm(conn)) notify(conn, false); return conn; } -- 2.39.5