-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edge: Improve stability for state and fd closing. v5.0.214 v6.0.139 #4126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review send_error_code
problem.
trunk/src/app/srs_app_edge.cpp
Outdated
if ((err = do_cycle()) != srs_success) { | ||
// If coroutine stopping, we should always set the quit error code. | ||
err = do_cycle(); | ||
if (send_error_code == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (send_error_code == 0) { | |
if ((err = do_cycle()) != srs_success) { | |
if (send_error_code == ERROR_SUCCESS) { | |
// If coroutine stopping, we should always set the quit error code. | |
send_error_code = srs_error_code(err); | |
} | |
return srs_error_wrap(err, "do cycle"); | |
} |
suggest another way.
About send_error_code
, I believe there is a dead loop:
srs/trunk/src/app/srs_app_edge.cpp
Lines 864 to 884 in 8c034e5
while (true) { | |
if ((err = trd->pull()) != srs_success) { | |
return srs_error_wrap(err, "edge forward pull"); | |
} | |
if (send_error_code != ERROR_SUCCESS) { | |
srs_usleep(SRS_EDGE_FORWARDER_TIMEOUT); | |
continue; | |
} | |
// read from client. | |
if (true) { | |
SrsCommonMessage* msg = NULL; | |
err = sdk->recv_message(&msg); | |
if (err != srs_success && srs_error_code(err) != ERROR_SOCKET_TIMEOUT) { | |
srs_error("edge push get server control message failed. err=%s", srs_error_desc(err).c_str()); | |
send_error_code = srs_error_code(err); | |
srs_error_reset(err); | |
continue; | |
} |
there are no place to set send_error_code
= ERROR_SUCCESS in the loop, only set the value when sdk->recv_message(&msg)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not dead loop, the publish owner will stop it when error.
1. Should always stop coroutine before close fd, see #511, #1784 2. When edge forwarder coroutine quit, always set the error code. 3. Do not unpublish if invalid state. --------- Co-authored-by: Jacob Su <[email protected]>
Co-authored-by: Jacob Su [email protected]