From f60ad5a5f1a49c4f1b2ad791b8ff69dfecb61529 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 29 Mar 2009 10:55:53 +0000 Subject: [PATCH] Attempt to fix bat seg faults git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8640 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/getmsg.c | 2 +- bacula/src/filed/job.c | 6 ++- bacula/src/lib/message.c | 2 + bacula/src/qt-console/bcomm/dircomm_auth.cpp | 3 +- bacula/src/qt-console/clients/clients.cpp | 45 ++++++++++--------- bacula/src/qt-console/fileset/fileset.cpp | 26 ++++++----- bacula/src/qt-console/joblist/joblist.cpp | 36 ++++++++------- bacula/src/qt-console/jobs/jobs.cpp | 32 ++++++------- bacula/src/qt-console/restore/restoretree.cpp | 2 +- 9 files changed, 82 insertions(+), 72 deletions(-) diff --git a/bacula/src/dird/getmsg.c b/bacula/src/dird/getmsg.c index b28a691091..60e7aed439 100644 --- a/bacula/src/dird/getmsg.c +++ b/bacula/src/dird/getmsg.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2008 Free Software Foundation Europe e.V. + Copyright (C) 2000-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. diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index a49951fbd7..ddc7faa955 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -206,6 +206,7 @@ void *handle_client_request(void *dirp) bool found, quit; JCR *jcr; BSOCK *dir = (BSOCK *)dirp; + const char jobname[12] = "*Director*"; jcr = new_jcr(sizeof(JCR), filed_free_jcr); /* create JCR */ jcr->dir_bsock = dir; @@ -216,6 +217,7 @@ void *handle_client_request(void *dirp) jcr->last_fname[0] = 0; jcr->client_name = get_memory(strlen(my_name) + 1); pm_strcpy(jcr->client_name, my_name); + bstrncpy(jcr->Job, jobname, sizeof(jobname)); /* dummy */ jcr->crypto.pki_sign = me->pki_sign; jcr->crypto.pki_encrypt = me->pki_encrypt; jcr->crypto.pki_keypair = me->pki_keypair; @@ -1310,11 +1312,11 @@ static int level_cmd(JCR *jcr) } else { type = M_INFO; } - Jmsg(jcr, type, 0, _("DIR and FD clocks differ by %d seconds, FD automatically compensating.\n"), adj); + Jmsg(jcr, type, 0, _("DIR and FD clocks differ by %lld seconds, FD automatically compensating.\n"), adj); } dir->signal(BNET_EOD); - Dmsg2(100, "adj = %d since_time=%lld\n", (int)adj, since_time); + Dmsg2(100, "adj=%lld since_time=%lld\n", adj, since_time); jcr->incremental = 1; /* set incremental or decremental backup */ jcr->mtime = since_time; /* set since time */ generate_plugin_event(jcr, bEventSince, (void *)(time_t)jcr->mtime); diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 2b123ed588..889eb1abc7 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -786,6 +786,8 @@ send_to_file: if (jcr && jcr->dir_bsock && !jcr->dir_bsock->errors) { bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%lld %s", jcr->Job, type, mtime, msg); + } else { + Dmsg1(000, "no jcr for following msg: %s", msg); } break; case MD_STDOUT: diff --git a/bacula/src/qt-console/bcomm/dircomm_auth.cpp b/bacula/src/qt-console/bcomm/dircomm_auth.cpp index e639d364cb..92cbfb9f0c 100644 --- a/bacula/src/qt-console/bcomm/dircomm_auth.cpp +++ b/bacula/src/qt-console/bcomm/dircomm_auth.cpp @@ -102,8 +102,7 @@ bool DirComm::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, } /* Timeout Hello after 15 secs */ -// Temp turn this off until we workout how to make sigusr2 work with Qt -// dir->start_timer(15); + dir->start_timer(15); dir->fsend(hello, bashed_name); /* respond to Dir challenge */ diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index eb05df07e8..9f3f4a93b4 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.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. @@ -127,29 +127,29 @@ void Clients::populateTable() foreach (QString resultline, results) { QStringList fieldlist = resultline.split("\t"); - TableItemFormatter item(*tableWidget, row); + TableItemFormatter item(*tableWidget, row); - /* Iterate through fields in the record */ - QStringListIterator fld(fieldlist); - int col = 0; + /* Iterate through fields in the record */ + QStringListIterator fld(fieldlist); + int col = 0; - /* name */ - item.setTextFld(col++, fld.next()); + /* name */ + item.setTextFld(col++, fld.next()); - /* file retention */ - item.setDurationFld(col++, fld.next()); + /* file retention */ + item.setDurationFld(col++, fld.next()); - /* job retention */ - item.setDurationFld(col++, fld.next()); + /* job retention */ + item.setDurationFld(col++, fld.next()); - /* autoprune */ - item.setBoolFld(col++, fld.next()); + /* autoprune */ + item.setBoolFld(col++, fld.next()); - /* client id */ - item.setNumericFld(col++, fld.next()); + /* client id */ + item.setNumericFld(col++, fld.next()); - /* uname */ - item.setTextFld(col++, fld.next()); + /* uname */ + item.setTextFld(col++, fld.next()); row++; } @@ -169,7 +169,9 @@ void Clients::populateTable() for(int r=0; r < rcnt; r++) { for(int c=0; c < ccnt; c++) { QTableWidgetItem* item = tableWidget->item(r, c); - item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + if (item) { + item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + } } } } @@ -294,9 +296,9 @@ void Clients::consolePurgeJobs() " you are doing.\n\n" " Is there any way I can get you to click Cancel here? You really don't want to do" " this\n\n" - "Press OK to proceed with the purge operation?").arg(m_currentlyselected), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Cancel) + "Press OK to proceed with the purge operation?").arg(m_currentlyselected), + QMessageBox::Ok | QMessageBox::Cancel, + QMessageBox::Cancel) == QMessageBox::Cancel) { return; } QString cmd("purge jobs client="); @@ -320,4 +322,3 @@ void Clients::statusClientWindow() QTreeWidgetItem *parentItem = mainWin->getFromHash(this); new ClientStat(m_currentlyselected, parentItem); } - diff --git a/bacula/src/qt-console/fileset/fileset.cpp b/bacula/src/qt-console/fileset/fileset.cpp index 7f0eb899ac..108eae991c 100644 --- a/bacula/src/qt-console/fileset/fileset.cpp +++ b/bacula/src/qt-console/fileset/fileset.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. @@ -123,20 +123,20 @@ void FileSet::populateTable() foreach (QString resultline, results) { fieldlist = resultline.split("\t"); - TableItemFormatter item(*tableWidget, row); + TableItemFormatter item(*tableWidget, row); - /* Iterate through fields in the record */ - QStringListIterator fld(fieldlist); - int col = 0; + /* Iterate through fields in the record */ + QStringListIterator fld(fieldlist); + int col = 0; - /* name */ - item.setTextFld(col++, fld.next()); + /* name */ + item.setTextFld(col++, fld.next()); - /* id */ - item.setNumericFld(col++, fld.next()); + /* id */ + item.setNumericFld(col++, fld.next()); - /* creation time */ - item.setTextFld(col++, fld.next()); + /* creation time */ + item.setTextFld(col++, fld.next()); row++; } @@ -156,7 +156,9 @@ void FileSet::populateTable() for(int r=0; r < rcnt; r++) { for(int c=0; c < ccnt; c++) { QTableWidgetItem* item = tableWidget->item(r, c); - item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + if (item) { + item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + } } } } diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index b523744caa..aa62e5e10e 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.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. @@ -159,45 +159,45 @@ void JobList::populateTable() foreach (resultline, results) { fieldlist = resultline.split("\t"); if (fieldlist.size() < 12) - continue; /* some fields missing, ignore row */ + continue; /* some fields missing, ignore row */ - TableItemFormatter jobitem(*mp_tableWidget, row); + TableItemFormatter jobitem(*mp_tableWidget, row); /* Iterate through fields in the record */ - QStringListIterator fld(fieldlist); + QStringListIterator fld(fieldlist); int col = 0; - /* job id */ + /* job id */ jobitem.setNumericFld(col++, fld.next()); - /* job name */ + /* job name */ jobitem.setTextFld(col++, fld.next()); - /* client */ + /* client */ jobitem.setTextFld(col++, fld.next()); - /* job starttime */ + /* job starttime */ jobitem.setTextFld(col++, fld.next(), true); - /* job type */ + /* job type */ jobitem.setJobTypeFld(col++, fld.next()); - /* job level */ + /* job level */ jobitem.setJobLevelFld(col++, fld.next()); - /* job files */ + /* job files */ jobitem.setNumericFld(col++, fld.next()); - /* job bytes */ + /* job bytes */ jobitem.setBytesFld(col++, fld.next()); - /* job status */ + /* job status */ jobitem.setJobStatusFld(col++, fld.next()); - /* purged */ - jobitem.setBoolFld(col++, fld.next()); + /* purged */ + jobitem.setBoolFld(col++, fld.next()); - /* fileset */ + /* fileset */ jobitem.setTextFld(col++, fld.next()); row++; @@ -225,7 +225,9 @@ void JobList::populateTable() for(int r=0; r < rcnt; r++) { for(int c=0; c < ccnt; c++) { QTableWidgetItem* item = mp_tableWidget->item(r, c); - item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + if (item) { + item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + } } } } diff --git a/bacula/src/qt-console/jobs/jobs.cpp b/bacula/src/qt-console/jobs/jobs.cpp index 843c057283..a1189df9cf 100644 --- a/bacula/src/qt-console/jobs/jobs.cpp +++ b/bacula/src/qt-console/jobs/jobs.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. @@ -100,19 +100,19 @@ void Jobs::populateTable() job_defaults job_defs; job_defs.job_name = jobName; if (m_console->get_job_defaults(job_defs)) { - int col = 0; - TableItemFormatter jobsItem(*tableWidget, row); - jobsItem.setTextFld(col++, jobName); - jobsItem.setTextFld(col++, job_defs.pool_name); - jobsItem.setTextFld(col++, job_defs.messages_name); - jobsItem.setTextFld(col++, job_defs.client_name); - jobsItem.setTextFld(col++, job_defs.store_name); - jobsItem.setTextFld(col++, job_defs.level); - jobsItem.setTextFld(col++, job_defs.type); - jobsItem.setTextFld(col++, job_defs.fileset_name); - jobsItem.setTextFld(col++, job_defs.catalog_name); - jobsItem.setBoolFld(col++, job_defs.enabled); - jobsItem.setTextFld(col++, job_defs.where); + int col = 0; + TableItemFormatter jobsItem(*tableWidget, row); + jobsItem.setTextFld(col++, jobName); + jobsItem.setTextFld(col++, job_defs.pool_name); + jobsItem.setTextFld(col++, job_defs.messages_name); + jobsItem.setTextFld(col++, job_defs.client_name); + jobsItem.setTextFld(col++, job_defs.store_name); + jobsItem.setTextFld(col++, job_defs.level); + jobsItem.setTextFld(col++, job_defs.type); + jobsItem.setTextFld(col++, job_defs.fileset_name); + jobsItem.setTextFld(col++, job_defs.catalog_name); + jobsItem.setBoolFld(col++, job_defs.enabled); + jobsItem.setTextFld(col++, job_defs.where); } row++; @@ -131,7 +131,9 @@ void Jobs::populateTable() for(int r=0; r < rcnt; r++) { for(int c=0; c < ccnt; c++) { QTableWidgetItem* item = tableWidget->item(r, c); - item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + if (item) { + item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable))); + } } } mainWin->waitExit(); diff --git a/bacula/src/qt-console/restore/restoretree.cpp b/bacula/src/qt-console/restore/restoretree.cpp index 748499de09..ef7a01ac07 100644 --- a/bacula/src/qt-console/restore/restoretree.cpp +++ b/bacula/src/qt-console/restore/restoretree.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. -- 2.39.5