ev.events = EPOLLIN | EPOLLET | EPOLLRDHUP;
ev.data.u64 = reinterpret_cast<uint64_t>(&clients[sock]);
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, sock, &ev) == -1) {
ev.events = EPOLLIN | EPOLLET | EPOLLRDHUP;
ev.data.u64 = reinterpret_cast<uint64_t>(&clients[sock]);
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, sock, &ev) == -1) {
ev.data.u64 = 0; // Keep Valgrind happy.
ev.data.u64 = reinterpret_cast<uint64_t>(client_ptr);
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, client.sock(), &ev) == -1) {
ev.data.u64 = 0; // Keep Valgrind happy.
ev.data.u64 = reinterpret_cast<uint64_t>(client_ptr);
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, client.sock(), &ev) == -1) {
- fprintf(stderr, "WARNING: fd %d lost %lld bytes, maybe too slow connection\n",
- client->sock,
+ log(WARNING, "[%s] Client lost %lld bytes, maybe too slow connection",
+ client->remote_addr.c_str(),
(long long int)(bytes_to_send - stream->backlog_size));
client->stream_pos = stream->bytes_received - stream->backlog_size;
client->bytes_lost += bytes_to_send - stream->backlog_size;
(long long int)(bytes_to_send - stream->backlog_size));
client->stream_pos = stream->bytes_received - stream->backlog_size;
client->bytes_lost += bytes_to_send - stream->backlog_size;
// We don't have any more data for this client, so put it to sleep.
// This is postcondition #3.
stream->put_client_to_sleep(client);
// We don't have any more data for this client, so put it to sleep.
// This is postcondition #3.
stream->put_client_to_sleep(client);
}
if (setsockopt(client->sock, SOL_SOCKET, SO_MARK, &client->fwmark, sizeof(client->fwmark)) == -1) {
if (client->fwmark != 0) {
}
if (setsockopt(client->sock, SOL_SOCKET, SO_MARK, &client->fwmark, sizeof(client->fwmark)) == -1) {
if (client->fwmark != 0) {
ev.data.u64 = reinterpret_cast<uint64_t>(client);
if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, client->sock, &ev) == -1) {
ev.data.u64 = reinterpret_cast<uint64_t>(client);
if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, client->sock, &ev) == -1) {
ev.data.u64 = reinterpret_cast<uint64_t>(client);
if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, client->sock, &ev) == -1) {
ev.data.u64 = reinterpret_cast<uint64_t>(client);
if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, client->sock, &ev) == -1) {
void Server::close_client(Client *client)
{
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, client->sock, NULL) == -1) {
void Server::close_client(Client *client)
{
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, client->sock, NULL) == -1) {