Skip to content

Commit

Permalink
fix: ios sockets segfault on connect timeout (#3760)
Browse files Browse the repository at this point in the history
  • Loading branch information
shannah committed Nov 7, 2023
1 parent 9a53f45 commit 9425b19
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Ports/iOSPort/nativeSources/SocketImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,23 @@ -(BOOL)connect:(NSString*)host port:(int)port timeout:(int)timeout{
});

}
[inputStream open];
[outputStream open];
while ([outputStream streamStatus] == NSStreamStatusOpening) {
if (inputStream != nil) {
[inputStream open];
}
if (outputStream != nil) {
[outputStream open];
}
while (outputStream != nil && [outputStream streamStatus] == NSStreamStatusOpening) {
_yield();
usleep(100000);
_resume();
}
while ([inputStream streamStatus] == NSStreamStatusOpening) {
while (inputStream != nil && [inputStream streamStatus] == NSStreamStatusOpening) {
_yield();
usleep(100000);
_resume();
}
if ([self isInputShutdown] || [self isOutputShutdown]) {
if (outputStream == nil || inputStream == nil || [self isInputShutdown] || [self isOutputShutdown]) {
connected = NO;
} else {
connected = YES;
Expand Down

0 comments on commit 9425b19

Please sign in to comment.