Skip to content
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

Block socket 设置 timeout, 网络慢时返回 error code EGAIN, 改成像 EINTR 一样重试处理而不是… #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion rtmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,19 @@ WriteN(PILI_RTMP *r, const char *buffer, int n, RTMPError *error)
RTMP_Log(RTMP_LOGERROR, "%s, PILI_RTMP send error %d, %s, (%d bytes)", __FUNCTION__,
sockerr, strerror(sockerr), n);

if (sockerr == EINTR && !PILI_RTMP_ctrlC)
/*
Specify the receiving or sending timeouts until reporting an error.
The argument is a struct timeval.
If an input or output function blocks for this period of time,
and data has been sent or received,
the return value of that function will be the amount of data transferred;
if no data has been transferred and the timeout has been reached then -1 is returned
with errno set to EAGAIN or EWOULDBLOCK, or EINPROGRESS (for connect(2)) just as if the socket was specified to be nonblocking.
If the timeout is set to zero (the default) then the operation will never timeout.
Timeouts only have effect for system calls that perform socket I/O (e.g., read(2), recvmsg(2), send(2), sendmsg(2));
timeouts have no effect for select(2), poll(2), epoll_wait(2), and so on.
*/
if ((sockerr == EINTR && !PILI_RTMP_ctrlC ) || sockerr == EAGAIN)
continue;

if (error) {
Expand Down