Imported Upstream version 3.3.2
[debian/amanda] / perl / Amanda / Changer / ndmp.pm
index 29c16b364c79c00804ec197baecdcdab5cca32fb..0314d326423698f7cfdd5b62f7f959fb657dbaeb 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2009,2010 Zmanda, Inc.  All Rights Reserved.
+# Copyright (c) 2009-2012 Zmanda, Inc.  All Rights Reserved.
 #
 # This library is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License version 2.1 as
@@ -110,6 +110,7 @@ sub get_device {
 
 package Amanda::Changer::ndmp::Interface;
 
+use Carp;
 use Amanda::NDMP qw( :constants );
 use Amanda::Debug qw( debug warning );
 use Amanda::MainLoop;
@@ -208,13 +209,13 @@ sub status {
 send_cdb:
     my $res = $conn->scsi_execute_cdb(
        flags => $NDMP9_SCSI_DATA_DIR_IN,
-       timeout => 2*1000,
+       timeout => 60*1000, # 60-second timeout
        cdb => pack('CCnnCCnxC',
            0xB8, # opcode
            0x10, # VOLTAG, all element types
            0, # start at addr 0
            0xffff, # and give me 65535 elements
-           0, # CURDATA=0, so don't do an inventory
+           2, # CURDATA=1, so the robot should use its cached state
            $bufsize >> 16, # allocation length high byte
            $bufsize & 0xffff, # allocation length low short
            0), # control
@@ -422,9 +423,9 @@ sub _parse_read_element_status {
        my $all_descrips_len = ($all_descrips_len_msb << 16) + $all_descrips_len_lsw;
        my $have_pvoltag = $flags & 0x80;
        my $have_avoltag = $flags & 0x40;
-       die unless $all_descrips_len % $descrip_len == 0;
-       die unless $all_descrips_len >= $descrip_len;
-       die length($data) unless $all_descrips_len <= length($data);
+       confess unless $all_descrips_len % $descrip_len == 0;
+       confess unless $all_descrips_len >= $descrip_len;
+       confess (length($data)) unless $all_descrips_len <= length($data);
        $data = substr($data, 8);
 
        while ($all_descrips_len > 0) { # for each element status descriptor