X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=server.cpp;h=da721e780c2149c566ada02fc7ca9d1c942f4602;hp=b914b2ec4fbaa50175021038e42ed9161cd21bad;hb=ad7d036afd462810aaa1c8686834fa91b2c4e5ae;hpb=4971ba0e48d77b075fc972c13ec2978aa93630a1;ds=sidebyside diff --git a/server.cpp b/server.cpp index b914b2e..da721e7 100644 --- a/server.cpp +++ b/server.cpp @@ -220,10 +220,18 @@ void Server::process_client(Client *client) } // See if we need to split across the circular buffer. - int ret; + ssize_t ret; if ((client->bytes_sent % BACKLOG_SIZE) + bytes_to_send > BACKLOG_SIZE) { - // TODO: writev - assert(false); + size_t bytes_first_part = BACKLOG_SIZE - (client->bytes_sent % BACKLOG_SIZE); + + iovec iov[2]; + iov[0].iov_base = const_cast(stream.data + (client->bytes_sent % BACKLOG_SIZE)); + iov[0].iov_len = bytes_first_part; + + iov[1].iov_base = const_cast(stream.data); + iov[1].iov_len = bytes_to_send - bytes_first_part; + + ret = writev(client->sock, iov, 2); } else { ret = write(client->sock, stream.data + (client->bytes_sent % BACKLOG_SIZE),