/*
Bacula® - The Network Backup Solution
- Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2003-2008 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.
pthread_t id;
/*
- * if any threads are idle, wake one --
- * actually we do a broadcast because on /lib/tls
+ * if any threads are idle, wake one.
+ * Actually we do a broadcast because on /lib/tls
* these signals seem to get lost from time to time.
*/
if (jq->idle_workers > 0) {
*/
if (jcr->acquired_resource_locks) {
if (jcr->rstore) {
- jcr->rstore->NumConcurrentJobs = 0;
+ jcr->rstore->NumConcurrentJobs--;
Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
+ ASSERT(jcr->rstore->NumConcurrentJobs >= 0);
}
if (jcr->wstore) {
jcr->wstore->NumConcurrentJobs--;
Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
+ ASSERT(jcr->wstore->NumConcurrentJobs >= 0);
}
jcr->client->NumConcurrentJobs--;
jcr->job->NumConcurrentJobs--;
bool skip_this_jcr = false;
jcr->acquired_resource_locks = false;
+ if (jcr->rstore == jcr->wstore) { /* deadlock */
+ Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
+ " Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
+ jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
+ set_jcr_job_status(jcr, JS_Canceled);
+ return false;
+ }
if (jcr->rstore) {
Dmsg1(200, "Rstore=%s\n", jcr->rstore->name());
- /*
- * Let only one Restore/Verify job run at a time regardless
- * of MaxConcurrentjobs.
- */
- if (jcr->rstore->NumConcurrentJobs == 0) {
+ if (jcr->rstore->NumConcurrentJobs == 0 &&
+ jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) {
+ /* Simple case, first job */
jcr->rstore->NumConcurrentJobs = 1;
Dmsg0(200, "Set rncj=1\n");
+ /* We can do this only if multi-drive autochanger */
+// } else if (jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) {
+// jcr->rstore->NumConcurrentJobs++;
+// Dmsg1(200, "Inc rncj=%d\n", jcr->rstore->NumConcurrentJobs);
} else {
Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->NumConcurrentJobs);
set_jcr_job_status(jcr, JS_WaitStoreRes);
if (jcr->wstore) {
Dmsg1(200, "Wstore=%s\n", jcr->wstore->name());
- if (jcr->rstore == jcr->wstore) { /* deadlock */
- jcr->rstore->NumConcurrentJobs = 0; /* back out rstore */
- Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
- " Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
- jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
- set_jcr_job_status(jcr, JS_Canceled);
- return false;
- }
if (jcr->wstore->NumConcurrentJobs == 0 &&
jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) {
/* Simple case, first job */
jcr->wstore->NumConcurrentJobs++;
Dmsg1(200, "Inc wncj=%d\n", jcr->wstore->NumConcurrentJobs);
} else if (jcr->rstore) {
- jcr->rstore->NumConcurrentJobs = 0; /* back out rstore */
+ jcr->rstore->NumConcurrentJobs--; /* back out rstore */
Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
+ ASSERT(jcr->rstore->NumConcurrentJobs >= 0);
skip_this_jcr = true;
} else {
Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
if (jcr->wstore) {
jcr->wstore->NumConcurrentJobs--;
Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
+ ASSERT(jcr->wstore->NumConcurrentJobs >= 0);
}
if (jcr->rstore) {
- jcr->rstore->NumConcurrentJobs = 0;
+ jcr->rstore->NumConcurrentJobs--;
Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
+ ASSERT(jcr->rstore->NumConcurrentJobs >= 0);
}
set_jcr_job_status(jcr, JS_WaitClientRes);
return false;
if (jcr->wstore) {
jcr->wstore->NumConcurrentJobs--;
Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
+ ASSERT(jcr->wstore->NumConcurrentJobs >= 0);
}
if (jcr->rstore) {
- jcr->rstore->NumConcurrentJobs = 0;
+ jcr->rstore->NumConcurrentJobs--;
Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
+ ASSERT(jcr->rstore->NumConcurrentJobs >= 0);
}
jcr->client->NumConcurrentJobs--;
set_jcr_job_status(jcr, JS_WaitJobRes);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 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.
bool bnet_tls_server(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list)
{
TLS_CONNECTION *tls;
+ JCR *jcr = bsock->jcr();
tls = new_tls_connection(ctx, bsock->m_fd);
if (!tls) {
}
if (verify_list) {
- if (!tls_postconnect_verify_cn(tls, verify_list)) {
+ if (!tls_postconnect_verify_cn(jcr, tls, verify_list)) {
Qmsg1(bsock->jcr(), M_FATAL, 0, _("TLS certificate verification failed."
" Peer certificate did not match a required commonName\n"),
bsock->host());
bool bnet_tls_client(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list)
{
TLS_CONNECTION *tls;
+ JCR *jcr = bsock->jcr();
tls = new_tls_connection(ctx, bsock->m_fd);
if (!tls) {
/* If there's an Allowed CN verify list, use that to validate the remote
* certificate's CN. Otherwise, we use standard host/CN matching. */
if (verify_list) {
- if (!tls_postconnect_verify_cn(tls, verify_list)) {
+ if (!tls_postconnect_verify_cn(jcr, tls, verify_list)) {
Qmsg1(bsock->jcr(), M_FATAL, 0, _("TLS certificate verification failed."
" Peer certificate did not match a required commonName\n"),
bsock->host());
goto err;
}
} else {
- if (!tls_postconnect_verify_host(tls, bsock->host())) {
+ if (!tls_postconnect_verify_host(jcr, tls, bsock->host())) {
Qmsg1(bsock->jcr(), M_FATAL, 0, _("TLS host certificate verification failed. Host %s did not match presented certificate\n"),
bsock->host());
goto err;
* Returns: true on success
* false on failure
*/
-bool tls_postconnect_verify_cn(TLS_CONNECTION *tls, alist *verify_list)
+bool tls_postconnect_verify_cn(JCR *jcr, TLS_CONNECTION *tls, alist *verify_list)
{
SSL *ssl = tls->openssl;
X509 *cert;
/* Check if peer provided a certificate */
if (!(cert = SSL_get_peer_certificate(ssl))) {
- Jmsg0(NULL, M_ERROR, 0, _("Peer failed to present a TLS certificate\n"));
+ Qmsg0(jcr, M_ERROR, 0, _("Peer failed to present a TLS certificate\n"));
return false;
}
* Returns: true on success
* false on failure
*/
-bool tls_postconnect_verify_host(TLS_CONNECTION *tls, const char *host)
+bool tls_postconnect_verify_host(JCR *jcr, TLS_CONNECTION *tls, const char *host)
{
SSL *ssl = tls->openssl;
X509 *cert;
/* Check if peer provided a certificate */
if (!(cert = SSL_get_peer_certificate(ssl))) {
- Jmsg1(NULL, M_ERROR, 0,
+ Qmsg1(jcr, M_ERROR, 0,
_("Peer %s failed to present a TLS certificate\n"), host);
return false;
}