simplify
This commit is contained in:
parent
2e1480dcab
commit
500a7fe2bb
@ -756,14 +756,10 @@ connection_done (void *cls,
|
|||||||
(void) connection;
|
(void) connection;
|
||||||
(void) socket_context;
|
(void) socket_context;
|
||||||
/* We only act if the connection is closed. */
|
/* We only act if the connection is closed. */
|
||||||
fprintf (stderr,
|
|
||||||
"Connection done!\n");
|
|
||||||
if (MHD_CONNECTION_NOTIFY_CLOSED != toe)
|
if (MHD_CONNECTION_NOTIFY_CLOSED != toe)
|
||||||
return;
|
return;
|
||||||
/* This callback is also present if the option wasn't, so
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
make sure the option was actually set. */
|
"Connection done!\n");
|
||||||
if (NULL == input_filename)
|
|
||||||
return;
|
|
||||||
do_terminate = GNUNET_YES;
|
do_terminate = GNUNET_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,11 +767,10 @@ connection_done (void *cls,
|
|||||||
/**
|
/**
|
||||||
* Run the exchange to serve a single request only, without threads.
|
* Run the exchange to serve a single request only, without threads.
|
||||||
*
|
*
|
||||||
* @param fh listen socket
|
|
||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
run_single_request (int fh)
|
run_single_request ()
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
pid_t cld;
|
pid_t cld;
|
||||||
@ -786,10 +781,9 @@ run_single_request (int fh)
|
|||||||
= MHD_start_daemon (MHD_USE_PIPE_FOR_SHUTDOWN
|
= MHD_start_daemon (MHD_USE_PIPE_FOR_SHUTDOWN
|
||||||
| MHD_USE_DEBUG | MHD_USE_DUAL_STACK
|
| MHD_USE_DEBUG | MHD_USE_DUAL_STACK
|
||||||
| MHD_USE_TCP_FASTOPEN,
|
| MHD_USE_TCP_FASTOPEN,
|
||||||
(-1 == fh) ? serve_port : 0,
|
0, /* pick free port */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&handle_mhd_request, NULL,
|
&handle_mhd_request, NULL,
|
||||||
MHD_OPTION_LISTEN_SOCKET, fh,
|
|
||||||
MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 10,
|
MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 10,
|
||||||
MHD_OPTION_EXTERNAL_LOGGER, &TALER_MHD_handle_logs,
|
MHD_OPTION_EXTERNAL_LOGGER, &TALER_MHD_handle_logs,
|
||||||
NULL,
|
NULL,
|
||||||
@ -804,6 +798,8 @@ run_single_request (int fh)
|
|||||||
"Failed to start HTTP server.\n");
|
"Failed to start HTTP server.\n");
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
serve_port = MHD_get_daemon_info (mhd,
|
||||||
|
MHD_DAEMON_INFO_BIND_PORT)->port;
|
||||||
cld = run_fake_client ();
|
cld = run_fake_client ();
|
||||||
if (-1 == cld)
|
if (-1 == cld)
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -1100,7 +1096,11 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
#if HAVE_DEVELOPER
|
#if HAVE_DEVELOPER
|
||||||
if (NULL != input_filename)
|
if (NULL != input_filename)
|
||||||
ret = run_single_request (fh);
|
{
|
||||||
|
if (-1 != fh)
|
||||||
|
close (fh);
|
||||||
|
ret = run_single_request ();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
ret = run_main_loop (fh,
|
ret = run_main_loop (fh,
|
||||||
|
Loading…
Reference in New Issue
Block a user