mirror of
https://github.com/Kiritow/GSock.git
synced 2024-03-22 13:10:51 +08:00
Fix bugs in Linux
This commit is contained in:
parent
f733f6c74e
commit
0213119ad8
15
gsock.cpp
15
gsock.cpp
|
@ -138,8 +138,7 @@ gerrno TranslateNativeErrToGErr(int native_errcode)
|
||||||
case WSAEINTR:
|
case WSAEINTR:
|
||||||
return gerrno::Interrupted;
|
return gerrno::Interrupted;
|
||||||
#else
|
#else
|
||||||
case EAGAIN:
|
case EWOULDBLOCK: // EAGAIN == EWOULDBLOCK
|
||||||
case EWOULDBLOCK:
|
|
||||||
return gerrno::WouldBlock;
|
return gerrno::WouldBlock;
|
||||||
case EINPROGRESS:
|
case EINPROGRESS:
|
||||||
return gerrno::InProgress;
|
return gerrno::InProgress;
|
||||||
|
@ -165,6 +164,7 @@ struct vsock::_impl
|
||||||
// Does not set "nonblocking" flag.
|
// Does not set "nonblocking" flag.
|
||||||
int doSetNonblocking()
|
int doSetNonblocking()
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
u_long mode = 1;
|
u_long mode = 1;
|
||||||
if (ioctlsocket(sfd, FIONBIO, &mode) == 0)
|
if (ioctlsocket(sfd, FIONBIO, &mode) == 0)
|
||||||
{
|
{
|
||||||
|
@ -174,6 +174,13 @@ struct vsock::_impl
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int flag = fcntl(sfd, F_GETFL, 0);
|
||||||
|
if (flag < 0) return -1;
|
||||||
|
flag |= O_NONBLOCK;
|
||||||
|
if (fcntl(sfd, F_SETFL, flag) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -457,6 +464,8 @@ struct NBSendResult::_impl
|
||||||
|
|
||||||
void NBSendResult::_impl::update()
|
void NBSendResult::_impl::update()
|
||||||
{
|
{
|
||||||
|
if (status > 1) return;
|
||||||
|
|
||||||
int ret = send(sfd, ptr + done, total - done, 0);
|
int ret = send(sfd, ptr + done, total - done, 0);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
|
@ -547,6 +556,8 @@ struct NBRecvResult::_impl
|
||||||
|
|
||||||
void NBRecvResult::_impl::update()
|
void NBRecvResult::_impl::update()
|
||||||
{
|
{
|
||||||
|
if (status > 1) return;
|
||||||
|
|
||||||
int ret = recv(sfd, ptr + done, maxsz - done, 0);
|
int ret = recv(sfd, ptr + done, maxsz - done, 0);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user