Changed writev to sendmsg to prevent SIGPIPE errors
This commit is contained in:
parent
aad09a1dd2
commit
ad9171f226
|
|
@ -224,19 +224,28 @@ public:
|
||||||
// update counter for next iteration
|
// update counter for next iteration
|
||||||
if (++index >= 64) break;
|
if (++index >= 64) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create the message header
|
||||||
|
struct msghdr header;
|
||||||
|
|
||||||
|
// make sure the members of the header are empty
|
||||||
|
memset(&header, 0, sizeof(header));
|
||||||
|
|
||||||
|
// save the buffers in the message header
|
||||||
|
header.msg_iov = buffer;
|
||||||
|
header.msg_iovlen = index;
|
||||||
|
|
||||||
// send the data
|
// send the data
|
||||||
// @todo use sendmsg() with a MSG_NOSIG flag
|
auto result = sendmsg(socket, &header, MSG_NOSIGNAL);
|
||||||
auto result = writev(socket, (const struct iovec *)&buffer, index);
|
|
||||||
|
|
||||||
// skip on error, or when nothing was written
|
// skip on error, or when nothing was written
|
||||||
if (result <= 0) return total > 0 ? total : result;
|
if (result <= 0) return total > 0 ? total : result;
|
||||||
|
|
||||||
// shrink the buffer
|
// shrink the buffer
|
||||||
shrink(result);
|
shrink(result);
|
||||||
|
|
||||||
// update total number of bytes written
|
// update total number of bytes written
|
||||||
total += 0;
|
total += result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue