Commit 0e640ae8 authored by Daniel O'Connell's avatar Daniel O'Connell

Made setopt() wrapper around mg_set_option()

parent 1bff6df2
......@@ -94,6 +94,13 @@ static void show_usage_and_exit(const char *prog) {
exit(EXIT_FAILURE);
}
static void setopt(struct mg_server *s, const char *opt, const char *val) {
const char *err_msg = mg_set_option(s, opt, val);
if (err_msg != NULL) {
elog(1, "Error setting [%s]: [%s]", opt, err_msg);
}
}
int main(int argc, char *argv[]) {
int i;
......@@ -117,17 +124,18 @@ int main(int argc, char *argv[]) {
// Create, configure and start proxy server in a separate thread
s_proxy_server = mg_create_server(NULL, &sse_handler);
mg_set_option(s_proxy_server, "listening_port", s_proxy_port);
mg_set_option(s_proxy_server, "ssl_certificate", s_cert);
mg_set_option(s_proxy_server, "ssl_ca_certificate", s_ca_cert);
setopt(s_proxy_server, "listening_port", s_proxy_port);
setopt(s_proxy_server, "ssl_certificate", s_cert);
setopt(s_proxy_server, "ssl_ca_certificate", s_ca_cert);
setopt(s_proxy_server, "hexdump_file", "/dev/stdout");
mg_start_thread(serve_thread_func, s_proxy_server);
// Create, configure and start SSE server and SSE pusher threads
// Start two SSE pushing threads
// Serve SSE server in the main thread
s_sse_server = mg_create_server(NULL, &sse_handler);
mg_set_option(s_sse_server, "listening_port", s_sse_port);
mg_set_option(s_sse_server, "document_root", ".");
setopt(s_sse_server, "listening_port", s_sse_port);
setopt(s_sse_server, "document_root", ".");
mg_start_thread(sse_pusher_thread_func, (void *) "sse_pusher_thread_1");
mg_start_thread(sse_pusher_thread_func, (void *) "sse_pusher_thread_2");
serve_thread_func(s_sse_server);
......@@ -137,4 +145,4 @@ int main(int argc, char *argv[]) {
mg_destroy_server(&s_proxy_server);
return EXIT_SUCCESS;
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment