<div dir="auto">Looks ok. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 17, 2021, 3:49 AM <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Chris Johns <<a href="mailto:chrisj@rtems.org" target="_blank" rel="noreferrer">chrisj@rtems.org</a>><br>
<br>
- Support all possible descriptors in a select call. Borrowed<br>
from Christain and his mDNS change in LibBSD<br>
<br>
- If select (or poll) fails pause for a bit rather than<br>
locking up in a hard loop<br>
---<br>
cpukit/mghttpd/mongoose.c | 28 ++++++++++++++++++++++++++++<br>
1 file changed, 28 insertions(+)<br>
<br>
diff --git a/cpukit/mghttpd/mongoose.c b/cpukit/mghttpd/mongoose.c<br>
index 0736c836ec..5e7e68e7ea 100644<br>
--- a/cpukit/mghttpd/mongoose.c<br>
+++ b/cpukit/mghttpd/mongoose.c<br>
@@ -81,6 +81,12 @@<br>
#include <stddef.h><br>
#include <stdio.h><br>
<br>
+#if __rtems__<br>
+#include <time.h><br>
+#include <sys/param.h><br>
+#include <rtems/libio_.h><br>
+#endif<br>
+<br>
#if defined(_WIN32) && !defined(__SYMBIAN32__) // Windows specific<br>
#undef _WIN32_WINNT<br>
#define _WIN32_WINNT 0x0400 // To make it link in VS2005<br>
@@ -1516,13 +1522,32 @@ static int set_non_blocking_mode(SOCKET sock) {<br>
#ifndef HAVE_POLL<br>
static int poll(struct pollfd *pfd, int n, int milliseconds) {<br>
struct timeval tv;<br>
+#if __rtems__<br>
+ #define set (*set_prealloc)<br>
+ static fd_set *set_prealloc;<br>
+ static size_t set_size;<br>
+#else<br>
fd_set set;<br>
+#endif<br>
int i, result;<br>
SOCKET maxfd = 0;<br>
<br>
tv.tv_sec = milliseconds / 1000;<br>
tv.tv_usec = (milliseconds % 1000) * 1000;<br>
+#if __rtems__<br>
+ if (set_prealloc == NULL) {<br>
+ set_size =<br>
+ sizeof(fd_set) * (howmany(rtems_libio_number_iops, sizeof(fd_set) * 8));<br>
+ set_prealloc = malloc(set_size);<br>
+ if (set_prealloc == NULL) {<br>
+ errno = ENOMEM;<br>
+ return -1;<br>
+ }<br>
+ }<br>
+ memset(set_prealloc, 0, set_size);<br>
+#else<br>
FD_ZERO(&set);<br>
+#endif<br>
<br>
for (i = 0; i < n; i++) {<br>
FD_SET((SOCKET) pfd[i].fd, &set);<br>
@@ -5367,6 +5392,9 @@ static void *master_thread(void *thread_func_param) {<br>
accept_new_connection(&ctx->listening_sockets[i], ctx);<br>
}<br>
}<br>
+ } else {<br>
+ struct timespec t = { .tv_sec = 0, .tv_nsec = 500000000L };<br>
+ nanosleep(&t, &t);<br>
}<br>
}<br>
free(pfd);<br>
-- <br>
2.19.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>