From 9038832adafeb6d209f406c2589c0f9e6924924b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Sun, 10 Jun 2018 18:32:19 -0400 Subject: [PATCH] Websocket stdio / websocketd experiment Signed-off-by: Bill Erickson --- src/websocket-stdio/osrf-websocket-stdio.c | 38 ++---------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/src/websocket-stdio/osrf-websocket-stdio.c b/src/websocket-stdio/osrf-websocket-stdio.c index c02e6ff..6233e1b 100644 --- a/src/websocket-stdio/osrf-websocket-stdio.c +++ b/src/websocket-stdio/osrf-websocket-stdio.c @@ -45,31 +45,7 @@ static char* config_ctxt = "gateway"; static char* osrf_router = NULL; static char* osrf_domain = NULL; static osrfHash* stateful_session_cache = NULL; -static char* client_ip; - -static time_t idle_timeout_interval = 120; -static time_t idle_check_interval = 5; -static time_t last_activity_time = 0; - -// Generally, we do not disconnect the client (as idle) if there is a -// request in flight. However, we need to have an upper bound on the -// amount of time we will wait for in-flight requests to complete to -// avoid leaving an effectively idle connection open after a request -// died on the backend and no response was received. -// Note that if other activity occurs while a long-running request -// is active, the wait time will get reset with each new activity. -// This is OK, though, because the goal of max_request_wait_time -// is not to chop requests off at the knees, it's to allow the client -// to timeout as idle when only a single long-running request is active -// and preventing timeout. -static time_t max_request_wait_time = 600; - -// Incremented with every REQUEST, decremented with every COMPLETE. -// Gives us a rough picture of the number of reqests we've sent to -// the server vs. the number for which a completed response has been -// received. -static int requests_in_flight = 0; - +static char* client_ip = NULL; static growing_buffer* stdin_buf = NULL; static transport_client* osrf_handle = NULL; static char recipient_buf[RECIP_BUF_SIZE]; // reusable recipient buffer @@ -141,12 +117,10 @@ int main() { } if (FD_ISSET(stdin_no, &fds)) { - osrfLogDebug(OSRF_LOG_MARK, "STDIN active"); read_from_stdin(); } if (FD_ISSET(osrf_no, &fds)) { - osrfLogDebug(OSRF_LOG_MARK, "XMPP active"); read_from_osrf(); } } @@ -180,8 +154,6 @@ static void child_init() { client_ip = getenv("REMOTE_ADDR"); osrfLogInfo(OSRF_LOG_MARK, "WS connect from %s", client_ip); - - // TODO read timeout ENV vars } @@ -332,8 +304,6 @@ static void relay_stdin_message(const char* msg_string) { message_free(tmsg); jsonObjectFree(msg_wrapper); free(msg_body); - - last_activity_time = time(NULL); } static char* extract_inbound_messages( @@ -398,7 +368,6 @@ static char* extract_inbound_messages( } osrfLogActivity(OSRF_LOG_MARK, "%s", act->buf); buffer_free(act); - requests_in_flight++; break; } @@ -491,6 +460,7 @@ static void read_one_osrf_message(transport_message* tmsg) { osrfHashSet(stateful_session_cache, sender, tmsg->thread); } else { + osrfLogWarning(OSRF_LOG_MARK, "WS max concurrent sessions (%d) reached. " "Current session will not be tracked", @@ -508,10 +478,6 @@ static void read_one_osrf_message(transport_message* tmsg) { if (recipToFree != NULL) { free(recipToFree); } - - } else { - if (one_msg->status_code == OSRF_STATUS_COMPLETE) - requests_in_flight--; } } } -- 2.11.0