commit fa8072232a908e60ac6f54f25d0fd206c23add0e
parent 522d6ec0c1244508b9290138ab16f922e7ec9fb7
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Tue, 13 May 2025 13:38:16 +0200
draft json_echo implementation
Diffstat:
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/doc/examples/external-select.c b/doc/examples/external-select.c
@@ -82,7 +82,8 @@ sock_reg_update_cb (
/* prepend to DLL */
app_cntx->prev = NULL;
app_cntx->next = head;
- head->prev = app_cntx;
+ if (NULL != head)
+ head->prev = app_cntx;
head = app_cntx;
app_cntx->fd = fd;
}
@@ -141,6 +142,7 @@ main ()
NULL);
if (MHD_SC_OK !=
MHD_daemon_set_options (daemon,
+ MHD_D_OPTION_REREGISTER_ALL (MHD_YES),
MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_LEVEL (
&sock_reg_update_cb,
NULL)))
@@ -151,7 +153,8 @@ main ()
}
/* We run with everything on default, so port 80, no TLS */
MHD_daemon_start (d);
- while (1) {
+ while (1)
+ {
struct timeval ts;
struct AppSockContext *pos;
uint_fast64_t next_wait;
diff --git a/src/examples2/json_echo.c b/src/examples2/json_echo.c
@@ -152,6 +152,10 @@ sock_reg_update_cb (
MHD_APP_SOCKET_CNTX_TYPE *app_cntx,
struct MHD_EventUpdateContext *ecb_cntx)
{
+ fprintf (stderr,
+ "reg update on %d - %d\n",
+ fd,
+ watch_for);
/* Note: This code only works on UNIX where MHD_Socket is an "int". */
if (fd >= FD_SETSIZE)
return NULL; /* not allowed by select() */
@@ -177,7 +181,8 @@ sock_reg_update_cb (
/* prepend to DLL */
app_cntx->prev = NULL;
app_cntx->next = head;
- head->prev = app_cntx;
+ if (NULL != head)
+ head->prev = app_cntx;
head = app_cntx;
app_cntx->fd = fd;
}
@@ -202,6 +207,9 @@ sock_reg_update_cb (
&es);
if (fd > max_fd)
max_fd = fd;
+ fprintf (stderr,
+ "returning %p\n",
+ app_cntx);
return app_cntx;
}
@@ -231,13 +239,9 @@ main (int argc,
char *const *argv)
{
struct MHD_Daemon *d;
- struct timeval tv;
- struct timeval *tvp;
fd_set rs;
fd_set ws;
fd_set es;
- MHD_Socket max;
- uint64_t mhd_timeout;
unsigned int port;
char dummy;
@@ -285,6 +289,7 @@ main (int argc,
if (MHD_SC_OK !=
MHD_DAEMON_SET_OPTIONS (
d,
+ MHD_D_OPTION_REREGISTER_ALL (MHD_YES),
MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL (
&sock_reg_update_cb,
NULL),