aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuardNetworkExtension/WireGuardGoWrapper.m
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-12 23:05:21 -0700
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-12 23:05:21 -0700
commit76a001dbe0a560219e03e418bbf50c46e52b3193 (patch)
tree10e9ca564980b15681acc69911406036cfe119f5 /WireGuardNetworkExtension/WireGuardGoWrapper.m
parentLog on VPNStatusDidChange. (diff)
downloadwireguard-apple-76a001dbe0a560219e03e418bbf50c46e52b3193.tar.xz
wireguard-apple-76a001dbe0a560219e03e418bbf50c46e52b3193.zip
bridge: don't put on another thread
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--WireGuardNetworkExtension/WireGuardGoWrapper.m21
1 files changed, 10 insertions, 11 deletions
diff --git a/WireGuardNetworkExtension/WireGuardGoWrapper.m b/WireGuardNetworkExtension/WireGuardGoWrapper.m
index 8deb527..2f5a558 100644
--- a/WireGuardNetworkExtension/WireGuardGoWrapper.m
+++ b/WireGuardNetworkExtension/WireGuardGoWrapper.m
@@ -94,18 +94,17 @@ static ssize_t do_read(const void *ctx, const unsigned char *buf, size_t len)
return 0;
}
- if (wrapper.packets.count == 0) {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
- [wrapper.packetFlow readPacketsWithCompletionHandler:^(NSArray<NSData *> * _Nonnull packets, NSArray<NSNumber *> * _Nonnull protocols) {
- [wrapper.packets addObjectsFromArray:packets];
- [wrapper.protocols addObjectsFromArray:protocols];
- os_log_debug([WireGuardGoWrapper log], "do_read - signal - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
- [wrapper.condition signal];
- }];
- });
+ if (!wrapper.packets.count) {
+ [wrapper.packetFlow readPacketsWithCompletionHandler:^(NSArray<NSData *> * _Nonnull packets, NSArray<NSNumber *> * _Nonnull protocols) {
+ [wrapper.condition signal];
+ [wrapper.packets addObjectsFromArray:packets];
+ [wrapper.protocols addObjectsFromArray:protocols];
+ os_log_debug([WireGuardGoWrapper log], "do_read - signal - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
+ [wrapper.condition signal];
+ }];
os_log_debug([WireGuardGoWrapper log], "do_read - wait - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
- [wrapper.condition wait];
+ while (!wrapper.packets.count)
+ [wrapper.condition wait];
}
NSData *packet = [wrapper.packets objectAtIndex:0];