Skip to content

Commit

Permalink
Fixed timeout not triggered, gardening
Browse files Browse the repository at this point in the history
  • Loading branch information
amosavian committed Jul 19, 2018
1 parent eaa1a5d commit 53384ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion AMSMB2.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "AMSMB2"
s.version = "1.4.0"
s.version = "1.5.0"
s.summary = "Swift framework to connect SMB2/3 shares"

# This description is used to generate tags and improve search results.
Expand Down
26 changes: 13 additions & 13 deletions AMSMB2/Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ extension SMB2Context {
// MARK: Async operation handler
extension SMB2Context {
private struct CBData {
var result: Int32 = 0
var result: Int32 = SMB2_STATUS_SUCCESS
var isFinished: Bool = false
var commandData: UnsafeMutableRawPointer? = nil

Expand Down Expand Up @@ -275,14 +275,13 @@ extension SMB2Context {
}

if pfd.revents == 0 {
if timeout > 0, Date().timeIntervalSince(startDate) > timeout {
throw POSIXError(.ETIMEDOUT)
}
continue
}

try service(revents: Int32(pfd.revents))

if timeout > 0, Date().timeIntervalSince(startDate) > timeout {
throw POSIXError(.ETIMEDOUT)
}
}
}

Expand All @@ -304,13 +303,13 @@ extension SMB2Context {
}
try POSIXError.throwIfError(result, description: error, default: .ECONNRESET)
try wait_for_reply(cbPtr)
let cbresult = cbPtr.bindMemory(to: CBData.self, capacity: 1).pointee.result
try POSIXError.throwIfError(cbresult, description: error, default: defaultError)
let cbResult = cbPtr.bindMemory(to: CBData.self, capacity: 1).pointee.result
try POSIXError.throwIfError(cbResult, description: error, default: defaultError)
let data = cbPtr.bindMemory(to: CBData.self, capacity: 1).pointee.commandData
return (cbresult, data)
return (cbResult, data)
}

func async_await_pdu(defaultError: POSIXError.Code, execute handler: (_ context: UnsafeMutablePointer<smb2_context>, _ cbPtr: UnsafeMutableRawPointer) -> UnsafeMutablePointer<smb2_pdu>?) throws -> (result: Int32, data: UnsafeMutableRawPointer?) {
func async_await_pdu(defaultError: POSIXError.Code, execute handler: (_ context: UnsafeMutablePointer<smb2_context>, _ cbPtr: UnsafeMutableRawPointer) -> UnsafeMutablePointer<smb2_pdu>?) throws -> (result: UInt32, data: UnsafeMutableRawPointer?) {
let cbPtr = CBData.initPointer()
defer {
cbPtr.deallocate()
Expand All @@ -324,12 +323,13 @@ extension SMB2Context {
smb2_queue_pdu(context, pdu)
}
try wait_for_reply(cbPtr)
let cbresult = cbPtr.bindMemory(to: CBData.self, capacity: 1).pointee.result
if cbresult < 0 {
let errorNo = nterror_to_errno(UInt32(bitPattern: cbresult))
let cbResult = cbPtr.bindMemory(to: CBData.self, capacity: 1).pointee.result
let result = UInt32(bitPattern: cbResult)
if result & SMB2_STATUS_SEVERITY_ERROR == 0xc0000000 {
let errorNo = nterror_to_errno(result)
try POSIXError.throwIfError(-errorNo, description: nil, default: defaultError)
}
let data = cbPtr.bindMemory(to: CBData.self, capacity: 1).pointee.commandData
return (cbresult, data)
return (result, data)
}
}
2 changes: 1 addition & 1 deletion AMSMB2/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.4.0</string>
<string>1.5.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit 53384ea

Please sign in to comment.