From: Kern Sibbald Date: Thu, 13 Sep 2007 21:47:10 +0000 (+0000) Subject: kes Add code to help Dan debug 2drive-incremental-2disk test. X-Git-Tag: Release-7.0.0~5676 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0dee96cf9f040437f2c59ed6e668675bdf3ed0bc;p=bacula%2Fbacula kes Add code to help Dan debug 2drive-incremental-2disk test. kes Add code to try to fix bug #908. kes Add waits to multiple exit detection code to try to force pid file to always be deleted. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5550 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 2b30c065c5..45ae5a6818 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -319,6 +319,7 @@ void terminate_dird(int sig) static bool already_here = false; if (already_here) { /* avoid recursive temination problems */ + bmicrosleep(2, 0); /* yield */ exit(1); } already_here = true; @@ -326,7 +327,6 @@ void terminate_dird(int sig) generate_daemon_event(NULL, "Exit"); write_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); delete_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); -// signal(SIGCHLD, SIG_IGN); /* don't worry about children now */ term_scheduler(); term_job_server(); if (runjob) { diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 3aa372472f..45b7fa7eb1 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -113,8 +113,11 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, /* * Now send JobId and authorization key */ - bnet_fsend(fd, jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, jcr->VolSessionId, + fd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, jcr->VolSessionId, jcr->VolSessionTime, jcr->sd_auth_key); + if (debug_level == 3) { + Dmsg1(000, ">filed: %s", fd->msg); + } if (strcmp(jcr->sd_auth_key, "dummy") != 0) { memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); } diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 935a9d08ab..b915f55290 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -191,6 +191,9 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore) Dmsg1(100, ">stored: %s\n", sd->msg); if (bget_dirmsg(sd) > 0) { Dmsg1(100, "msg); + if (debug_level == 3) { + Dmsg1(000, "msg); + } if (sscanf(sd->msg, OKjob, &jcr->VolSessionId, &jcr->VolSessionTime, &auth_key) != 3) { Dmsg1(100, "BadJob=%s\n", sd->msg); diff --git a/bacula/src/filed/authenticate.c b/bacula/src/filed/authenticate.c index 4ed53cdffc..00db82327b 100644 --- a/bacula/src/filed/authenticate.c +++ b/bacula/src/filed/authenticate.c @@ -225,6 +225,9 @@ int authenticate_storagedaemon(JCR *jcr) } /* Respond to SD challenge */ + if (debug_level == 3) { + Dmsg1(000, "sd_auth_key=%s\n", jcr->sd_auth_key); + } auth_success = cram_md5_respond(sd, jcr->sd_auth_key, &tls_remote_need, &compatible); if (job_canceled(jcr)) { auth_success = false; /* force quick exit */ @@ -273,6 +276,9 @@ int authenticate_storagedaemon(JCR *jcr) auth_fatal: /* Destroy session key */ memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); + if (debug_level == 3) { + Dmsg0(000, "zap sd_auth_key\n"); + } stop_bsock_timer(tid); /* Single thread all failures to avoid DOS */ if (!auth_success) { diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index 6852b0ccef..277e32d994 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -235,6 +235,7 @@ void terminate_filed(int sig) static bool already_here = false; if (already_here) { + bmicrosleep(2, 0); /* yield */ exit(1); /* prevent loops */ } already_here = true; diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index d8f0d00780..561297044b 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -406,7 +406,7 @@ static int setdebug_cmd(JCR *jcr) } debug_level = level; set_trace(trace_flag); - return bnet_fsend(dir, OKsetdebug, level); + return dir->fsend(OKsetdebug, level); } @@ -418,11 +418,11 @@ static int estimate_cmd(JCR *jcr) if (sscanf(dir->msg, estimatecmd, &jcr->listing) != 1) { pm_strcpy(jcr->errmsg, dir->msg); Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s"), jcr->errmsg); - bnet_fsend(dir, _("2992 Bad estimate command.\n")); + dir->fsend(_("2992 Bad estimate command.\n")); return 0; } make_estimate(jcr); - bnet_fsend(dir, OKest, jcr->num_files_examined, + dir->fsend(OKest, jcr->num_files_examined, edit_uint64_with_commas(jcr->JobBytes, ed2)); bnet_sig(dir, BNET_EOD); return 1; @@ -437,6 +437,9 @@ static int job_cmd(JCR *jcr) POOLMEM *sd_auth_key; sd_auth_key = get_memory(dir->msglen); + if (debug_level == 3) { + Dmsg1(000, "msg); + } if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job, &jcr->VolSessionId, &jcr->VolSessionTime, sd_auth_key) != 5) { @@ -447,9 +450,12 @@ static int job_cmd(JCR *jcr) return 0; } jcr->sd_auth_key = bstrdup(sd_auth_key); + if (debug_level == 3) { + Dmsg1(000, "sd_auth_key=%s\n", jcr->sd_auth_key); + } free_pool_memory(sd_auth_key); Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key); - return bnet_fsend(dir, OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER); + return dir->fsend(OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER); } static int runbefore_cmd(JCR *jcr) @@ -463,7 +469,7 @@ static int runbefore_cmd(JCR *jcr) if (sscanf(dir->msg, runbefore, cmd) != 1) { pm_strcpy(jcr->errmsg, dir->msg); Jmsg1(jcr, M_FATAL, 0, _("Bad RunBeforeJob command: %s\n"), jcr->errmsg); - bnet_fsend(dir, _("2905 Bad RunBeforeJob command.\n")); + dir->fsend(_("2905 Bad RunBeforeJob command.\n")); free_memory(cmd); return 0; } diff --git a/bacula/src/stored/authenticate.c b/bacula/src/stored/authenticate.c index f2c4485c30..d323084c2b 100644 --- a/bacula/src/stored/authenticate.c +++ b/bacula/src/stored/authenticate.c @@ -1,15 +1,7 @@ -/* - * Authenticate caller - * - * Kern Sibbald, October 2000 - * - * Version $Id$ - * - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 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. @@ -33,6 +25,15 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Authenticate caller + * + * Kern Sibbald, October 2000 + * + * Version $Id$ + * + */ + #include "bacula.h" #include "stored.h" @@ -208,6 +209,9 @@ int authenticate_filed(JCR *jcr) /* Timeout Hello after 5 mins */ btimer_t *tid = start_bsock_timer(fd, AUTH_TIMEOUT); /* Challenge FD */ + if (debug_level == 3) { + Pmsg1(000, "sd_auth_key=%s\n", jcr->sd_auth_key); + } auth_success = cram_md5_challenge(fd, jcr->sd_auth_key, tls_local_need, compatible); if (auth_success) { /* Respond to his challenge */ diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 2e2f39088b..d858e387c5 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -1844,7 +1844,8 @@ void DEVICE::close() /* Clean up device packet so it can be reused */ clear_opened(); - state &= ~(ST_LABEL|ST_READ|ST_APPEND|ST_EOT|ST_WEOT|ST_EOF); + state &= ~(ST_LABEL|ST_READ|ST_APPEND|ST_EOT|ST_WEOT|ST_EOF| + ST_MOUNTED|ST_MEDIA|ST_SHORT|ST_FREESPACE_OK|ST_PART_SPOOLED); label_type = B_BACULA_LABEL; file = block_num = 0; file_size = 0; diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index a0454fd97b..9fa0fce53d 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -91,7 +91,7 @@ bool job_cmd(JCR *jcr) &write_part_after_job, &PreferMountedVols); if (stat != 13) { pm_strcpy(jcr->errmsg, dir->msg); - bnet_fsend(dir, BAD_job, stat, jcr->errmsg); + dir->fsend(BAD_job, stat, jcr->errmsg); Dmsg1(100, ">dird: %s", dir->msg); set_jcr_job_status(jcr, JS_ErrorTerminated); return false; @@ -135,7 +135,10 @@ bool job_cmd(JCR *jcr) * Pass back an authorization key for the File daemon */ make_session_key(auth_key, NULL, 1); - bnet_fsend(dir, OKjob, jcr->VolSessionId, jcr->VolSessionTime, auth_key); + dir->fsend(OKjob, jcr->VolSessionId, jcr->VolSessionTime, auth_key); + if (debug_level == 3) { + Dmsg1(000, ">dird: %s", dir->msg); + } Dmsg1(100, ">dird: %s", dir->msg); jcr->sd_auth_key = bstrdup(auth_key); memset(auth_key, 0, sizeof(auth_key)); @@ -185,6 +188,9 @@ bool run_cmd(JCR *jcr) } V(mutex); + if (debug_level == 3) { + Dmsg0(000, "Zap sd_auth_key\n"); + } memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); if (jcr->authenticated && !job_canceled(jcr)) { @@ -274,9 +280,9 @@ bool query_cmd(JCR *jcr) } ok = dir_update_device(jcr, device->dev); if (ok) { - ok = bnet_fsend(dir, OK_query); + ok = dir->fsend(OK_query); } else { - bnet_fsend(dir, NO_query); + dir->fsend(NO_query); } return ok; } @@ -289,9 +295,9 @@ bool query_cmd(JCR *jcr) } ok = dir_update_changer(jcr, changer); if (ok) { - ok = bnet_fsend(dir, OK_query); + ok = dir->fsend(OK_query); } else { - bnet_fsend(dir, NO_query); + dir->fsend(NO_query); } return ok; } @@ -299,12 +305,12 @@ bool query_cmd(JCR *jcr) /* If we get here, the device/autochanger was not found */ unbash_spaces(dir->msg); pm_strcpy(jcr->errmsg, dir->msg); - bnet_fsend(dir, NO_device, dev_name.c_str()); + dir->fsend(NO_device, dev_name.c_str()); Dmsg1(100, ">dird: %s\n", dir->msg); } else { unbash_spaces(dir->msg); pm_strcpy(jcr->errmsg, dir->msg); - bnet_fsend(dir, BAD_query, jcr->errmsg); + dir->fsend(BAD_query, jcr->errmsg); Dmsg1(100, ">dird: %s\n", dir->msg); } @@ -322,7 +328,7 @@ void stored_free_jcr(JCR *jcr) { Dmsg1(900, "stored_free_jcr JobId=%u\n", jcr->JobId); if (jcr->file_bsock) { - bnet_close(jcr->file_bsock); + jcr->file_bsock->close(); jcr->file_bsock = NULL; } if (jcr->job_name) { diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 3a5eff611f..070e788d8f 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -534,6 +534,7 @@ void terminate_stored(int sig) JCR *jcr; if (in_here) { /* prevent loops */ + bmicrosleep(2, 0); /* yield */ exit(1); } in_here = true; diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 4ce2834e95..658c56473e 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,12 @@ General: 13Sep07 +kes Add code to help Dan debug 2drive-incremental-2disk test. +kes Add code to try to fix bug #908. +kes Add waits to multiple exit detection code to try to force pid + file to always be deleted. +kes Restore good dev.tar.gz to rescue set appropriate binary property. + This fixes bug #950. kes Fix seg fault in error exit of acquire_for_read after unsuccessfully trying to switch drives by checking for blocking before unblocking. Fixes bug #906.