use uwsgi_buffer for send_ack in #760

This commit is contained in:
Roberto De Ioris
2014-11-02 09:32:50 +01:00
parent 1964c9758b
commit 48314cb903
+16 -13
View File
@@ -73,26 +73,29 @@ static int amqp_send_ack(int fd, uint64_t delivery_tag) {
uint32_t size = 4 + 8 + 1;
size = htonl(size);
struct uwsgi_buffer *ub = uwsgi_buffer_new(64);
// send type and channel
amqp_send(fd, "\1\0\1", 3);
if (uwsgi_buffer_append(ub, "\1\0\1", 3)) goto end;
// send size
amqp_send(fd, &size, 4);
// send class 60 method 80
amqp_send(fd, "\x00\x3C\x00\x50", 4);
if (uwsgi_buffer_u32be(ub, size)) goto end;
// send class 60 method 80
if (uwsgi_buffer_append(ub, "\x00\x3C\x00\x50", 4)) goto end;
// set delivery_tag
delivery_tag = htonll(delivery_tag);
amqp_send(fd, &delivery_tag, 8);
if (uwsgi_buffer_u64be(ub, delivery_tag)) goto end;
if (uwsgi_buffer_append(ub, "\0\xCE", 2)) goto end;
// empty bits
amqp_send(fd, "\0", 1);
// send buffer to socket
if (write(fd, ub->buf, ub->pos) < 0) {
uwsgi_error("amqp_send_ack()/write()");
goto end;
}
// send frame-end
amqp_send(fd, "\xCE", 1);
uwsgi_buffer_destroy(ub);
return 0;
end:
uwsgi_buffer_destroy(ub);
return -1;
}
char *uwsgi_amqp_consume(int fd, uint64_t *msgsize, char **routing_key) {