From: Kern Sibbald Date: Sat, 21 Mar 2009 14:24:27 +0000 (+0000) Subject: Attempt to correct timing problems with starting bat and obtaining X-Git-Tag: Release-3.0.0~131 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7faf66914b36a1b481539c8cca5bf55953568e73;p=bacula%2Fbacula Attempt to correct timing problems with starting bat and obtaining lists. Maintain in_command counter to know when a list is coming. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8571 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 5577c3445b..32a1aea5bd 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -193,6 +193,7 @@ bool do_a_command(UAContext *ua) } if (ua->api) user->signal(BNET_CMD_BEGIN); ok = (*commands[i].func)(ua, ua->cmd); /* go execute command */ + if (ua->api) user->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED); found = true; break; } @@ -201,7 +202,6 @@ bool do_a_command(UAContext *ua) ua->error_msg(_("%s: is an invalid command.\n"), ua->argk[0]); ok = false; } - if (ua->api) user->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED); return ok; } diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index d09c60d378..462d8ed27a 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2008 Free Software Foundation Europe e.V. + Copyright (C) 2002-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -131,6 +131,7 @@ bool do_a_dot_command(UAContext *ua) ua->gui = true; if (ua->api) user->signal(BNET_CMD_BEGIN); ok = (*commands[i].func)(ua, ua->cmd); /* go execute command */ + if (ua->api) user->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED); ua->gui = gui; found = true; break; @@ -141,7 +142,6 @@ bool do_a_dot_command(UAContext *ua) ua->error_msg("%s", user->msg); ok = false; } - if (ua->api) user->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED); return ok; } diff --git a/bacula/src/qt-console/bcomm/dircomm.cpp b/bacula/src/qt-console/bcomm/dircomm.cpp index c08ca6b115..67b10f99ee 100644 --- a/bacula/src/qt-console/bcomm/dircomm.cpp +++ b/bacula/src/qt-console/bcomm/dircomm.cpp @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2007-2008 Free Software Foundation Europe e.V. + Copyright (C) 2007-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -51,6 +51,7 @@ m_api_set(false) m_at_prompt = false; m_at_main_prompt = false; m_conn = conn; + m_in_command = 0; } DirComm::~DirComm() @@ -301,12 +302,19 @@ int DirComm::read() if (mainWin->m_commDebug) Pmsg0(000, "CMD OK\n"); m_at_prompt = false; m_at_main_prompt = false; +// Pmsg1(000, "before dec m_in_command=%d\n", m_in_command); + if (--m_in_command < 0) { +// Pmsg0(000, "m_in_command < 0\n"); + m_in_command = 0; + } mainWin->set_status(_("Command completed ...")); continue; case BNET_CMD_BEGIN: if (mainWin->m_commDebug) Pmsg0(000, "CMD BEGIN\n"); m_at_prompt = false; m_at_main_prompt = false; + m_in_command++; +// Pmsg1(000, "after inc m_in_command=%d\n", m_in_command); mainWin->set_status(_("Processing command ...")); continue; case BNET_MAIN_PROMPT: @@ -325,6 +333,9 @@ int DirComm::read() break; case BNET_CMD_FAILED: if (mainWin->m_commDebug) Pmsg0(000, "CMD FAILED\n"); + if (--m_in_command < 0) { + Pmsg0(000, "m_in_command < 0\n"); + } mainWin->set_status(_("Command failed.")); QApplication::restoreOverrideCursor(); break; diff --git a/bacula/src/qt-console/bcomm/dircomm.h b/bacula/src/qt-console/bcomm/dircomm.h index 4f84a2a03f..a8e66aa6d0 100644 --- a/bacula/src/qt-console/bcomm/dircomm.h +++ b/bacula/src/qt-console/bcomm/dircomm.h @@ -3,7 +3,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2007-2008 Free Software Foundation Europe e.V. + Copyright (C) 2007-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -64,6 +64,7 @@ public: char *msg(); bool notify(bool enable); // enables/disables socket notification - returns the previous state bool is_notify_enabled() const; + bool is_in_command() const { return m_in_command > 0; }; void terminate(); bool connect_dir(); int read(void); @@ -77,6 +78,7 @@ private: BSOCK *m_sock; bool m_at_prompt; bool m_at_main_prompt; + int m_in_command; QSocketNotifier *m_notifier; bool m_api_set; int m_conn; diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 8a14015091..f17a735857 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2007-2008 Free Software Foundation Europe e.V. + Copyright (C) 2007-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -176,11 +176,12 @@ bool Console::dir_cmd(const char *cmd, QStringList &results) Pmsg2(000, "dir_cmd conn %i %s\n", conn, cmd); notify(conn, false); dircomm->write(cmd); - while ((stat = dircomm->read()) > 0) { + while ((stat = dircomm->read()) > 0 && dircomm->is_in_command()) { if (mainWin->m_displayAll) display_text(dircomm->msg()); strip_trailing_junk(dircomm->msg()); results << dircomm->msg(); } + if (stat > 0 && mainWin->m_displayAll) display_text(dircomm->msg()); notify(conn, true); discardToPrompt(conn); return true; /* ***FIXME*** return any command error */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index f820150d3f..f61d1f3628 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -49,6 +49,9 @@ Code to be completed before 3.0.0 is released: General: +21Mar09 +Kes Attempt to correct timing problems with starting bat and obtaining + lists. Maintain in_command counter to know when a list is coming. 20Mar09 kes Convert seconds.seq separator into seconds_seq so that Bacula editing of the Job name from the full Job name works. This fixes