Mercurial > pidgin.yaz
diff src/win32/libc_interface.c @ 13200:33bef17125c2
[gaim-migrate @ 15563]
This is the soon-to-be-infamous nonblocking network activity patch that I've been working on. Feel free to yell at me if this makes you unhappy.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 09 Feb 2006 04:17:56 +0000 |
parents | 13276711babc |
children | b04212d6b115 |
line wrap: on
line diff
--- a/src/win32/libc_interface.c Thu Feb 09 04:14:54 2006 +0000 +++ b/src/win32/libc_interface.c Thu Feb 09 04:17:56 2006 +0000 @@ -276,9 +276,11 @@ int wgaim_read(int fd, void *buf, unsigned int size) { int ret; - if( wgaim_is_socket(fd) ) { - if( (ret = recv(fd, buf, size, 0)) == SOCKET_ERROR ) { + if(wgaim_is_socket(fd)) { + if((ret = recv(fd, buf, size, 0)) == SOCKET_ERROR) { errno = WSAGetLastError(); + if(errno == WSAEWOULDBLOCK) + errno = EAGAIN; return -1; } #if 0 @@ -292,8 +294,7 @@ /* success reading socket */ return ret; } - } - else { + } else { /* fd is not a socket handle.. pass it off to read */ return read(fd, buf, size); } @@ -302,25 +303,27 @@ int wgaim_write(int fd, const void *buf, unsigned int size) { int ret; - if( wgaim_is_socket(fd) ) { - if( (ret = send(fd, buf, size, 0)) == SOCKET_ERROR ) { + if(wgaim_is_socket(fd)) { + if((ret = send(fd, buf, size, 0)) == SOCKET_ERROR) { errno = WSAGetLastError(); + if(errno == WSAEWOULDBLOCK) + errno = EAGAIN; return -1; - } - else { + } else { /* success */ return ret; } - } - else + } else return write(fd, buf, size); } int wgaim_recv(int fd, void *buf, size_t len, int flags) { int ret; - if ((ret = recv(fd, buf, len, flags)) == SOCKET_ERROR) { + if((ret = recv(fd, buf, len, flags)) == SOCKET_ERROR) { errno = WSAGetLastError(); + if(errno == WSAEWOULDBLOCK) + errno = EAGAIN; return -1; } else { return ret;