Also listen on IPv6
This commit is contained in:
parent
0e71bbf605
commit
8336b7ef9d
22
main.c
22
main.c
|
@ -357,7 +357,7 @@ void print_addresses(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
struct MHD_Daemon *d;
|
struct MHD_Daemon *d, *d6;
|
||||||
struct stat sBuf;
|
struct stat sBuf;
|
||||||
|
|
||||||
int port;
|
int port;
|
||||||
|
@ -457,7 +457,24 @@ int main(int argc, char ** argv) {
|
||||||
&request_completed, NULL,
|
&request_completed, NULL,
|
||||||
MHD_OPTION_END);
|
MHD_OPTION_END);
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
LOG(LVL_FATAL, "Cannot start up libmicrohttpd.");
|
LOG(LVL_ERR, "Cannot start up libmicrohttpd listening on IPv4.");
|
||||||
|
}
|
||||||
|
|
||||||
|
d6 = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_IPv6,
|
||||||
|
port,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&connection_handler,
|
||||||
|
NULL,
|
||||||
|
MHD_OPTION_NOTIFY_COMPLETED,
|
||||||
|
&request_completed, NULL,
|
||||||
|
MHD_OPTION_END);
|
||||||
|
if (d6 == NULL) {
|
||||||
|
LOG(LVL_ERR, "Cannot start up libmicrohttpd listening on IPv6.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(d == NULL && d6 == NULL) {
|
||||||
|
LOG(LVL_FATAL, "Both IPv4 and IPv6 servers failed to start. Terminating.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,6 +488,7 @@ int main(int argc, char ** argv) {
|
||||||
LOG(LVL_INFO, "Shutting down...");
|
LOG(LVL_INFO, "Shutting down...");
|
||||||
|
|
||||||
MHD_stop_daemon(d);
|
MHD_stop_daemon(d);
|
||||||
|
MHD_stop_daemon(d6);
|
||||||
|
|
||||||
MHD_destroy_response(error403Response);
|
MHD_destroy_response(error403Response);
|
||||||
MHD_destroy_response(error404Response);
|
MHD_destroy_response(error404Response);
|
||||||
|
|
Loading…
Reference in a new issue