Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by QodoBound RTMP setup waits and release the mutex on initialization failure
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
- One 5 s deadline for connect and handshake: each handshake read waits only for the time that is left, so a peer that trickles bytes cannot hold the start. - Shut the socket down before joining the receiver when the sender thread cannot be created. - Close the socket when the connect, createStream or publish step fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Updated after the automatic review (second commit).
🤖 Generated with Claude Code |
What was wrong
With
stream.enableon and an RTMP destination that does not answer, the camera reboots again and again. Seen twice on a Ruision F8 board (FH8856V200) while testing RTMP: the hardware watchdog rebooted the board.Why
Two faults in
src/rtmp.c:rtmp_start_sequence()connects with a blockingconnect()and then waits for the handshake replies with no time limit. It runs on the main thread before the video starts, so a destination that drops the packets holds the program until the watchdog fires.rtmp_init()holdsrtmp_mutexand reports its errors withHAL_ERROR, which returns from the function (return EXIT_FAILUREis part of the macro). The mutex stays locked, and the nextrtmp_close()(every stop or restart of the program) waits on it forever, again until the watchdog fires.What this changes
SO_SNDTIMEOandSO_RCVTIMEOof 5 s on the socket during connect and handshake, set back to no limit once connected (the running stream keeps today's behaviour). A failed connect logs a warning.HAL_DANGERinstead ofHAL_ERRORfor the three messages inrtmp_init(); it logs the same red line without returning, so the existingpthread_mutex_unlock()andreturn ret;at the end are reached.How it was checked
./build.sh fhan-v2, no new warnings;./test.sh -apasses.Effect on other platforms
Shared code, used only with
stream.enableand anrtmp://destination. Socket timeouts are standard BSD socket options in glibc, musl and uClibc.Update after the automatic review
A second commit makes the 5 s one deadline for the connect and the handshake together (each handshake read waits only for the time left), shuts the socket down before joining the receiver when the sender thread cannot be created, and closes the socket when the connect, createStream or publish step fails. Tested on the board against a server that answers one byte every 2 s: the camera now gives up after 5.0 s (before: as long as the server kept trickling).
🤖 Generated with Claude Code