Skip to content

Commit 899d99b

Browse files
committed
Bug fix from eldenchen: Fixed a crash problem (issue robbiehanson#62)
1 parent 83add44 commit 899d99b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

GCD/GCDAsyncSocket.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,6 +2340,11 @@ - (BOOL)connectWithAddress4:(NSData *)address4 address6:(NSData *)address6 error
23402340
}
23412341
}
23422342

2343+
// Prevent SIGPIPE signals
2344+
2345+
int nosigpipe = 1;
2346+
setsockopt(socketFD, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));
2347+
23432348
// Start the connection process in a background queue
23442349

23452350
int aConnectIndex = connectIndex;
@@ -2488,11 +2493,6 @@ - (void)didConnect:(int)aConnectIndex
24882493
return;
24892494
}
24902495

2491-
// Prevent SIGPIPE signals
2492-
2493-
int nosigpipe = 1;
2494-
setsockopt(socketFD, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));
2495-
24962496
// Setup our read/write sources
24972497

24982498
[self setupReadAndWriteSourcesForNewlyConnectedSocket:socketFD];

0 commit comments

Comments
 (0)