1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

hotfix #200, deadloop when read/write 0 and ETIME. 1.0.6.

This commit is contained in:
winlin 2014-11-13 14:48:21 +08:00
parent f2f259d050
commit eba1740ed5
4 changed files with 55 additions and 24 deletions

View file

@ -82,8 +82,10 @@ int SrsStSocket::read(void* buf, size_t size, ssize_t* nread)
// On success a non-negative integer indicating the number of bytes actually read is returned
// (a value of 0 means the network connection is closed or end of file is reached).
// Otherwise, a value of -1 is returned and errno is set to indicate the error.
if (nb_read <= 0) {
if (errno == ETIME) {
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if (nb_read < 0 && errno == ETIME) {
return ERROR_SOCKET_TIMEOUT;
}
@ -110,8 +112,10 @@ int SrsStSocket::read_fully(void* buf, size_t size, ssize_t* nread)
// On success a non-negative integer indicating the number of bytes actually read is returned
// (a value less than nbyte means the network connection is closed or end of file is reached)
// Otherwise, a value of -1 is returned and errno is set to indicate the error.
if (nb_read != (ssize_t)size) {
if (errno == ETIME) {
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if (nb_read < 0 && errno == ETIME) {
return ERROR_SOCKET_TIMEOUT;
}
@ -136,8 +140,11 @@ int SrsStSocket::write(void* buf, size_t size, ssize_t* nwrite)
*nwrite = nb_write;
}
// On success a non-negative integer equal to nbyte is returned.
// Otherwise, a value of -1 is returned and errno is set to indicate the error.
if (nb_write <= 0) {
if (errno == ETIME) {
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if (nb_write < 0 && errno == ETIME) {
return ERROR_SOCKET_TIMEOUT;
}
@ -158,8 +165,11 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
*nwrite = nb_write;
}
// On success a non-negative integer equal to nbyte is returned.
// Otherwise, a value of -1 is returned and errno is set to indicate the error.
if (nb_write <= 0) {
if (errno == ETIME) {
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if (nb_write < 0 && errno == ETIME) {
return ERROR_SOCKET_TIMEOUT;
}