mirror of
https://github.com/godotengine/godot
synced 2024-09-05 07:28:25 +00:00
[Net] Explicitly handle buffer errors in send/recv
This commit is contained in:
parent
851bc640dd
commit
28001b9ef6
|
@ -204,6 +204,9 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
|
|||
if (err == WSAEACCES) {
|
||||
return ERR_NET_UNAUTHORIZED;
|
||||
}
|
||||
if (err == WSAEMSGSIZE || err == WSAENOBUFS) {
|
||||
return ERR_NET_BUFFER_TOO_SMALL;
|
||||
}
|
||||
print_verbose("Socket error: " + itos(err));
|
||||
return ERR_NET_OTHER;
|
||||
#else
|
||||
|
@ -222,6 +225,9 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
|
|||
if (errno == EACCES) {
|
||||
return ERR_NET_UNAUTHORIZED;
|
||||
}
|
||||
if (errno == ENOBUFS) {
|
||||
return ERR_NET_BUFFER_TOO_SMALL;
|
||||
}
|
||||
print_verbose("Socket error: " + itos(errno));
|
||||
return ERR_NET_OTHER;
|
||||
#endif
|
||||
|
@ -550,6 +556,10 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) {
|
|||
return ERR_BUSY;
|
||||
}
|
||||
|
||||
if (err == ERR_NET_BUFFER_TOO_SMALL) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
@ -571,6 +581,10 @@ Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddr
|
|||
return ERR_BUSY;
|
||||
}
|
||||
|
||||
if (err == ERR_NET_BUFFER_TOO_SMALL) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
@ -606,6 +620,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;
|
||||
}
|
||||
|
@ -625,6 +642,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;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
ERR_NET_IN_PROGRESS,
|
||||
ERR_NET_ADDRESS_INVALID_OR_UNAVAILABLE,
|
||||
ERR_NET_UNAUTHORIZED,
|
||||
ERR_NET_BUFFER_TOO_SMALL,
|
||||
ERR_NET_OTHER,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue