diff options
author | Alan Antonuk <alan.antonuk@gmail.com> | 2015-05-23 23:56:51 -0700 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2015-05-31 22:57:38 -0700 |
commit | 2bc1f9b1b03c217512ce7026f76976cdcb8cc17e (patch) | |
tree | ec9d45fc68e1f1dedb570b1694df34738c8cbb04 /librabbitmq/amqp_tcp_socket.c | |
parent | ed363ad6db549e9d3fa57f7ca761032eecb2a1a1 (diff) | |
download | rabbitmq-c-2bc1f9b1b03c217512ce7026f76976cdcb8cc17e.tar.gz |
lib: use MSG_MORE on Linux for basic.publish
As a performance optimization in the send path, add an AMQP_SF_MORE flag
indicating that more data is intended to be sent, and that packets shouldn't be
sent out on the wire unless there is a full packet's worth of data available.
Use this to specify MSG_MORE to send() on Linux.
Diffstat (limited to 'librabbitmq/amqp_tcp_socket.c')
-rw-r--r-- | librabbitmq/amqp_tcp_socket.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/librabbitmq/amqp_tcp_socket.c b/librabbitmq/amqp_tcp_socket.c index e14cf38..e363b90 100644 --- a/librabbitmq/amqp_tcp_socket.c +++ b/librabbitmq/amqp_tcp_socket.c @@ -42,25 +42,31 @@ struct amqp_tcp_socket_t { static ssize_t -amqp_tcp_socket_send(void *base, const void *buf, size_t len) +amqp_tcp_socket_send(void *base, const void *buf, size_t len, int flags) { struct amqp_tcp_socket_t *self = (struct amqp_tcp_socket_t *)base; ssize_t res; - int flags = 0; + int flagz = 0; if (-1 == self->sockfd) { return AMQP_STATUS_SOCKET_CLOSED; } #ifdef MSG_NOSIGNAL - flags |= MSG_NOSIGNAL; + flagz |= MSG_NOSIGNAL; +#endif + +#if defined(MSG_MORE) + if (flags & AMQP_SF_MORE) { + flagz |= MSG_MORE; + } #endif start: #ifdef _WIN32 - res = send(self->sockfd, buf, (int)len, flags); + res = send(self->sockfd, buf, (int)len, flagz); #else - res = send(self->sockfd, buf, len, flags); + res = send(self->sockfd, buf, len, flagz); #endif if (res < 0) { |