Session: reinit ioctl data before sending it again.

The structure is used as input and output from ioctl, so we must clean
it before doing the ioctl for the second try.

May fix #11477.
This commit is contained in:
Adrien Destugues
2014-11-17 09:22:17 +01:00
parent 8d67965f06
commit 4ecb74f198
@@ -248,6 +248,8 @@ read_table_of_contents(int deviceFD, uint32 first_session, uchar* buffer,
if (error) if (error)
return error; return error;
// This does not always work on the first try, so do it twice just in case.
for (int attempt = 0; attempt < 2; attempt++) {
// Init the scsi command and copy it into the "raw scsi command" // Init the scsi command and copy it into the "raw scsi command"
// ioctl struct // ioctl struct
memset(raw_command.command, 0, 16); memset(raw_command.command, 0, 16);
@@ -275,8 +277,6 @@ read_table_of_contents(int deviceFD, uint32 first_session, uchar* buffer,
memset(raw_command.sense_data, 0, raw_command.sense_data_length); memset(raw_command.sense_data, 0, raw_command.sense_data_length);
raw_command.timeout = kScsiTimeout; raw_command.timeout = kScsiTimeout;
// This does not always work on the first try, so do it twice just in case.
for (int attempt = 0; attempt < 2; attempt++) {
if (ioctl(deviceFD, B_RAW_DEVICE_COMMAND, &raw_command) == 0) { if (ioctl(deviceFD, B_RAW_DEVICE_COMMAND, &raw_command) == 0) {
if (raw_command.scsi_status == 0 && raw_command.cam_status == 1) { if (raw_command.scsi_status == 0 && raw_command.cam_status == 1) {
// SUCCESS!!! // SUCCESS!!!