Skip to content

Commit 2ec8f56

Browse files
stackiaclaude
andcommitted
fix: use fprintf instead of logger in connection_queue_output to prevent feedback loop
When SSE queue is full or buffer pool exhausted, using logger() triggers status_add_log_entry() which sends SSE updates, potentially causing more queue failures and creating an infinite feedback loop. Switch to fprintf() to break this cycle. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 5edc3fa commit 2ec8f56

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/connection.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,14 @@ int connection_queue_output(connection_t *c, const uint8_t *data, size_t len) {
489489
/* Allocate a buffer from the pool */
490490
buffer_ref_t *buf_ref = connection_alloc_output_buffer(c);
491491
if (!buf_ref) {
492-
/* Pool exhausted */
493-
logger(LOG_WARN,
494-
"connection_queue_output: Buffer pool exhausted, cannot queue %zu "
495-
"bytes",
496-
remaining);
492+
/* Pool exhausted.
493+
* Use fprintf instead of logger to avoid feedback loop:
494+
* logger -> status_add_log_entry -> SSE update -> pool exhausted -> logger
495+
*/
496+
fprintf(stderr,
497+
"connection_queue_output: Buffer pool exhausted, cannot queue "
498+
"%zu bytes\n",
499+
remaining);
497500
return -1;
498501
}
499502

@@ -508,12 +511,14 @@ int connection_queue_output(connection_t *c, const uint8_t *data, size_t len) {
508511

509512
/* Queue this buffer for zero-copy send */
510513
if (connection_queue_zerocopy(c, buf_ref) < 0) {
511-
/* Queue full - release the buffer and fail */
514+
/* Queue full - release the buffer and fail.
515+
* Use fprintf instead of logger to avoid feedback loop:
516+
* logger -> status_add_log_entry -> SSE update -> queue full -> logger */
512517
buffer_ref_put(buf_ref);
513-
logger(LOG_WARN,
514-
"connection_queue_output: Zero-copy queue full, cannot queue %zu "
515-
"bytes",
516-
remaining);
518+
fprintf(stderr,
519+
"connection_queue_output: Zero-copy queue full, cannot queue %zu "
520+
"bytes\n",
521+
remaining);
517522
return -1;
518523
}
519524

0 commit comments

Comments
 (0)