From e9ec65cfde58dcde4bc0c426f4bc4c588bdf8800 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Sun, 30 Sep 2018 06:27:58 +0300 Subject: [PATCH] report about stream clients --- src/http.c | 20 ++++++++++++++++++++ src/http.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/http.c b/src/http.c index 050766e..3a9d18e 100644 --- a/src/http.c +++ b/src/http.c @@ -219,6 +219,8 @@ static void _http_callback_stream(struct evhttp_request *request, void *v_server struct evhttp_connection *conn; struct bufferevent *buf_event; struct stream_client_t *client; + char *client_addr; + unsigned short client_port; PROCESS_HEAD_REQUEST; @@ -239,6 +241,13 @@ static void _http_callback_stream(struct evhttp_request *request, void *v_server client->prev = last; last->next = client; } + ++server->run->stream_clients_count; + + evhttp_connection_get_peer(conn, &client_addr, &client_port); + LOG_INFO( + "HTTP: Registered the new stream client: [%s]:%u; clients now: %u", + client_addr, client_port, server->run->stream_clients_count + ); buf_event = evhttp_connection_get_bufferevent(conn); bufferevent_setcb(buf_event, NULL, NULL, _http_callback_stream_error, (void *)client); @@ -301,8 +310,19 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c static void _http_callback_stream_error(UNUSED struct bufferevent *buf_event, UNUSED short what, void *v_client) { struct stream_client_t *client = (struct stream_client_t *)v_client; struct evhttp_connection *conn; + char *client_addr = "???"; + unsigned short client_port = 0; + + --client->server->run->stream_clients_count; conn = evhttp_request_get_connection(client->request); + if (conn != NULL) { + evhttp_connection_get_peer(conn, &client_addr, &client_port); + } + LOG_INFO( + "HTTP: Disconnected the stream client: [%s]:%u; clients now: %u", + client_addr, client_port, client->server->run->stream_clients_count + ); if (conn != NULL) { evhttp_connection_free(conn); } diff --git a/src/http.h b/src/http.h index e093856..75faf4c 100644 --- a/src/http.h +++ b/src/http.h @@ -54,6 +54,7 @@ struct http_server_runtime_t { struct stream_t *stream; struct exposed_t *exposed; struct stream_client_t *stream_clients; + unsigned stream_clients_count; unsigned drop_same_frames_blank; };