mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Explicitly handle buffer errors in send/recv
This commit is contained in:
parent
ca171817a8
commit
e56567ff4d
@ -195,6 +195,9 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
|
||||
return ERR_NET_IN_PROGRESS;
|
||||
if (err == WSAEWOULDBLOCK)
|
||||
return ERR_NET_WOULD_BLOCK;
|
||||
if (err == WSAEMSGSIZE || err == WSAENOBUFS) {
|
||||
return ERR_NET_BUFFER_TOO_SMALL;
|
||||
}
|
||||
print_verbose("Socket error: " + itos(err));
|
||||
return ERR_NET_OTHER;
|
||||
#else
|
||||
@ -207,6 +210,9 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
return ERR_NET_WOULD_BLOCK;
|
||||
}
|
||||
if (errno == ENOBUFS) {
|
||||
return ERR_NET_BUFFER_TOO_SMALL;
|
||||
}
|
||||
print_verbose("Socket error: " + itos(errno));
|
||||
return ERR_NET_OTHER;
|
||||
#endif
|
||||
@ -535,6 +541,9 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) {
|
||||
if (err == ERR_NET_WOULD_BLOCK) {
|
||||
return ERR_BUSY;
|
||||
}
|
||||
if (err == ERR_NET_BUFFER_TOO_SMALL) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return FAILED;
|
||||
}
|
||||
@ -556,6 +565,9 @@ Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Add
|
||||
if (err == ERR_NET_WOULD_BLOCK) {
|
||||
return ERR_BUSY;
|
||||
}
|
||||
if (err == ERR_NET_BUFFER_TOO_SMALL) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return FAILED;
|
||||
}
|
||||
@ -592,6 +604,9 @@ Error NetSocketPosix::send(const uint8_t *p_buffer, int p_len, int &r_sent) {
|
||||
if (err == ERR_NET_WOULD_BLOCK) {
|
||||
return ERR_BUSY;
|
||||
}
|
||||
if (err == ERR_NET_BUFFER_TOO_SMALL) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return FAILED;
|
||||
}
|
||||
@ -611,6 +626,9 @@ Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP
|
||||
if (err == ERR_NET_WOULD_BLOCK) {
|
||||
return ERR_BUSY;
|
||||
}
|
||||
if (err == ERR_NET_BUFFER_TOO_SMALL) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return FAILED;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ private:
|
||||
ERR_NET_WOULD_BLOCK,
|
||||
ERR_NET_IS_CONNECTED,
|
||||
ERR_NET_IN_PROGRESS,
|
||||
ERR_NET_BUFFER_TOO_SMALL,
|
||||
ERR_NET_OTHER
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user