Skip to content

Commit

Permalink
check return value
Browse files Browse the repository at this point in the history
  • Loading branch information
scareything committed Oct 12, 2023
1 parent ff81316 commit 52551cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Ziti.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ import CZitiPrivate
initCallback(ZitiError(errStr, errorCode: Int(zitiStatus)))
return
}

// Save off reference to current thread and run the loop
if privateLoop {
Thread.current.name = "ziti_uv_loop_private"
Expand Down Expand Up @@ -898,6 +898,7 @@ import CZitiPrivate
log.wtf("invalid event", function:"onEvent()")
return
}

// always update zid name...
if let czid = ziti_get_identity(ztx) {
let name = String(cString: czid.pointee.name)
Expand Down
7 changes: 5 additions & 2 deletions lib/ZitiTunnel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ public class ZitiTunnel : NSObject, ZitiUnretained {
func setZitiInstance(_ identifier:String, _ zitiCtx:ziti_context) {
var zi:UnsafeMutablePointer<ziti_instance_s>?
zi = new_ziti_instance(identifier.cString(using: .utf8))

// use the context and options that the caller provided
zi?.pointee.ztx = zitiCtx
// add in required options for receiving tsdk events
set_tnlr_options(zi) // todo check return
let rc = set_tnlr_options(zi)
guard rc == Ziti.ZITI_OK else {
log.wtf("unable to set tunneler options on Ziti instance for identifier \(identitifer)")
return
}

set_ziti_instance(identifier.cString(using: .utf8), zi)

Expand Down

0 comments on commit 52551cb

Please sign in to comment.