Implement non-blocking recvfrom on Windows (#1124)
This pull request is a split of PR #1061 As @KangLin pointed out in the original PR those sockets should ideally be permanently non-blocking for performance reasons, but they are NOT at the moment. Someone with more knowledge about the code in dtls_listener.c should probably have a look if it would be feasible to change the sockets to non-blocking already at creation, similar to what is done in udpserver.c...
This commit is contained in:
parent
fae5d2756e
commit
980ef8f9dc
@ -621,8 +621,9 @@ start_udp_cycle:
|
|||||||
|
|
||||||
ssize_t bsize = 0;
|
ssize_t bsize = 0;
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
// TODO: implement it!!!
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
u_long iMode = 1;
|
||||||
|
ioctlsocket(fd, FIONBIO, &iMode);
|
||||||
#else
|
#else
|
||||||
int flags = MSG_DONTWAIT;
|
int flags = MSG_DONTWAIT;
|
||||||
#endif
|
#endif
|
||||||
@ -633,6 +634,11 @@ start_udp_cycle:
|
|||||||
int conn_reset = is_connreset();
|
int conn_reset = is_connreset();
|
||||||
int to_block = would_block();
|
int to_block = would_block();
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
iMode = 0;
|
||||||
|
ioctlsocket(fd, FIONBIO, &iMode);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bsize < 0) {
|
if (bsize < 0) {
|
||||||
|
|
||||||
if (to_block) {
|
if (to_block) {
|
||||||
@ -645,8 +651,9 @@ start_udp_cycle:
|
|||||||
#if defined(MSG_ERRQUEUE)
|
#if defined(MSG_ERRQUEUE)
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
// TODO: implement it!!!
|
|
||||||
int eflags = MSG_ERRQUEUE;
|
int eflags = MSG_ERRQUEUE;
|
||||||
|
iMode = 1;
|
||||||
|
ioctlsocket(fd, FIONBIO, &iMode);
|
||||||
#else
|
#else
|
||||||
// Linux
|
// Linux
|
||||||
int eflags = MSG_ERRQUEUE | MSG_DONTWAIT;
|
int eflags = MSG_ERRQUEUE | MSG_DONTWAIT;
|
||||||
@ -668,6 +675,11 @@ start_udp_cycle:
|
|||||||
conn_reset = is_connreset();
|
conn_reset = is_connreset();
|
||||||
to_block = would_block();
|
to_block = would_block();
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
iMode = 0;
|
||||||
|
ioctlsocket(fd, FIONBIO, &iMode);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (conn_reset) {
|
if (conn_reset) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user