Skip to content

Commit

Permalink
Change close method of DEV class to return if it failed or not.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent b621db4 commit a20c11c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/stored/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,9 @@ void DEVICE::clear_volhdr()
/*
* Close the device.
*/
void DEVICE::close(DCR *dcr)
bool DEVICE::close(DCR *dcr)
{
bool retval = true;
int status;
Dmsg1(100, "close_dev %s\n", print_name());

Expand All @@ -888,21 +889,25 @@ void DEVICE::close(DCR *dcr)

if (!is_open()) {
Dmsg2(100, "device %s already closed vol=%s\n", print_name(), VolHdr.VolumeName);
return; /* already closed */
goto bail_out; /* already closed */
}

switch (dev_type) {
case B_VTL_DEV:
case B_TAPE_DEV:
unlock_door();
/* Fall through wanted */
/*
* Fall through wanted
*/
default:
status = d_close(m_fd);
if (status < 0) {
berrno be;

Mmsg2(errmsg, _("Unable to close device %s. ERR=%s\n"), print_name(), be.bstrerror());
Jmsg(dcr->jcr, M_FATAL, 0, errmsg);
Mmsg2(errmsg, _("Unable to close device %s. ERR=%s\n"),
print_name(), be.bstrerror());
dev_errno = errno;
retval = false;
}
break;
}
Expand All @@ -928,6 +933,9 @@ void DEVICE::close(DCR *dcr)
stop_thread_timer(tid);
tid = 0;
}

bail_out:
return retval;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/stored/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class DEVICE: public SMARTALLOC {
const char *mode_to_str(int mode);
void set_unload();
void clear_volhdr();
void close(DCR *dcr);
bool close(DCR *dcr);
bool open(DCR *dcr, int mode);
void term();
ssize_t read(void *buf, size_t len);
Expand Down

0 comments on commit a20c11c

Please sign in to comment.