(apple ssl) unify read and write ssl utility code
This commit is contained in:
parent
f75684a412
commit
5020870cdf
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [7.9.2] - 2020-01-06
|
||||||
|
|
||||||
|
(apple ssl) unify read and write ssl utility code
|
||||||
|
|
||||||
## [7.9.1] - 2020-01-06
|
## [7.9.1] - 2020-01-06
|
||||||
|
|
||||||
(websocket client) better error propagation when errors are detected while sending data
|
(websocket client) better error propagation when errors are detected while sending data
|
||||||
|
@ -100,7 +100,8 @@ namespace ix
|
|||||||
{
|
{
|
||||||
case ENOENT: return errSSLClosedGraceful;
|
case ENOENT: return errSSLClosedGraceful;
|
||||||
|
|
||||||
case EAGAIN: return errSSLWouldBlock;
|
case EAGAIN: return errSSLWouldBlock; // EWOULDBLOCK is a define for EAGAIN on osx
|
||||||
|
case EINPROGRESS: return errSSLWouldBlock;
|
||||||
|
|
||||||
case ECONNRESET: return errSSLClosedAbort;
|
case ECONNRESET: return errSSLClosedAbort;
|
||||||
|
|
||||||
@ -142,13 +143,16 @@ namespace ix
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
*len = 0;
|
*len = 0;
|
||||||
if (errno == EAGAIN)
|
switch (errno)
|
||||||
{
|
{
|
||||||
return errSSLWouldBlock;
|
case ENOENT: return errSSLClosedGraceful;
|
||||||
}
|
|
||||||
else
|
case EAGAIN: return errSSLWouldBlock; // EWOULDBLOCK is a define for EAGAIN on osx
|
||||||
{
|
case EINPROGRESS: return errSSLWouldBlock;
|
||||||
return errSecIO;
|
|
||||||
|
case ECONNRESET: return errSSLClosedAbort;
|
||||||
|
|
||||||
|
default: return errSecIO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,20 +238,31 @@ namespace ix
|
|||||||
|
|
||||||
ssize_t SocketAppleSSL::send(char* buf, size_t nbyte)
|
ssize_t SocketAppleSSL::send(char* buf, size_t nbyte)
|
||||||
{
|
{
|
||||||
ssize_t ret = 0;
|
OSStatus status = errSSLWouldBlock;
|
||||||
OSStatus status;
|
while (status == errSSLWouldBlock)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
size_t processed = 0;
|
size_t processed = 0;
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
status = SSLWrite(_sslContext, buf, nbyte, &processed);
|
status = SSLWrite(_sslContext, buf, nbyte, &processed);
|
||||||
ret += processed;
|
|
||||||
buf += processed;
|
|
||||||
nbyte -= processed;
|
|
||||||
} while (nbyte > 0 && status == errSSLWouldBlock);
|
|
||||||
|
|
||||||
if (ret == 0 && errSSLClosedAbort != status) ret = -1;
|
if (processed > 0) return (ssize_t) processed;
|
||||||
return ret;
|
|
||||||
|
// The connection was reset, inform the caller that this
|
||||||
|
// Socket should close
|
||||||
|
if (status == errSSLClosedGraceful || status == errSSLClosedNoNotify ||
|
||||||
|
status == errSSLClosedAbort)
|
||||||
|
{
|
||||||
|
errno = ECONNRESET;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == errSSLWouldBlock)
|
||||||
|
{
|
||||||
|
errno = EWOULDBLOCK;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t SocketAppleSSL::send(const std::string& buffer)
|
ssize_t SocketAppleSSL::send(const std::string& buffer)
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "7.9.1"
|
#define IX_WEBSOCKET_VERSION "7.9.2"
|
||||||
|
Loading…
Reference in New Issue
Block a user