From 432fd81d406a569dfa0411be6e8911f18fd2a3ca Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Sun, 10 Jun 2018 21:08:21 -0400 Subject: [PATCH] Websocket stdio / websocketd experiment Signed-off-by: Bill Erickson --- src/websocket-stdio/osrf-websocket-stdio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/websocket-stdio/osrf-websocket-stdio.c b/src/websocket-stdio/osrf-websocket-stdio.c index 6427ef6..f32e28c 100644 --- a/src/websocket-stdio/osrf-websocket-stdio.c +++ b/src/websocket-stdio/osrf-websocket-stdio.c @@ -238,6 +238,7 @@ static void relay_stdin_message(const char* msg_string) { const char *service = NULL; const char *thread = NULL; const char *log_xid = NULL; + char *tmp_recip = NULL; char *msg_body = NULL; char *recipient = NULL; @@ -310,14 +311,19 @@ static void relay_stdin_message(const char* msg_string) { "WS relaying message to opensrf thread=%s, recipient=%s", thread, recipient); - msg_body = extract_inbound_messages( - service, thread, recipient, osrf_msg); + // 'recipient' will be freed in extract_inbound_messages + // during a DISCONNECT call. Retain a local copy. + tmp_recip = strdup(recipient); + + msg_body = extract_inbound_messages(service, thread, recipient, osrf_msg); osrfLogInternal(OSRF_LOG_MARK, "WS relaying inbound message: %s", msg_body); transport_message *tmsg = message_init( - msg_body, NULL, thread, recipient, NULL); + msg_body, NULL, thread, tmp_recip, NULL); + + free(tmp_recip); message_set_osrf_xid(tmsg, osrfLogGetXid()); -- 2.11.0