Skip to content

Commit

Permalink
Fixes an issue where a semaphore timeout would cause a command execut…
Browse files Browse the repository at this point in the history
…ion to return a nil result and a nil error at the same time.
  • Loading branch information
jensutbult committed Nov 20, 2024
1 parent 72728a9 commit ec4ed90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ - (void)execute:(nonnull YKFAPDU *)command timeout:(NSTimeInterval)timeout compl
}];

// Lock the async call to enforce the sequential execution using the library dispatch queue.
dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC)));
if(dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC))) != 0) {
executionError = [YKFSessionError errorWithCode:YKFSessionErrorReadTimeoutCode];
}

// Do not notify if the operation was canceled.
if (operation.isCancelled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ - (void)execute:(nonnull YKFAPDU *)command timeout:(NSTimeInterval)timeout compl
}];

// Lock the async call to enforce the sequential execution using the library dispatch queue.
dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC)));
if(dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC))) != 0) {
executionError = [YKFSessionError errorWithCode:YKFSessionErrorReadTimeoutCode];
}

// Do not notify if the operation was canceled.
if (operation.isCancelled) {
Expand Down

0 comments on commit ec4ed90

Please sign in to comment.