Skip to content

Commit

Permalink
For #2369, #1708, #1941: Check errno when close fd or stop thread
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 31, 2021
1 parent 60ab81a commit 1dbccdb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion trunk/src/app/srs_app_st.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,16 @@ void SrsFastCoroutine::stop()
if (trd) {
void* res = NULL;
int r0 = st_thread_join((st_thread_t)trd, &res);
srs_assert(!r0);
if (!r0) {
// By st_thread_join
if (errno == EINVAL) srs_assert(!r0);
if (errno == EDEADLK) srs_assert(!r0);
// By st_cond_timedwait
if (errno == EINTR) srs_assert(!r0);
if (errno == ETIME) srs_assert(!r0);
// Others
srs_assert(!r0);
}

srs_error_t err_res = (srs_error_t)res;
if (err_res != srs_success) {
Expand Down
13 changes: 11 additions & 2 deletions trunk/src/protocol/srs_service_st.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,17 @@ void srs_close_stfd(srs_netfd_t& stfd)
{
if (stfd) {
// we must ensure the close is ok.
int err = st_netfd_close((st_netfd_t)stfd);
srs_assert(err != -1);
int r0 = st_netfd_close((st_netfd_t)stfd);
if (!r0) {
// By _st_epoll_fd_close or _st_kq_fd_close
if (errno == EBUSY) srs_assert(!r0);
// By close
if (errno == EBADF) srs_assert(!r0);
if (errno == EINTR) srs_assert(!r0);
if (errno == EIO) srs_assert(!r0);
// Others
srs_assert(!r0);
}
stfd = NULL;
}
}
Expand Down

0 comments on commit 1dbccdb

Please sign in to comment.