Add autorelease pool markers in Go callback functions.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
fc1ddc8b12
commit
8c8030e5c7
|
@ -114,12 +114,13 @@ static void do_log(int level, const char *tag, const char *msg);
|
|||
|
||||
static ssize_t do_read(const void *ctx, const unsigned char *buf, size_t len)
|
||||
{
|
||||
// os_log_debug([WireGuardGoWrapper log], "do_read - start - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
|
||||
@autoreleasepool {
|
||||
os_log_debug([WireGuardGoWrapper log], "do_read - start - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
|
||||
WireGuardGoWrapper *wrapper = (__bridge WireGuardGoWrapper *)ctx;
|
||||
if (wrapper.isClosed) return -1;
|
||||
|
||||
if (wrapper.handle < 0 || !wrapper.configured ) {
|
||||
// os_log_debug([WireGuardGoWrapper log], "do_read - early - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
|
||||
os_log_debug([WireGuardGoWrapper log], "do_read - early - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -162,9 +163,11 @@ static ssize_t do_read(const void *ctx, const unsigned char *buf, size_t len)
|
|||
os_log_debug([WireGuardGoWrapper log], "do_read - packet - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
|
||||
return packetLength;
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t do_write(const void *ctx, const unsigned char *buf, size_t len)
|
||||
{
|
||||
@autoreleasepool {
|
||||
os_log_debug([WireGuardGoWrapper log], "do_write - start");
|
||||
|
||||
WireGuardGoWrapper *wrapper = (__bridge WireGuardGoWrapper *)ctx;
|
||||
|
@ -173,9 +176,12 @@ static ssize_t do_write(const void *ctx, const unsigned char *buf, size_t len)
|
|||
[wrapper.packetFlow writePackets:@[packet] withProtocols:@[@AF_INET]];
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
static void do_log(int level, const char *tag, const char *msg)
|
||||
{
|
||||
@autoreleasepool {
|
||||
// TODO Get some details on the log level and distribute to matching log levels.
|
||||
os_log([WireGuardGoWrapper log], "Log level %d for %{public}s: %{public}s", level, tag, msg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue