正在显示
2 个修改的文件
包含
17 行增加
和
4 行删除
@@ -84,6 +84,7 @@ int SrsStSocket::read(void* buf, size_t size, ssize_t* nread) | @@ -84,6 +84,7 @@ int SrsStSocket::read(void* buf, size_t size, ssize_t* nread) | ||
84 | // (a value of 0 means the network connection is closed or end of file is reached). | 84 | // (a value of 0 means the network connection is closed or end of file is reached). |
85 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. | 85 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. |
86 | if (nb_read <= 0) { | 86 | if (nb_read <= 0) { |
87 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/200 | ||
87 | if (nb_read < 0 && errno == ETIME) { | 88 | if (nb_read < 0 && errno == ETIME) { |
88 | return ERROR_SOCKET_TIMEOUT; | 89 | return ERROR_SOCKET_TIMEOUT; |
89 | } | 90 | } |
@@ -113,6 +114,7 @@ int SrsStSocket::read_fully(void* buf, size_t size, ssize_t* nread) | @@ -113,6 +114,7 @@ int SrsStSocket::read_fully(void* buf, size_t size, ssize_t* nread) | ||
113 | // (a value less than nbyte means the network connection is closed or end of file is reached) | 114 | // (a value less than nbyte means the network connection is closed or end of file is reached) |
114 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. | 115 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. |
115 | if (nb_read != (ssize_t)size) { | 116 | if (nb_read != (ssize_t)size) { |
117 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/200 | ||
116 | if (nb_read < 0 && errno == ETIME) { | 118 | if (nb_read < 0 && errno == ETIME) { |
117 | return ERROR_SOCKET_TIMEOUT; | 119 | return ERROR_SOCKET_TIMEOUT; |
118 | } | 120 | } |
@@ -141,6 +143,7 @@ int SrsStSocket::write(void* buf, size_t size, ssize_t* nwrite) | @@ -141,6 +143,7 @@ int SrsStSocket::write(void* buf, size_t size, ssize_t* nwrite) | ||
141 | // On success a non-negative integer equal to nbyte is returned. | 143 | // On success a non-negative integer equal to nbyte is returned. |
142 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. | 144 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. |
143 | if (nb_write <= 0) { | 145 | if (nb_write <= 0) { |
146 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/200 | ||
144 | if (nb_write < 0 && errno == ETIME) { | 147 | if (nb_write < 0 && errno == ETIME) { |
145 | return ERROR_SOCKET_TIMEOUT; | 148 | return ERROR_SOCKET_TIMEOUT; |
146 | } | 149 | } |
@@ -165,6 +168,7 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite) | @@ -165,6 +168,7 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite) | ||
165 | // On success a non-negative integer equal to nbyte is returned. | 168 | // On success a non-negative integer equal to nbyte is returned. |
166 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. | 169 | // Otherwise, a value of -1 is returned and errno is set to indicate the error. |
167 | if (nb_write <= 0) { | 170 | if (nb_write <= 0) { |
171 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/200 | ||
168 | if (nb_write < 0 && errno == ETIME) { | 172 | if (nb_write < 0 && errno == ETIME) { |
169 | return ERROR_SOCKET_TIMEOUT; | 173 | return ERROR_SOCKET_TIMEOUT; |
170 | } | 174 | } |
@@ -143,17 +143,25 @@ int SimpleSocketStream::writev(const iovec *iov, int iov_size, ssize_t* nwrite) | @@ -143,17 +143,25 @@ int SimpleSocketStream::writev(const iovec *iov, int iov_size, ssize_t* nwrite) | ||
143 | { | 143 | { |
144 | int ret = ERROR_SUCCESS; | 144 | int ret = ERROR_SUCCESS; |
145 | 145 | ||
146 | - *nwrite = ::writev(fd, iov, iov_size); | 146 | + ssize_t nb_write = ::writev(fd, iov, iov_size); |
147 | 147 | ||
148 | - if (*nwrite <= 0) { | ||
149 | - if (errno == ETIME) { | 148 | + if (nwrite) { |
149 | + *nwrite = nb_write; | ||
150 | + } | ||
151 | + | ||
152 | + // On success, the readv() function returns the number of bytes read; | ||
153 | + // the writev() function returns the number of bytes written. On error, -1 is | ||
154 | + // returned, and errno is set appropriately. | ||
155 | + if (nb_write <= 0) { | ||
156 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/200 | ||
157 | + if (nb_write < 0 && errno == ETIME) { | ||
150 | return ERROR_SOCKET_TIMEOUT; | 158 | return ERROR_SOCKET_TIMEOUT; |
151 | } | 159 | } |
152 | 160 | ||
153 | return ERROR_SOCKET_WRITE; | 161 | return ERROR_SOCKET_WRITE; |
154 | } | 162 | } |
155 | 163 | ||
156 | - send_bytes += *nwrite; | 164 | + send_bytes += nb_write; |
157 | 165 | ||
158 | return ret; | 166 | return ret; |
159 | } | 167 | } |
@@ -202,6 +210,7 @@ int SimpleSocketStream::write(void* buf, size_t size, ssize_t* nwrite) | @@ -202,6 +210,7 @@ int SimpleSocketStream::write(void* buf, size_t size, ssize_t* nwrite) | ||
202 | } | 210 | } |
203 | 211 | ||
204 | if (nb_write <= 0) { | 212 | if (nb_write <= 0) { |
213 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/200 | ||
205 | if (nb_write < 0 && errno == ETIME) { | 214 | if (nb_write < 0 && errno == ETIME) { |
206 | return ERROR_SOCKET_TIMEOUT; | 215 | return ERROR_SOCKET_TIMEOUT; |
207 | } | 216 | } |
-
请 注册 或 登录 后发表评论