mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-15 10:29:47 +00:00
Stop pretending that sl_* API is BSD-compatible
PUBLISHED_FROM=355fea9a5a75ac926d4c64d41828ebcd96c04080
This commit is contained in:
1 parent
abbd44e276
commit
7414a4fb06
2 files changed
+16
-35
No files matched your search
+16
-15
@@ -10774,7 +10774,7 @@ static sock_t mg_open_listening_socket(union socket_address *sa, int type,
|
||||
(sa->sa.sa_family == AF_INET) ? sizeof(sa->sin) : sizeof(sa->sin6);
|
||||
sock_t sock = sl_Socket(sa->sa.sa_family, type, proto);
|
||||
if (sock < 0) return sock;
|
||||
if ((r = bind(sock, &sa->sa, sa_len)) < 0) {
|
||||
if ((r = sl_Bind(sock, &sa->sa, sa_len)) < 0) {
|
||||
sl_Close(sock);
|
||||
return r;
|
||||
}
|
||||
@@ -10792,7 +10792,7 @@ static void mg_write_to_socket(struct mg_connection *nc) {
|
||||
|
||||
if (nc->flags & MG_F_UDP) {
|
||||
n = sl_SendTo(nc->sock, io->buf, io->len, 0, &nc->sa.sa,
|
||||
sizeof(nc->sa.sin));
|
||||
sizeof(nc->sa.sin));
|
||||
DBG(("%p %d %d %d %s:%hu", nc, nc->sock, n, errno,
|
||||
inet_ntoa(nc->sa.sin.sin_addr), ntohs(nc->sa.sin.sin_port)));
|
||||
} else {
|
||||
@@ -10946,13 +10946,13 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int timeout_ms) {
|
||||
double min_timer;
|
||||
struct mg_connection *nc, *tmp;
|
||||
struct SlTimeval_t tv;
|
||||
fd_set read_set, write_set, err_set;
|
||||
SlFdSet_t read_set, write_set, err_set;
|
||||
sock_t max_fd = INVALID_SOCKET;
|
||||
int num_fds, num_ev, num_timers = 0;
|
||||
|
||||
FD_ZERO(&read_set);
|
||||
FD_ZERO(&write_set);
|
||||
FD_ZERO(&err_set);
|
||||
SL_FD_ZERO(&read_set);
|
||||
SL_FD_ZERO(&write_set);
|
||||
SL_FD_ZERO(&err_set);
|
||||
|
||||
/*
|
||||
* Note: it is ok to have connections with sock == INVALID_SOCKET in the list,
|
||||
@@ -10968,14 +10968,14 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int timeout_ms) {
|
||||
if (!(nc->flags & MG_F_WANT_WRITE) &&
|
||||
nc->recv_mbuf.len < nc->recv_mbuf_limit &&
|
||||
(!(nc->flags & MG_F_UDP) || nc->listener == NULL)) {
|
||||
FD_SET(nc->sock, &read_set);
|
||||
SL_FD_SET(nc->sock, &read_set);
|
||||
if (max_fd == INVALID_SOCKET || nc->sock > max_fd) max_fd = nc->sock;
|
||||
}
|
||||
|
||||
if (((nc->flags & MG_F_CONNECTING) && !(nc->flags & MG_F_WANT_READ)) ||
|
||||
(nc->send_mbuf.len > 0 && !(nc->flags & MG_F_CONNECTING))) {
|
||||
FD_SET(nc->sock, &write_set);
|
||||
FD_SET(nc->sock, &err_set);
|
||||
SL_FD_SET(nc->sock, &write_set);
|
||||
SL_FD_SET(nc->sock, &err_set);
|
||||
if (max_fd == INVALID_SOCKET || nc->sock > max_fd) max_fd = nc->sock;
|
||||
}
|
||||
}
|
||||
@@ -11012,12 +11012,13 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int timeout_ms) {
|
||||
int fd_flags = 0;
|
||||
if (nc->sock != INVALID_SOCKET) {
|
||||
if (num_ev > 0) {
|
||||
fd_flags = (FD_ISSET(nc->sock, &read_set) &&
|
||||
(!(nc->flags & MG_F_UDP) || nc->listener == NULL)
|
||||
? _MG_F_FD_CAN_READ
|
||||
: 0) |
|
||||
(FD_ISSET(nc->sock, &write_set) ? _MG_F_FD_CAN_WRITE : 0) |
|
||||
(FD_ISSET(nc->sock, &err_set) ? _MG_F_FD_ERROR : 0);
|
||||
fd_flags =
|
||||
(SL_FD_ISSET(nc->sock, &read_set) &&
|
||||
(!(nc->flags & MG_F_UDP) || nc->listener == NULL)
|
||||
? _MG_F_FD_CAN_READ
|
||||
: 0) |
|
||||
(SL_FD_ISSET(nc->sock, &write_set) ? _MG_F_FD_CAN_WRITE : 0) |
|
||||
(SL_FD_ISSET(nc->sock, &err_set) ? _MG_F_FD_ERROR : 0);
|
||||
}
|
||||
/* SimpleLink does not report UDP sockets as writeable. */
|
||||
if (nc->flags & MG_F_UDP && nc->send_mbuf.len > 0) {
|
||||
|
||||
-20
@@ -732,31 +732,11 @@ int _stat(const char *pathname, struct stat *st);
|
||||
#define SOCK_STREAM SL_SOCK_STREAM
|
||||
#define SOCK_DGRAM SL_SOCK_DGRAM
|
||||
|
||||
#define FD_SET SL_FD_SET
|
||||
#define FD_CLR SL_FD_CLR
|
||||
#define FD_ISSET SL_FD_ISSET
|
||||
#define FD_ZERO SL_FD_ZERO
|
||||
#define fd_set SlFdSet_t
|
||||
|
||||
#define htonl sl_Htonl
|
||||
#define ntohl sl_Ntohl
|
||||
#define htons sl_Htons
|
||||
#define ntohs sl_Ntohs
|
||||
|
||||
#define accept sl_Accept
|
||||
#define closesocket sl_Close
|
||||
#define bind sl_Bind
|
||||
#define connect sl_Connect
|
||||
#define listen sl_Listen
|
||||
#define recv sl_Recv
|
||||
#define recvfrom sl_RecvFrom
|
||||
#define send sl_Send
|
||||
#define sendto sl_SendTo
|
||||
#define socket sl_Socket
|
||||
|
||||
#define select(nfds, rfds, wfds, efds, tout) \
|
||||
sl_Select((nfds), (rfds), (wfds), (efds), (struct SlTimeval_t *)(tout))
|
||||
|
||||
#ifndef EACCES
|
||||
#define EACCES SL_EACCES
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user