summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_socket.c
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2015-04-22 22:44:16 -0700
committerAlan Antonuk <alan.antonuk@gmail.com>2015-05-03 20:24:03 -0700
commit6db386b3442f1d4480846291bc0e2970c7923afb (patch)
tree15305685f89e90b77e644e6476a25753367ac520 /librabbitmq/amqp_socket.c
parent5498dc66c3be4176c3631ee4b4ec26d6cb4966ae (diff)
downloadrabbitmq-c-6db386b3442f1d4480846291bc0e2970c7923afb.tar.gz
Extract deadline as param of try_writev/try_send
Diffstat (limited to 'librabbitmq/amqp_socket.c')
-rw-r--r--librabbitmq/amqp_socket.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c
index 6785187..957b7d2 100644
--- a/librabbitmq/amqp_socket.c
+++ b/librabbitmq/amqp_socket.c
@@ -304,20 +304,13 @@ int amqp_poll_write(int fd, amqp_time_t deadline) {
}
ssize_t amqp_try_writev(amqp_connection_state_t state, struct iovec *iov,
- int iovcnt) {
+ int iovcnt, amqp_time_t deadline) {
int i;
int fd;
ssize_t res;
struct iovec *iov_left = iov;
int iovcnt_left = iovcnt;
ssize_t len_left;
- /* TODO(alanxz) this should probably be a parameter */
- amqp_time_t deadline;
-
- res = amqp_time_from_now(&deadline, NULL);
- if (AMQP_STATUS_OK != res) {
- return res;
- }
len_left = 0;
for (i = 0; i < iovcnt_left; ++i) {
@@ -367,18 +360,12 @@ start_send:
}
ssize_t amqp_try_send(amqp_connection_state_t state, const void *buf,
- size_t len) {
+ size_t len, amqp_time_t deadline) {
ssize_t res;
int fd;
void* buf_left = (void*)buf;
/* Assume that len is going to be larger than ssize_t can hold. */
ssize_t len_left = (size_t)len;
- /* TODO(alanxz) this should probably be a parameter */
- amqp_time_t deadline;
- res = amqp_time_from_now(&deadline, NULL);
- if (AMQP_STATUS_OK != res) {
- return res;
- }
start_send:
res = amqp_socket_send(state->socket, buf_left, len_left);
@@ -543,7 +530,7 @@ int amqp_send_header(amqp_connection_state_t state)
AMQP_PROTOCOL_VERSION_MINOR,
AMQP_PROTOCOL_VERSION_REVISION
};
- return amqp_try_send(state, header, sizeof(header));
+ return amqp_try_send(state, header, sizeof(header), amqp_time_infinite());
}
static amqp_bytes_t sasl_method_name(amqp_sasl_method_enum method)