Skip to content

Commit

Permalink
Ensure native sockets are closed appropriately in hs.ping. Closes #3387
Browse files Browse the repository at this point in the history
… (#3419)
  • Loading branch information
cmsj authored Mar 11, 2023
1 parent 86a4479 commit 3ca0cb9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions extensions/network/ping/SimplePing.m
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,15 @@ - (void)stopHostResolution {

- (void)stopSocket {
if (self.socket != NULL) {
int fd = CFSocketGetNative(self.socket);

if (CFSocketGetSocketFlags(self.socket) & kCFSocketCloseOnInvalidate) {
fd = -1; // No need to manually close the socket, it'll happen automatically
}
CFSocketInvalidate(self.socket);
if (fd != -1) {
close(fd);
}
self.socket = NULL;
}
}
Expand Down

0 comments on commit 3ca0cb9

Please sign in to comment.