From 8e767cf5bf0499ab676ed4413b017cadc32ae43d Mon Sep 17 00:00:00 2001 From: liangliang Date: Wed, 27 Apr 2016 12:31:43 +0800 Subject: [PATCH] =?UTF-8?q?Block=20socket=20=E8=AE=BE=E7=BD=AE=20timeout,?= =?UTF-8?q?=20=E7=BD=91=E7=BB=9C=E6=85=A2=E6=97=B6=E8=BF=94=E5=9B=9E=20err?= =?UTF-8?q?or=20code=20EGAIN,=20=E6=94=B9=E6=88=90=E5=83=8F=20EINTR=20?= =?UTF-8?q?=E4=B8=80=E6=A0=B7=E9=87=8D=E8=AF=95=E5=A4=84=E7=90=86=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E7=AB=8B=E5=8D=B3=20close=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtmp.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rtmp.c b/rtmp.c index 04ddc9a..923fd48 100644 --- a/rtmp.c +++ b/rtmp.c @@ -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) {