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

Merge branch 'srs.1.0release' into 1.0release

This commit is contained in:
winlin 2014-11-13 14:49:20 +08:00
commit 2da1ba0a1f
4 changed files with 55 additions and 24 deletions

View file

@ -208,10 +208,11 @@ Supported operating systems and hardware:
* 2013-10-17, Created.<br/> * 2013-10-17, Created.<br/>
## History ## History
* v2.0, 2014-11-13, hotfix [#200](https://github.com/winlinvip/simple-rtmp-server/issues/200), deadloop when read/write 0 and ETIME. 1.0.6.
* v1.0, 2014-11-06, use number for macro VERSION_MAJOR, VERSION_MINOR and VERSION_REVISION. 1.0.5. * v1.0, 2014-11-06, use number for macro VERSION_MAJOR, VERSION_MINOR and VERSION_REVISION. 1.0.5.
* v1.0, 2014-10-24, fix [#186](https://github.com/winlinvip/simple-rtmp-server/issues/186), hotfix for bug #186, drop connect args when not object. 1.0.3. * v1.0, 2014-10-24, hotfix [#186](https://github.com/winlinvip/simple-rtmp-server/issues/186), drop connect args when not object. 1.0.3.
* v1.0, 2014-10-24, rename wiki/xxx to wiki/v1_CN_xxx. 1.0.2. * v1.0, 2014-10-24, rename wiki/xxx to wiki/v1_CN_xxx. 1.0.2.
* v1.0, 2014-10-19, fix [#183](https://github.com/winlinvip/simple-rtmp-server/issues/183), hotfix for bug #183, donot support AnnexB when decoding RTMP body for HLS. 1.0.1. * v1.0, 2014-10-19, hotfix [#183](https://github.com/winlinvip/simple-rtmp-server/issues/183), donot support AnnexB when decoding RTMP body for HLS. 1.0.1.
* <strong>v1.0, 2014-10-09, [1.0 beta(1.0.0)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.beta) released. 59316 lines.</strong> * <strong>v1.0, 2014-10-09, [1.0 beta(1.0.0)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.beta) released. 59316 lines.</strong>
* v1.0, 2014-10-08, fix [#151](https://github.com/winlinvip/simple-rtmp-server/issues/151), always reap ts whatever audio or video packet. 0.9.223. * v1.0, 2014-10-08, fix [#151](https://github.com/winlinvip/simple-rtmp-server/issues/151), always reap ts whatever audio or video packet. 0.9.223.
* v1.0, 2014-10-08, fix [#162](https://github.com/winlinvip/simple-rtmp-server/issues/162), failed if no epoll. 0.9.222. * v1.0, 2014-10-08, fix [#162](https://github.com/winlinvip/simple-rtmp-server/issues/162), failed if no epoll. 0.9.222.

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 // 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). // (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 (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; 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 // 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) // (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 (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; return ERROR_SOCKET_TIMEOUT;
} }
@ -136,8 +140,11 @@ int SrsStSocket::write(void* buf, size_t size, ssize_t* nwrite)
*nwrite = nb_write; *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 (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; return ERROR_SOCKET_TIMEOUT;
} }
@ -158,8 +165,11 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
*nwrite = nb_write; *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 (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; return ERROR_SOCKET_TIMEOUT;
} }

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version // current release version
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 5 #define VERSION_REVISION 6
// server info. // server info.
#define RTMP_SIG_SRS_KEY "SRS" #define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server" #define RTMP_SIG_SRS_ROLE "origin/edge server"

View file

@ -82,23 +82,27 @@ int SimpleSocketStream::read(void* buf, size_t size, ssize_t* nread)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
*nread = ::recv(fd, buf, size, 0); ssize_t nb_read = ::recv(fd, buf, size, 0);
if (nread) {
*nread = nb_read;
}
// On success a non-negative integer indicating the number of bytes actually read is returned // 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). // (a value of 0 means the network connection is closed or end of file is reached).
if (*nread <= 0) { if (nb_read <= 0) {
if (errno == ETIME) { if (nb_read < 0 && errno == ETIME) {
return ERROR_SOCKET_TIMEOUT; return ERROR_SOCKET_TIMEOUT;
} }
if (*nread == 0) { if (nb_read == 0) {
errno = ECONNRESET; errno = ECONNRESET;
} }
return ERROR_SOCKET_READ; return ERROR_SOCKET_READ;
} }
recv_bytes += *nread; recv_bytes += nb_read;
return ret; return ret;
} }
@ -139,17 +143,25 @@ int SimpleSocketStream::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
*nwrite = ::writev(fd, iov, iov_size); ssize_t nb_write = ::writev(fd, iov, iov_size);
if (*nwrite <= 0) { if (nwrite) {
if (errno == ETIME) { *nwrite = nb_write;
}
// On success, the readv() function returns the number of bytes read;
// the writev() function returns the number of bytes written. On error, -1 is
// returned, and errno is set appropriately.
if (nb_write <= 0) {
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if (nb_write < 0 && errno == ETIME) {
return ERROR_SOCKET_TIMEOUT; return ERROR_SOCKET_TIMEOUT;
} }
return ERROR_SOCKET_WRITE; return ERROR_SOCKET_WRITE;
} }
send_bytes += *nwrite; send_bytes += nb_write;
return ret; return ret;
} }
@ -165,21 +177,24 @@ int SimpleSocketStream::read_fully(void* buf, size_t size, ssize_t* nread)
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
size_t left = size; size_t left = size;
*nread = 0; ssize_t nb_read = 0;
while (left > 0) { while (left > 0) {
char* this_buf = (char*)buf + *nread; char* this_buf = (char*)buf + nb_read;
ssize_t this_nread; ssize_t this_nread;
if ((ret = this->read(this_buf, left, &this_nread)) != ERROR_SUCCESS) { if ((ret = this->read(this_buf, left, &this_nread)) != ERROR_SUCCESS) {
return ret; return ret;
} }
*nread += this_nread; nb_read += this_nread;
left -= this_nread; left -= this_nread;
} }
recv_bytes += *nread; if (nread) {
*nread = nb_read;
}
recv_bytes += nb_read;
return ret; return ret;
} }
@ -188,17 +203,22 @@ int SimpleSocketStream::write(void* buf, size_t size, ssize_t* nwrite)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
*nwrite = ::send(fd, (void*)buf, size, 0); ssize_t nb_write = ::send(fd, (void*)buf, size, 0);
if (*nwrite <= 0) { if (nwrite) {
if (errno == ETIME) { *nwrite = nb_write;
}
if (nb_write <= 0) {
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if (nb_write < 0 && errno == ETIME) {
return ERROR_SOCKET_TIMEOUT; return ERROR_SOCKET_TIMEOUT;
} }
return ERROR_SOCKET_WRITE; return ERROR_SOCKET_WRITE;
} }
send_bytes += *nwrite; send_bytes += nb_write;
return ret; return ret;
} }