Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows SPTI timeout value is in seconds, not milliseconds. #11

Closed
wants to merge 1 commit into from

Conversation

ZakDanger
Copy link
Contributor

Windows SPTI timeout value is in seconds, not milliseconds.. So changed 3000 to 3.

from: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddscsi/ns-ntddscsi-_scsi_pass_through_direct

"""
TimeOutValue
Indicates the interval in seconds that the request can execute before the OS-specific port driver might consider it timed out.
"""

@TkTech
Copy link
Owner

TkTech commented Jun 7, 2024

Great catch! Since we kind of want to keep the SCSIDevice interface consistent, what do you think about doing this instead?

Index: smartie/scsi/windows.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/smartie/scsi/windows.py b/smartie/scsi/windows.py
--- a/smartie/scsi/windows.py	(revision 0a30edfee9e15907cb2a14bc52479291f7f99249)
+++ b/smartie/scsi/windows.py	(date 1717773398837)
@@ -63,7 +63,10 @@
                 data_buffer=ctypes.addressof(data),
                 cdb_length=ctypes.sizeof(command),
                 cdb=cdb,
-                timeout_value=timeout,
+                # While most platforms use a timeout in milliseconds, Windows
+                # uses a timeout in seconds. A timeout of 0 makes little
+                # sense, so we set a minimum of 1 second.
+                timeout_value=max(timeout // 1000, 1),
                 sense_info_length=SCSIPassThroughDirectWithBuffer.sense.size,
                 sense_info_offset=(
                     SCSIPassThroughDirectWithBuffer.sense.offset

@ZakDanger
Copy link
Contributor Author

Your changed fix looks good

@TkTech TkTech closed this Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants