aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-02-03 17:07:32 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-03-11 15:41:42 +0100
commit767e24572db2bbc4b9837c32ffc0bab4e1ad0b81 (patch)
treecc2f361240799bb0b25f9fef83c8a24791b443ea
parent69fedd655a87c32c0c54eac46a1d6df7450873d6 (diff)
downloadlibnitrokey-767e24572db2bbc4b9837c32ffc0bab4e1ad0b81.tar.gz
libnitrokey-767e24572db2bbc4b9837c32ffc0bab4e1ad0b81.tar.bz2
Disconnect device as soon as the communication issue appears
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--include/device_proto.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/device_proto.h b/include/device_proto.h
index 9401428..1e07277 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -243,10 +243,13 @@ namespace nitrokey {
int sending_retry_counter = dev->get_retry_sending_count();
while (sending_retry_counter-- > 0) {
status = dev->send(&outp);
- if (status <= 0)
+ if (status <= 0){
+ Log::instance()("Encountered communication error, disconnecting device", Loglevel::DEBUG_L2);
+ dev->disconnect();
throw DeviceSendingFailure(
std::string("Device error while sending command ") +
std::to_string(status));
+ }
std::this_thread::sleep_for(dev->get_send_receive_delay());