mirror of https://git.kore.io/kore.git
make kore_websocket_send() slightly faster.
build the frame in a kore_buf on the stack and use net_send_stream() to push it out rather then making yet another copy in net_send(). saves several cpu cycles before the frame starts going out as we're not allocating a kore_buf, its contents and then memcpy()ing that contents to a new netbuf.
This commit is contained in:
parent
fcc044af87
commit
f8b3915ee1
|
@ -138,12 +138,16 @@ void
|
||||||
kore_websocket_send(struct connection *c, u_int8_t op, const void *data,
|
kore_websocket_send(struct connection *c, u_int8_t op, const void *data,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
struct kore_buf *frame;
|
struct kore_buf frame;
|
||||||
|
|
||||||
frame = kore_buf_alloc(len);
|
kore_buf_init(&frame, len);
|
||||||
websocket_frame_build(frame, op, data, len);
|
|
||||||
net_send_queue(c, frame->data, frame->offset);
|
websocket_frame_build(&frame, op, data, len);
|
||||||
kore_buf_free(frame);
|
net_send_stream(c, frame.data, frame.offset, NULL, NULL);
|
||||||
|
|
||||||
|
/* net_send_stream() takes over the buffer data pointer. */
|
||||||
|
frame.data = NULL;
|
||||||
|
kore_buf_cleanup(&frame);
|
||||||
|
|
||||||
net_send_flush(c);
|
net_send_flush(c);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue