diff --git a/src/gateway.c b/src/gateway.c index 35cd048d8..17cb15d0d 100644 --- a/src/gateway.c +++ b/src/gateway.c @@ -477,6 +477,9 @@ http_redir_loop(s_config *config) if (!request_ctx) termination_handler(0); wd_signals_init(base); + + setbuf(stdout, NULL); + setbuf(stderr, NULL); evhttp_set_cb(http, "/wifidog", ev_http_callback_wifidog, NULL); //evhttp_set_cb(http, "/wifidog/status", ev_http_callback_status, NULL); @@ -489,6 +492,9 @@ http_redir_loop(s_config *config) evhttp_bind_socket_with_handle(http, config->gw_address, config->gw_port); event_base_dispatch(base); + + evhttp_free(http); + event_base_free(base); } /**@internal diff --git a/src/http.c b/src/http.c index 50c61ed77..a02dd1d3f 100644 --- a/src/http.c +++ b/src/http.c @@ -155,7 +155,7 @@ process_apple_wisper(struct evhttp_request *req, const char *mac, const char *re * * @param req The http request * @param type 1: internet not online - * other: auth server ont online + * other: auth server offline */ void ev_http_reply_client_error(struct evhttp_request *req, enum reply_client_error_type type) @@ -239,11 +239,13 @@ void ev_http_callback_404(struct evhttp_request *req, void *arg) { if (!is_online()) { + debug(LOG_INFO, "Internet is offline"); ev_http_reply_client_error(req, INTERNET_OFFLINE); return; } if (!is_auth_online()) { + debug(LOG_INFO, "Auth server is offline"); ev_http_reply_client_error(req, AUTHSERVER_OFFLINE); return; } diff --git a/src/ping_thread.c b/src/ping_thread.c index f2cf96f96..2ba8ef5eb 100644 --- a/src/ping_thread.c +++ b/src/ping_thread.c @@ -72,8 +72,11 @@ ping_work_cb(evutil_socket_t fd, short event, void *arg) { struct sys_info info; memset(&info, 0, sizeof(info)); - if (wd_make_request(request_ctx, &evcon, &req, process_ping_response)) return; - + if (wd_make_request(request_ctx, &evcon, &req, process_ping_response)) { + debug(LOG_ERR, "Failed to make request to auth server"); + return; + } + get_sys_info(&info); char *uri = get_ping_uri(&info); if (!uri) return; // impossibe @@ -285,7 +288,8 @@ process_ping_response(struct evhttp_request *req, void *ctx) } } else if (strstr(buffer, "Pong") == 0) { mark_auth_offline(); - debug(LOG_WARNING, "Auth server did NOT say Pong!"); + debug(LOG_WARNING, "Auth server did NOT say Pong! the response [%s], error: %s", + buffer, strerror(errno)); if (!authdown) { fw_set_authdown(); authdown = 1; diff --git a/src/wd_client.c b/src/wd_client.c index 4ac77e023..ec91f5592 100644 --- a/src/wd_client.c +++ b/src/wd_client.c @@ -213,7 +213,8 @@ wd_make_request(struct wd_request_context *request_ctx, struct bufferevent *bev = request_ctx->bev; struct event_base *base = request_ctx->base; t_auth_serv *auth_server = get_auth_server(); - + + debug(LOG_DEBUG, "auth_server->authserv_use_ssl: %d", auth_server->authserv_use_ssl); if (!auth_server->authserv_use_ssl) { *evcon = evhttp_connection_base_bufferevent_new(base, NULL, bev, auth_server->authserv_hostname, auth_server->authserv_http_port);