mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-02-01 05:22:10 +00:00
Add autorelease pool markers in Go callback functions.
This commit is contained in:
parent
dc5a99e0a3
commit
43b7b55cc1
@ -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;
|
||||
}
|
||||
@ -161,10 +162,12 @@ static ssize_t do_read(const void *ctx, const unsigned char *buf, size_t len)
|
||||
memcpy(buf, [packet bytes], packetLength);
|
||||
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;
|
||||
@ -172,10 +175,13 @@ static ssize_t do_write(const void *ctx, const unsigned char *buf, size_t len)
|
||||
NSData *packet = [[NSData alloc] initWithBytes:buf length: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
Block a user