*/
int bget_dirmsg(BSOCK *bs)
{
- int32_t n;
+ int32_t n = BNET_TERMINATE;
char Job[MAX_NAME_LENGTH];
char MsgType[20];
int type;
JCR *jcr = bs->jcr();
char *msg;
- for (;;) {
+ for ( ; !bs->is_stop() && !bs->is_timed_out(); ) {
n = bs->recv();
Dmsg2(100, "bget_dirmsg %d: %s\n", n, bs->msg);
- if (is_bnet_stop(bs)) {
+ if (bs->is_stop() || bs->is_timed_out()) {
return n; /* error or terminate */
}
if (n == BNET_SIGNAL) { /* handle signal */
#endif
return n;
}
+ return n;
}
static char *find_msg_start(char *msg)
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2010 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.
*
* Kern Sibbald, October MM
*
- * Version $Id$
*/
#include "bacula.h"
fd->signal(BNET_TERMINATE);
fd->close();
ua->jcr->file_bsock = NULL;
+ jcr->file_bsock->set_terminated();
+ if (jcr->my_thread_id) {
+ pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
+ Dmsg1(800, "Send kill to jid=%d\n", jcr->JobId);
+ }
}
/* Cancel Storage daemon */
sd->signal(BNET_TERMINATE);
sd->close();
ua->jcr->store_bsock = NULL;
+ jcr->store_bsock->set_terminated();
+ if (jcr->my_thread_id) {
+ pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
+ }
}
break;
}
if (job->AllowDuplicateJobs) {
return true;
}
+ Dmsg0(800, "Enter allow_duplicate_job\n");
/*
* After this point, we do not want to allow any duplicate
* job to run.
}
if (strcmp(job->name(), djcr->job->name()) == 0) {
bool cancel_dup = false;
- bool cancel_me = false;
+ bool cancel_me = false;
if (job->DuplicateJobProximity > 0) {
utime_t now = (utime_t)time(NULL);
if ((now - djcr->start_time) > job->DuplicateJobProximity) {
}
if (cancel_dup || job->CancelRunningDuplicates) {
/* Zap the duplicated job djcr */
- UAContext *ua = new_ua_context(djcr);
+ UAContext *ua = new_ua_context(jcr);
Jmsg(jcr, M_INFO, 0, _("Cancelling duplicate JobId=%d.\n"), djcr->JobId);
- ua->jcr = djcr;
cancel_job(ua, djcr);
free_ua_context(ua);
- Dmsg2(800, "Have cancelled JCR %p JobId=%d\n", djcr, djcr->JobId);
+ if (djcr->my_thread_id) {
+ pthread_kill(djcr->my_thread_id, TIMEOUT_SIGNAL);
+ Dmsg1(800, "Send kill to jid=%d\n", djcr->JobId);
+ }
+ Dmsg2(800, "Cancel dup %p JobId=%d\n", djcr, djcr->JobId);
} else {
/* Zap current job */
Jmsg(jcr, M_FATAL, 0, _("JobId %d already running. Duplicate job not allowed.\n"),
djcr->JobId);
+ Dmsg2(800, "Cancel me %p JobId=%d\n", jcr, jcr->JobId);
}
+ Dmsg4(800, "curJobId=%d use_cnt=%d dupJobId=%d use_cnt=%d\n",
+ jcr->JobId, jcr->use_count(), djcr->JobId, djcr->use_count());
break; /* did our work, get out of foreach loop */
}
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2010 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.
*
* Kern Sibbald, May MMI
*
- * Version $Id$
- *
*/
#include "bacula.h"
extern bool init_done;
/* Static variables */
-static char derrmsg[] = "3900 Invalid command\n";
+static char derrmsg[] = "3900 Invalid command:";
static char OKsetdebug[] = "3000 OK setdebug=%d\n";
static char invalid_cmd[] = "3997 Invalid command for a Director with Monitor directive enabled.\n";
static char OK_bootstrap[] = "3000 OK bootstrap\n";
}
}
if (!found) { /* command not found */
- bs->fsend(derrmsg);
+ POOL_MEM err_msg;
+ Mmsg(err_msg, "%s %s\n", derrmsg, bs->msg);
+ bs->fsend(err_msg.c_str());
break;
}
}
} else {
oldStatus = jcr->JobStatus;
set_jcr_job_status(jcr, JS_Canceled);
+ Dmsg2(800, "Cancel JobId=%d %p\n", jcr->JobId, jcr);
if (!jcr->authenticated && oldStatus == JS_WaitFD) {
pthread_cond_signal(&jcr->job_start_wait); /* wake waiting thread */
}
if (jcr->file_bsock) {
- bnet_sig(jcr->file_bsock, BNET_TERMINATE);
+ jcr->file_bsock->signal(BNET_TERMINATE);
+ jcr->file_bsock->set_terminated();
+ Dmsg2(800, "Term bsock jid=%d %p\n", jcr->JobId, jcr);
} else {
/* Still waiting for FD to connect, release it */
+ bmicrosleep(0, 50000);
pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */
+ Dmsg2(800, "Signal FD connect jid=%d %p\n", jcr->JobId, jcr);
}
/* If thread waiting on mount, wake him */
if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->waiting_for_mount()) {