mirror of
https://github.com/devkitPro/wut.git
synced 2026-06-20 11:33:58 -05:00
- Fix select() to also update the fd_set arguments on timeout condition.
- Move the nfds argument restriction to the nsysnet side. - Allow user-defined FD_SETSIZE, since newlib's fd_set allow custom sizes. - Define __socklen_t_defined when socklen_t is typedefed.
This commit is contained in:
parent
cac70f560e
commit
055b968da7
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 32
|
||||
#endif
|
||||
|
||||
#include_next <sys/select.h>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@
|
|||
#define SO_NOSLOWSTART 0x4000 // disable slowstart
|
||||
#define SO_RUSRBUF 0x10000 // enable somemopt provided memory for receive buffer
|
||||
|
||||
typedef uint32_t socklen_t;
|
||||
#ifndef __socklen_t_defined
|
||||
typedef __socklen_t socklen_t;
|
||||
#define __socklen_t_defined
|
||||
#endif
|
||||
|
||||
typedef uint16_t sa_family_t;
|
||||
|
||||
struct sockaddr
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ select(int nfds,
|
|||
nsysnet_fd_set cnv_rd, cnv_wr, cnv_ex;
|
||||
struct nsysnet_timeval cnv_timeout;
|
||||
|
||||
if (nfds > FD_SETSIZE) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
NSYSNET_FD_ZERO(&cnv_rd);
|
||||
NSYSNET_FD_ZERO(&cnv_wr);
|
||||
NSYSNET_FD_ZERO(&cnv_ex);
|
||||
|
|
@ -38,6 +33,10 @@ select(int nfds,
|
|||
|
||||
if ((cnv_fd + 1) > cnv_nfds) {
|
||||
cnv_nfds = cnv_fd + 1;
|
||||
if (cnv_nfds > NSYSNET_FD_SETSIZE) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rd_fd) {
|
||||
|
|
@ -67,8 +66,6 @@ select(int nfds,
|
|||
return rc;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
if (readfds) {
|
||||
FD_ZERO(readfds);
|
||||
}
|
||||
|
|
@ -79,6 +76,11 @@ select(int nfds,
|
|||
FD_ZERO(exceptfds);
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
return 0;
|
||||
|
||||
rc = 0;
|
||||
|
||||
for (i = 0; i < nfds; i++) {
|
||||
int cnv_fd = __wut_get_nsysnet_fd(i);
|
||||
if (cnv_fd == -1) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user