Skip to content

Instantly share code, notes, and snippets.

@lminiero
Created April 24, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lminiero/5bd6795f2534b9c523c90603ec23816a to your computer and use it in GitHub Desktop.
Save lminiero/5bd6795f2534b9c523c90603ec23816a to your computer and use it in GitHub Desktop.
Example of a broken MHD daemon on 0.9.53 (fc25)
#include <stdio.h>
#include <stdlib.h>
#include <microhttpd.h>
/* Placeholders: these methods do nothing */
static int janus_http_client_connect(void *cls, const struct sockaddr *addr, socklen_t addrlen) {
return MHD_YES;
}
static int janus_http_handler(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr) {
return MHD_NO;
}
static void janus_http_request_completed(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe) {
return;
}
int main(int argc, char *argv[]) {
int port = 8088;
char *path = "/janus";
/* Create the daemon */
struct MHD_Daemon *daemon = MHD_start_daemon(
MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL | MHD_USE_DUAL_STACK,
port,
janus_http_client_connect,
NULL,
&janus_http_handler,
path,
MHD_OPTION_NOTIFY_COMPLETED, &janus_http_request_completed, NULL,
MHD_OPTION_END);
if(daemon == NULL) {
printf("Daemon error!\n");
exit(1);
}
printf("Bye!\n");
MHD_stop_daemon(daemon);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment