summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_connection.c
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonygarnockjones@gmail.com>2010-04-15 22:58:25 +1200
committerTony Garnock-Jones <tonygarnockjones@gmail.com>2010-04-15 22:58:25 +1200
commitf86edf6b66a39b3dc7fc909a37a04ea22878d6e7 (patch)
tree0512ea8065c4d97393db05d64c413a4bef380357 /librabbitmq/amqp_connection.c
parent78361421f8ce0533a7f2df9f745e5ac838da05d3 (diff)
downloadrabbitmq-c-github-ask-f86edf6b66a39b3dc7fc909a37a04ea22878d6e7.tar.gz
Use writev(2) instead of 3 write(2)s
Diffstat (limited to 'librabbitmq/amqp_connection.c')
-rw-r--r--librabbitmq/amqp_connection.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
index b05bdd4..610de19 100644
--- a/librabbitmq/amqp_connection.c
+++ b/librabbitmq/amqp_connection.c
@@ -56,6 +56,7 @@
#include <unistd.h>
#include <sys/uio.h>
+#include <sys/types.h>
#include "amqp.h"
#include "amqp_framing.h"
@@ -423,15 +424,19 @@ int amqp_send_frame(amqp_connection_state_t state,
payload_len + (HEADER_SIZE + FOOTER_SIZE)));
return 0;
- case 1:
- AMQP_CHECK_RESULT(write(state->sockfd, state->outbound_buffer.bytes, HEADER_SIZE));
- AMQP_CHECK_RESULT(write(state->sockfd, encoded.bytes, payload_len));
- {
- assert(FOOTER_SIZE == 1);
- char frame_end_byte = AMQP_FRAME_END;
- AMQP_CHECK_RESULT(write(state->sockfd, &frame_end_byte, FOOTER_SIZE));
- }
+ case 1: {
+ struct iovec iov[3];
+ char frame_end_byte = AMQP_FRAME_END;
+ iov[0].iov_base = state->outbound_buffer.bytes;
+ iov[0].iov_len = HEADER_SIZE;
+ iov[1].iov_base = encoded.bytes;
+ iov[1].iov_len = payload_len;
+ iov[2].iov_base = &frame_end_byte;
+ assert(FOOTER_SIZE == 1);
+ iov[2].iov_len = FOOTER_SIZE;
+ AMQP_CHECK_RESULT(writev(state->sockfd, &iov[0], 3));
return 0;
+ }
default:
return separate_body;