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

merge from allspace srs-librtmp for win vs2010. 2.0.36

This commit is contained in:
winlin 2014-11-28 10:33:36 +08:00
parent 14fca601f9
commit 7f121efd7a
6 changed files with 68 additions and 53 deletions

View file

@ -45,22 +45,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SimpleSocketStream::SimpleSocketStream()
{
fd = -1;
SOCKET_RESET(fd);
send_timeout = recv_timeout = ST_UTIME_NO_TIMEOUT;
recv_bytes = send_bytes = 0;
SOCKET_SETUP();
}
SimpleSocketStream::~SimpleSocketStream()
{
if (fd != -1) {
::close(fd);
fd = -1;
}
SOCKET_CLOSE(fd);
SOCKET_CLEANUP();
}
int SimpleSocketStream::create_socket()
{
if((fd = ::socket(AF_INET, SOCK_STREAM, 0)) < 0){
fd = ::socket(AF_INET, SOCK_STREAM, 0);
if (!SOCKET_VALID(fd)) {
return ERROR_SOCKET_CREATE;
}
@ -95,12 +95,12 @@ int SimpleSocketStream::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).
if (nb_read <= 0) {
if (nb_read < 0 && errno == ETIME) {
if (nb_read < 0 && SOCKET_ERRNO() == SOCKET_ETIME) {
return ERROR_SOCKET_TIMEOUT;
}
if (nb_read == 0) {
errno = ECONNRESET;
errno = SOCKET_ECONNRESET;
}
return ERROR_SOCKET_READ;
@ -158,7 +158,7 @@ int SimpleSocketStream::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
// 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) {
if (nb_write < 0 && SOCKET_ERRNO() == SOCKET_ETIME) {
return ERROR_SOCKET_TIMEOUT;
}
@ -215,7 +215,7 @@ int SimpleSocketStream::write(void* buf, size_t size, ssize_t* nwrite)
if (nb_write <= 0) {
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if (nb_write < 0 && errno == ETIME) {
if (nb_write < 0 && SOCKET_ERRNO() == SOCKET_ETIME) {
return ERROR_SOCKET_TIMEOUT;
}