add cancellation support while connecting, to speed up WebSocket::stop

This commit is contained in:
Benjamin Sergeant
2018-12-09 17:56:20 -08:00
parent 62528e6a0b
commit 8c079787f0
13 changed files with 69 additions and 25 deletions

View File

@ -6,7 +6,6 @@
* Adapted from Satori SDK Apple SSL code.
*/
#include "IXSocketAppleSSL.h"
#include "IXSocketConnect.h"
#include <fcntl.h>
#include <netdb.h>
@ -157,13 +156,14 @@ namespace ix
// No wait support
bool SocketAppleSSL::connect(const std::string& host,
int port,
std::string& errMsg)
std::string& errMsg,
CancellationRequest isCancellationRequested)
{
OSStatus status;
{
std::lock_guard<std::mutex> lock(_mutex);
_sockfd = SocketConnect::connect(host, port, errMsg);
_sockfd = SocketConnect::connect(host, port, errMsg, isCancellationRequested);
if (_sockfd == -1) return false;
_sslContext = SSLCreateContext(kCFAllocatorDefault, kSSLClientSide, kSSLStreamType);