- Dmsg3(100, "I'm going to wait for a device. HB=%d wait=%d remwait=%d\n",
- (int)me->heartbeat_interval, jcr->wait_sec, jcr->rem_wait_sec);
- start = time(NULL);
- /* Wait required time */
- stat = pthread_cond_timedwait(&wait_device_release, &device_release_mutex, &timeout);
- Dmsg1(100, "Wokeup from sleep on device stat=%d\n", stat);
-
- now = time(NULL);
- jcr->rem_wait_sec -= (now - start);
-
-#ifdef needed
- /* Note, this always triggers the first time. We want that. */
- if (me->heartbeat_interval) {
- if (now - last_heartbeat >= me->heartbeat_interval) {
- /* send heartbeats */
- if (jcr->file_bsock) {
- bnet_sig(jcr->file_bsock, BNET_HEARTBEAT);
- Dmsg0(400, "Send heartbeat to FD.\n");
- }
- if (jcr->dir_bsock) {
- bnet_sig(jcr->dir_bsock, BNET_HEARTBEAT);
- }
- last_heartbeat = now;
- }
- }
-#endif
-
- if (stat != ETIMEDOUT) { /* if someone woke us up */
- ok = true;
- break; /* allow caller to examine device */
- }
- if (jcr->rem_wait_sec <= 0) { /* on exceeding wait time return */
- Dmsg0(400, "Exceed wait time.\n");
- if (!double_jcr_wait_time(jcr)) {
- break; /* give up */
- }
- Jmsg(jcr, M_MOUNT, 0, _("Job %s waiting to obtain a device.\n"), jcr->Job);
- }
-
- add_wait = jcr->wait_sec - (now - start);
- if (add_wait < 0) {
- add_wait = 0;
- }
- if (me->heartbeat_interval && add_wait > me->heartbeat_interval) {
- add_wait = me->heartbeat_interval;
- }
- }
+ /* Wait required time */
+ stat = pthread_cond_timedwait(&wait_device_release, &device_release_mutex, &timeout);
+ Dmsg1(dbglvl, "Wokeup from sleep on device stat=%d\n", stat);