From: Kern Sibbald Date: Fri, 19 Mar 2004 11:13:58 +0000 (+0000) Subject: Eliminate zombie job in SD X-Git-Tag: Release-7.0.0~9616 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cc4be3a7c0b43ad093d008707277de22ddffc4a3;p=bacula%2Fbacula Eliminate zombie job in SD git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1142 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 7618ec6932..ce801ee496 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -390,6 +390,7 @@ static void list_running_jobs(UAContext *ua) bool pool_mem = false; Dmsg0(200, "enter list_run_jobs()\n"); + bsendmsg(ua, _("Running Jobs:\n")); lock_jcr_chain(); foreach_jcr(jcr) { njobs++; @@ -407,7 +408,8 @@ static void list_running_jobs(UAContext *ua) } if (njobs == 0) { unlock_jcr_chain(); - bsendmsg(ua, _("No Running Jobs.\n")); + /* Note the following message is used in regress -- don't change */ + bsendmsg(ua, _("No Jobs running.\n====\n")); Dmsg0(200, "leave list_run_jobs()\n"); return; } @@ -535,7 +537,7 @@ static void list_running_jobs(UAContext *ua) free_locked_jcr(jcr); } unlock_jcr_chain(); - bsendmsg(ua, "\n"); + bsendmsg(ua, "====\n"); Dmsg0(200, "leave list_run_jobs()\n"); } diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index b588282485..32e50a5da6 100755 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -87,6 +87,8 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a * List running jobs */ Dmsg0(1000, "Begin status jcr loop.\n"); + len = Mmsg(&msg, _("Running Jobs:\n")); + sendit(msg, len, arg); lock_jcr_chain(); foreach_jcr(njcr) { bstrftime_nc(dt, sizeof(dt), njcr->start_time); @@ -138,9 +140,11 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a unlock_jcr_chain(); Dmsg0(1000, "Begin status jcr loop.\n"); if (!found) { - len = Mmsg(&msg, _("No jobs running.\n")); + len = Mmsg(&msg, _("No Jobs running.\n")); sendit(msg, len, arg); } + len = Mmsg(&msg, _("====\n")); + sendit(msg, len, arg); free_pool_memory(msg); } diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index d05b2fe30d..bc800d4a8d 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -166,6 +166,7 @@ int dir_find_next_appendable_volume(JCR *jcr) lock_jcr_chain(); foreach_jcr(njcr) { if (jcr == njcr) { + free_locked_jcr(njcr); continue; /* us */ } Dmsg2(200, "Compare to JobId=%d using Vol=%s\n", njcr->JobId, njcr->VolumeName); diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index afb880c585..218c655e91 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -232,6 +232,7 @@ static int unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) block->BlockVer = 1; block->bufp = block->buf + bhl; if (strncmp(Id, BLKHDR1_ID, BLKHDR_ID_LENGTH) != 0) { + dev->dev_errno = EIO; Mmsg2(&dev->errmsg, _("Volume data error! Wanted ID: %s, got %s. Buffer discarded.\n"), BLKHDR1_ID, Id); if (block->read_errors == 0 || verbose >= 2) { @@ -247,6 +248,7 @@ static int unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) block->BlockVer = 2; block->bufp = block->buf + bhl; if (strncmp(Id, BLKHDR2_ID, BLKHDR_ID_LENGTH) != 0) { + dev->dev_errno = EIO; Mmsg2(&dev->errmsg, _("Volume data error! Wanted ID: %s, got %s. Buffer discarded.\n"), BLKHDR2_ID, Id); if (block->read_errors == 0 || verbose >= 2) { @@ -256,6 +258,7 @@ static int unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) return 0; } } else { + dev->dev_errno = EIO; Mmsg1(&dev->errmsg, _("Volume data error! Wanted block-id BB02, got %s. Buffer discarded.\n"), Id); if (block->read_errors == 0 || verbose >= 2) { Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -266,6 +269,7 @@ static int unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) /* Sanity check */ if (block_len > MAX_BLOCK_LENGTH) { + dev->dev_errno = EIO; Mmsg1(&dev->errmsg, _("Volume data error! Block length %u is insane (too large), probably due to a bad archive.\n"), block_len); if (block->read_errors == 0 || verbose >= 2) { @@ -291,6 +295,7 @@ static int unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) BlockCheckSum = bcrc32((uint8_t *)block->buf+BLKHDR_CS_LENGTH, block_len-BLKHDR_CS_LENGTH); if (BlockCheckSum != CheckSum) { + dev->dev_errno = EIO; Mmsg3(&dev->errmsg, _("Volume data error! Block checksum mismatch in block %u: calc=%x blk=%x\n"), (unsigned)BlockNumber, BlockCheckSum, CheckSum); if (block->read_errors == 0 || verbose >= 2) { @@ -335,6 +340,7 @@ int write_block_to_device(DCR *dcr, DEV_BLOCK *block) if (dcr->NewVol || dcr->NewFile) { /* Create a jobmedia record for this job */ if (!dir_create_jobmedia_record(jcr)) { + dev->dev_errno = EIO; Jmsg(jcr, M_ERROR, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), jcr->VolCatInfo.VolCatName, jcr->Job); set_new_volume_parameters(jcr, dev); @@ -385,6 +391,7 @@ int write_block_to_dev(DCR *dcr, DEV_BLOCK *block) /* dump_block(block, "before write"); */ if (dev->state & ST_WEOT) { Dmsg0(100, "return write_block_to_dev with ST_WEOT\n"); + dev->dev_errno = ENOSPC; Jmsg(jcr, M_FATAL, 0, _("Cannot write block. Device at EOM.\n")); return 0; } @@ -450,6 +457,7 @@ int write_block_to_dev(DCR *dcr, DEV_BLOCK *block) dev->VolCatInfo.VolCatErrors++; } dev->state |= (ST_EOF | ST_EOT | ST_WEOT); + dev->dev_errno = ENOSPC; return 0; } @@ -466,6 +474,7 @@ int write_block_to_dev(DCR *dcr, DEV_BLOCK *block) Dmsg0(100, "dir_update_volume_info\n"); dev->VolCatInfo.VolCatFiles = dev->file; dir_update_volume_info(jcr, dev, 0); + dev->dev_errno = ENOSPC; return 0; } @@ -474,6 +483,7 @@ int write_block_to_dev(DCR *dcr, DEV_BLOCK *block) dev->VolCatInfo.VolCatFiles = dev->file; dir_update_volume_info(jcr, dev, 0); if (!dir_create_jobmedia_record(jcr)) { + dev->dev_errno = EIO; Jmsg(jcr, M_ERROR, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), dcr->VolCatInfo.VolCatName, jcr->Job); return 0; @@ -666,6 +676,7 @@ int read_block_from_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_bloc block->buf_len); reread: if (looping > 1) { + dev->dev_errno = EIO; Mmsg1(&dev->errmsg, _("Block buffer size looping problem on device %s\n"), dev->dev_name); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -709,6 +720,7 @@ reread: /* Continue here for successful read */ block->read_len = stat; /* save length read */ if (block->read_len < BLKHDR2_LENGTH) { + dev->dev_errno = EIO; Mmsg2(&dev->errmsg, _("Volume data error! Very short block of %d bytes on device %s discarded.\n"), block->read_len, dev->dev_name); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -729,6 +741,7 @@ reread: * and go re-read. */ if (block->block_len > block->buf_len) { + dev->dev_errno = EIO; Mmsg2(&dev->errmsg, _("Block length %u is greater than buffer %u. Attempting recovery.\n"), block->block_len, block->buf_len); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); @@ -762,6 +775,7 @@ reread: } if (block->block_len > block->read_len) { + dev->dev_errno = EIO; Mmsg3(&dev->errmsg, _("Volume data error! Short block at %u of %d bytes on device %s discarded.\n"), dev->block_num, block->read_len, dev->dev_name); Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index 68aa67d4d0..2c56ba5c02 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -81,7 +81,7 @@ int status_cmd(JCR *jcr) /* * List devices */ - bnet_fsend(user, _("Device status:\n")); + bnet_fsend(user, _("\nDevice status:\n")); LockRes(); foreach_res(device, R_DEVICE) { for (dev=device->dev; dev; dev=dev->next) { @@ -264,7 +264,7 @@ static void list_running_jobs(BSOCK *user) } unlock_jcr_chain(); if (!found) { - bnet_fsend(user, _("No jobs running.\n")); + bnet_fsend(user, _("No Jobs running.\n")); } bnet_fsend(user, "====\n"); } @@ -342,7 +342,7 @@ static void list_terminated_jobs(void *arg) dt, JobName); sendit(buf, strlen(buf), arg); } - sendit("====\n", 1, arg); + sendit("====\n", 5, arg); unlock_last_jobs_list(); } diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index ae82a14028..366be796c5 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -290,13 +290,12 @@ static void check_config() */ static void *device_allocation(void *arg) { - int i; DEVRES *device; LockRes(); pthread_detach(pthread_self()); - for (device=NULL,i=0; (device=(DEVRES *)GetNextRes(R_DEVICE, (RES *)device)); i++) { + foreach_res(device, R_DEVICE) { Dmsg1(90, "calling init_dev %s\n", device->device_name); device->dev = init_dev(NULL, device); Dmsg1(10, "SD init done %s\n", device->device_name); @@ -353,7 +352,7 @@ void terminate_stored(int sig) * volume status. */ lock_jcr_chain(); - for (jcr=NULL; (jcr=get_next_jcr(jcr)); ) { + foreach_jcr(jcr) { BSOCK *fd; free_locked_jcr(jcr); if (jcr->JobId == 0) { @@ -381,7 +380,7 @@ void terminate_stored(int sig) Dmsg1(200, "In terminate_stored() sig=%d\n", sig); LockRes(); - for (device=NULL; (device=(DEVRES *)GetNextRes(R_DEVICE, (RES *)device)); ) { + foreach_res(device, R_DEVICE) { if (device->dev) { term_dev(device->dev); } diff --git a/bacula/src/version.h b/bacula/src/version.h index 81a889092d..14779d9cc0 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.33.4" #define VSTRING "1" -#define BDATE "18 Mar 2004" -#define LSMDATE "18Mar04" +#define BDATE "19 Mar 2004" +#define LSMDATE "19Mar04" /* Debug flags */ #undef DEBUG