mirror of
https://github.com/Fishwaldo/minihttp.git
synced 2025-07-06 21:08:47 +00:00
fuck POSIX; errno shall die in a fire
This commit is contained in:
parent
f3d366320f
commit
cf2e45aa84
1 changed files with 6 additions and 4 deletions
10
minihttp.cpp
10
minihttp.cpp
|
@ -618,6 +618,8 @@ int TcpSocket::_writeBytes(const unsigned char *buf, size_t len)
|
||||||
flags |= MSG_NOSIGNAL;
|
flags |= MSG_NOSIGNAL;
|
||||||
#endif
|
#endif
|
||||||
ret = ::send(_s, buf, len, flags);
|
ret = ::send(_s, buf, len, flags);
|
||||||
|
if(ret == -1) // *nix just returns -1 and sets errno... in that case, return the actual error
|
||||||
|
ret = _GetError();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -645,7 +647,8 @@ int TcpSocket::_readBytes(unsigned char *buf, size_t maxlen)
|
||||||
else
|
else
|
||||||
return net_recv(&_s, buf, maxlen);
|
return net_recv(&_s, buf, maxlen);
|
||||||
#else
|
#else
|
||||||
return recv(_s, buf, maxlen, 0); // last char is used as string terminator
|
int bytes = recv(_s, buf, maxlen, 0); // last char is used as string terminator
|
||||||
|
return bytes != -1 ? bytes : _GetError(); // *nix just returns -1 and sets errno... in that case, return the actual error
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,8 +683,7 @@ bool TcpSocket::update(void)
|
||||||
}
|
}
|
||||||
else // whoops, error?
|
else // whoops, error?
|
||||||
{
|
{
|
||||||
int err = _GetError();
|
switch(bytes)
|
||||||
switch(err)
|
|
||||||
{
|
{
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
#if defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
|
#if defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
|
||||||
|
@ -695,7 +697,7 @@ bool TcpSocket::update(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
traceprint("SOCKET UPDATE ERROR: (%d): %s\n", err, _GetErrorStr(err).c_str());
|
traceprint("SOCKET UPDATE ERROR: (%d): %s\n", bytes, _GetErrorStr(bytes).c_str());
|
||||||
case ECONNRESET:
|
case ECONNRESET:
|
||||||
case ENOTCONN:
|
case ENOTCONN:
|
||||||
case ETIMEDOUT:
|
case ETIMEDOUT:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue