Skip to content

Commit

Permalink
io: get rid of qio_channel_websock_encode helper method
Browse files Browse the repository at this point in the history
The qio_channel_websock_encode method is only used in one place,
everything else calls qio_channel_websock_encode_buffer directly.
It can also be pushed up a level into the qio_channel_websock_writev
method, since every other caller of qio_channel_websock_write_wire
has already filled encoutput.

Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Daniel P. Berrange <[email protected]>
  • Loading branch information
berrange committed Oct 16, 2017
1 parent 57b0cdf commit bac6c95
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions io/channel-websock.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,18 +616,6 @@ static void qio_channel_websock_encode_buffer(QIOChannelWebsock *ioc,
}


static void qio_channel_websock_encode(QIOChannelWebsock *ioc)
{
if (!ioc->rawoutput.offset) {
return;
}
qio_channel_websock_encode_buffer(
ioc, &ioc->encoutput, QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME,
&ioc->rawoutput);
buffer_reset(&ioc->rawoutput);
}


static ssize_t qio_channel_websock_write_wire(QIOChannelWebsock *, Error **);


Expand Down Expand Up @@ -948,8 +936,6 @@ static ssize_t qio_channel_websock_write_wire(QIOChannelWebsock *ioc,
ssize_t ret;
ssize_t done = 0;

qio_channel_websock_encode(ioc);

while (ioc->encoutput.offset > 0) {
ret = qio_channel_write(ioc->master,
(char *)ioc->encoutput.buffer,
Expand Down Expand Up @@ -1134,6 +1120,12 @@ static ssize_t qio_channel_websock_writev(QIOChannel *ioc,
}

done:
if (ioc->rawoutput.offset) {
qio_channel_websock_encode_buffer(
ioc, &ioc->encoutput, QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME,
&ioc->rawoutput);
buffer_reset(&ioc->rawoutput);
}
ret = qio_channel_websock_write_wire(wioc, errp);
if (ret < 0 &&
ret != QIO_CHANNEL_ERR_BLOCK) {
Expand Down

0 comments on commit bac6c95

Please sign in to comment.