Buffer overflow error.

This commit is contained in:
SergeantPanda 2025-05-21 09:44:09 -05:00
parent ba8eee16ee
commit 303123f3ec
4 changed files with 30 additions and 22 deletions

View file

@ -376,28 +376,33 @@ class StreamManager:
logger.debug(f"Started stderr reader thread for channel {self.channel_id}")
def _read_stderr(self):
"""Read and log stderr output from the transcode process"""
"""Read and log ffmpeg stderr output"""
try:
if not self.transcode_process or not self.transcode_process.stderr:
logger.warning(f"No stderr to read for channel {self.channel_id}")
return
for line in iter(self.transcode_process.stderr.readline, b''):
if not line:
break
# Decode the line and strip whitespace
error_line = line.decode('utf-8', errors='replace').strip()
# Skip empty lines
if not error_line:
continue
# Log all stderr output as debug messages
logger.debug(f"Transcode stderr [{self.channel_id}]: {error_line}")
for error_line in iter(self.transcode_process.stderr.readline, b''):
if error_line:
error_line = error_line.decode('utf-8', errors='replace').strip()
try:
# Wrap the logging call in a try-except to prevent crashes due to logging errors
logger.debug(f"Transcode stderr [{self.channel_id}]: {error_line}")
except OSError as e:
# If logging fails, try a simplified log message
if e.errno == 105: # No buffer space available
try:
# Try a much shorter message without the error content
logger.warning(f"Logging error (buffer full) in channel {self.channel_id}")
except:
# If even that fails, we have to silently continue
pass
except Exception:
# Ignore other logging errors to prevent thread crashes
pass
except Exception as e:
logger.error(f"Error reading transcode stderr: {e}")
# Catch any other exceptions in the thread to prevent crashes
try:
logger.error(f"Error in stderr reader thread: {e}")
except:
# Again, if logging fails, continue silently
pass
def _establish_http_connection(self):
"""Establish a direct HTTP connection to the stream"""

View file

@ -47,6 +47,7 @@ thunder-lock = true
log-4xx = true
log-5xx = true
disable-logging = false
log-buffering = 1024 # Add buffer size limit for logging
; Longer timeouts for debugging sessions
harakiri = 3600

View file

@ -57,4 +57,5 @@ log-master = true
logformat-strftime = true
log-date = %%Y-%%m-%%d %%H:%%M:%%S,000
# Use formatted time with environment variable for log level
log-format = %(ftime) $(DISPATCHARR_LOG_LEVEL) uwsgi.requests Worker ID: %(wid) %(method) %(status) %(uri) %(msecs)ms
log-format = %(ftime) $(DISPATCHARR_LOG_LEVEL) uwsgi.requests Worker ID: %(wid) %(method) %(status) %(uri) %(msecs)ms
log-buffering = 1024 # Add buffer size limit for logging

View file

@ -55,4 +55,5 @@ log-master = true
logformat-strftime = true
log-date = %%Y-%%m-%%d %%H:%%M:%%S,000
# Use formatted time with environment variable for log level
log-format = %(ftime) $(DISPATCHARR_LOG_LEVEL) uwsgi.requests Worker ID: %(wid) %(method) %(status) %(uri) %(msecs)ms
log-format = %(ftime) $(DISPATCHARR_LOG_LEVEL) uwsgi.requests Worker ID: %(wid) %(method) %(status) %(uri) %(msecs)ms
log-buffering = 1024 # Add buffer size limit for logging