Merge pull request #399 from Azure/lts_07_2019-update20191007

Lts 07 2019 update20191007
This commit is contained in:
ewertons 2019-10-18 09:01:45 -07:00 коммит произвёл GitHub
Родитель f0642196af 111da6c855
Коммит 3e2b342ecb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 14 добавлений и 17 удалений

Просмотреть файл

@ -49,6 +49,7 @@
#define SOCKET_SUCCESS 0
#define INVALID_SOCKET -1
#define SOCKET_SEND_FAILURE -1
#define MAC_ADDRESS_STRING_LENGTH 18
#ifndef IFREQ_BUFFER_SIZE
@ -864,25 +865,20 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
signal(SIGPIPE, SIG_IGN);
ssize_t send_result = send(socket_io_instance->socket, buffer, size, 0);
if ((send_result < 0) || ((size_t)send_result != size))
if ((size_t)send_result != size)
{
if (send_result == INVALID_SOCKET)
if (send_result == SOCKET_SEND_FAILURE && errno != EAGAIN)
{
if (errno == EAGAIN) /*send says "come back later" with EAGAIN - likely the socket buffer cannot accept more data*/
{
/*do nothing*/
result = 0;
}
else
{
LogError("Failure: sending socket failed. errno=%d (%s).", errno, strerror(errno));
result = MU_FAILURE;
}
LogError("Failure: sending socket failed. errno=%d (%s).", errno, strerror(errno));
result = MU_FAILURE;
}
else
{
/*send says "come back later" with EAGAIN - likely the socket buffer cannot accept more data*/
/* queue data */
if (add_pending_io(socket_io_instance, buffer + send_result, size - send_result, on_send_complete, callback_context) != 0)
size_t bytes_sent = (send_result < 0 ? 0 : send_result);
if (add_pending_io(socket_io_instance, buffer + bytes_sent, size - bytes_sent, on_send_complete, callback_context) != 0)
{
LogError("Failure: add_pending_io failed.");
result = MU_FAILURE;

Просмотреть файл

@ -481,21 +481,22 @@ int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size,
}
else
{
/* TODO: we need to do more than a cast here to be 100% clean
The following bug was filed: [WarnL4] socketio_win32 does not account for already sent bytes and there is a truncation of size from size_t to int */
int send_result = send(socket_io_instance->socket, (const char*)buffer, (int)size, 0);
if (send_result != (int)size)
{
int last_error = WSAGetLastError();
if (last_error != WSAEWOULDBLOCK)
if (send_result == SOCKET_ERROR && last_error != WSAEWOULDBLOCK)
{
LogError("Failure: sending socket failed %d.", last_error);
result = MU_FAILURE;
}
else
{
size_t bytes_sent = (send_result == SOCKET_ERROR ? 0 : send_result);
/* queue data */
if (add_pending_io(socket_io_instance, (const unsigned char*)buffer, size, on_send_complete, callback_context) != 0)
if (add_pending_io(socket_io_instance, ((const unsigned char*)buffer) + bytes_sent, size - bytes_sent, on_send_complete, callback_context) != 0)
{
LogError("Failure: add_pending_io failed.");
result = MU_FAILURE;