Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ connection_write_status_t connection_handle_write(connection_t *c) {
size_t bytes_sent = 0;
int ret = zerocopy_send(c->fd, &c->zc_queue, &bytes_sent);
total_sent += bytes_sent;
/* Count post-send so per-client bandwidth reflects actual receive rate, not enqueue rate. */
c->stream.total_bytes_sent += (uint64_t)bytes_sent;
Comment thread
stackia marked this conversation as resolved.
Comment thread
stackia marked this conversation as resolved.
Comment thread
stackia marked this conversation as resolved.

if (ret < 0 && ret != -2) {
c->state = CONN_CLOSING;
Expand Down
11 changes: 2 additions & 9 deletions src/fcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,7 @@ int fcc_handle_unicast_media(stream_context_t *ctx, buffer_ref_t *buf_ref) {
}

/* Forward RTP payload to client (with reordering) */
int processed_bytes = stream_process_rtp_payload(ctx, buf_ref);
if (processed_bytes > 0) {
ctx->total_bytes_sent += (uint64_t)processed_bytes;
}
stream_process_rtp_payload(ctx, buf_ref);

/* Check if we should terminate FCC based on reorder's delivered sequence.
* base_seq - 1 is the last sequence number successfully delivered.
Expand Down Expand Up @@ -562,7 +559,6 @@ int fcc_handle_mcast_active(stream_context_t *ctx, buffer_ref_t *buf_ref) {
buffer_ref_t *next = node->send_next;
int processed_bytes = stream_process_rtp_payload(ctx, node);
if (likely(processed_bytes > 0)) {
ctx->total_bytes_sent += (uint64_t)processed_bytes;
flushed_bytes += (uint64_t)processed_bytes;
}
buffer_ref_put(node);
Expand All @@ -578,10 +574,7 @@ int fcc_handle_mcast_active(stream_context_t *ctx, buffer_ref_t *buf_ref) {

/* Forward multicast data to client (true zero-copy) or capture I-frame
* (snapshot) */
int processed_bytes = stream_process_rtp_payload(ctx, buf_ref);
if (likely(processed_bytes > 0)) {
ctx->total_bytes_sent += (uint64_t)processed_bytes;
}
stream_process_rtp_payload(ctx, buf_ref);

return 0;
}
5 changes: 1 addition & 4 deletions src/multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,7 @@ int mcast_session_handle_event(mcast_session_t *session, stream_context_t *ctx,
/* Handle based on FCC state (if FCC initialized) */
if (!ctx->fcc.initialized) {
/* Direct multicast without FCC - forward to client */
int processed_bytes = stream_process_rtp_payload(ctx, recv_buf);
if (processed_bytes > 0) {
ctx->total_bytes_sent += (uint64_t)processed_bytes;
}
stream_process_rtp_payload(ctx, recv_buf);
buffer_ref_put(recv_buf);
continue; /* Read next packet */
}
Expand Down
9 changes: 0 additions & 9 deletions src/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ int stream_handle_fd_event(stream_context_t *ctx, int fd, uint32_t events, int64
}
return -1;
}
if (result > 0) {
ctx->total_bytes_sent += (uint64_t)result;
}
return 0;
}

Expand All @@ -119,9 +116,6 @@ int stream_handle_fd_event(stream_context_t *ctx, int fd, uint32_t events, int64
if (result < 0) {
return -1; /* Error */
}
if (result > 0) {
ctx->total_bytes_sent += (uint64_t)result;
}
return 0; /* Success - processed data, continue with other events */
}

Expand All @@ -143,9 +137,6 @@ int stream_handle_fd_event(stream_context_t *ctx, int fd, uint32_t events, int64
logger(LOG_ERROR, "HTTP Proxy: Socket event handling failed");
return -1;
}
if (result > 0) {
ctx->total_bytes_sent += (uint64_t)result;
}
return 0;
}

Expand Down
Loading