+ /*
+ * Authenticate the File daemon
+ */
+ Dmsg0(050, "=== Authenticate FD\n");
+ if (jcr->authenticated || !authenticate_filed(jcr, jcr->file_bsock, jcr->FDVersion)) {
+ Dmsg1(050, "Authentication failed Job %s\n", jcr->Job);
+ Jmsg(jcr, M_FATAL, 0, _("Unable to authenticate File daemon\n"));
+ } else {
+ jcr->authenticated = true;
+ }
+ } else if (!jcr->sd_client) {
+ /* We wait to receive connection from Client */
+ gettimeofday(&tv, &tz);
+ timeout.tv_nsec = tv.tv_usec * 1000;
+ timeout.tv_sec = tv.tv_sec + me->client_wait;
+
+ Dmsg3(050, "%s waiting %d sec for FD to contact SD key=%s\n",
+ jcr->Job, (int)(timeout.tv_sec-time(NULL)), jcr->sd_auth_key);
+
+ Dmsg3(800, "=== Block Job=%s jid=%d %p\n", jcr->Job, jcr->JobId, jcr);
+
+ /*
+ * Wait for the File daemon to contact us to start the Job,
+ * when he does, we will be released, unless the 30 minutes
+ * expires.
+ */
+ P(mutex);
+ while ( !jcr->authenticated && !job_canceled(jcr) ) {
+ errstat = pthread_cond_timedwait(&jcr->job_start_wait, &mutex, &timeout);
+ if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) {
+ break;
+ }
+ Dmsg1(800, "=== Auth cond errstat=%d\n", errstat);
+ }
+ Dmsg4(050, "=== Auth=%d jid=%d canceled=%d errstat=%d\n",
+ jcr->JobId, jcr->authenticated, job_canceled(jcr), errstat);
+ V(mutex);
+ Dmsg2(800, "Auth fail or cancel for jid=%d %p\n", jcr->JobId, jcr);