perror("epoll_ctl(EPOLL_CTL_ADD)");
exit(1);
}
+
+ process_client(&clients[client.sock()]);
}
void Server::add_stream(const string &stream_id)
// This is postcondition #3.
client->state = Client::SENDING_DATA;
client->bytes_sent = client->stream->data_size;
- sleeping_clients.push_back(client);
+ put_client_to_sleep(client);
return;
}
case Client::SENDING_DATA: {
// but resync will be the mux's problem.
const Stream *stream = client->stream;
size_t bytes_to_send = stream->data_size - client->bytes_sent;
+ if (bytes_to_send == 0) {
+ return;
+ }
if (bytes_to_send > BACKLOG_SIZE) {
fprintf(stderr, "WARNING: fd %d lost %lld bytes, maybe too slow connection\n",
client->sock,
}
client->stream_id = request_tokens[1];
- client->stream = streams[client->stream_id];
+ client->stream = find_stream(client->stream_id);
client->request.clear();
return 200; // OK!