[OpenSRF-GIT] OpenSRF branch master updated. 4163499191dfb511ba8646ae1c4748d88996558e

Evergreen Git git at git.evergreen-ils.org
Thu Feb 1 15:53:09 EST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".

The branch, master has been updated
       via  4163499191dfb511ba8646ae1c4748d88996558e (commit)
       via  50a6bcad0b6d94e8edd15ee460b84466bc55c941 (commit)
      from  a90a1d9a99e510423b9fdc43afcb128ace79a24a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4163499191dfb511ba8646ae1c4748d88996558e
Author: Bill Erickson <berickxx at gmail.com>
Date:   Wed Jan 24 15:16:14 2018 -0500

    LP#1744158 Websocket proc exits on ejabberd disconnect
    
    Any errors relaying websocket messages to OpenSRF now result in the WS
    client being disconnected, allowing the WS process to exit.  This
    prevents the WS gateway from accepting requests it cannot process and
    allows the client to connect to a new WS process.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Jason Stephenson <jason at sigio.com>

diff --git a/src/gateway/osrf_websocket_translator.c b/src/gateway/osrf_websocket_translator.c
index f43fb62..2d3a5e1 100644
--- a/src/gateway/osrf_websocket_translator.c
+++ b/src/gateway/osrf_websocket_translator.c
@@ -911,8 +911,12 @@ static size_t on_message_handler_body(void *data,
         msg_body, NULL, thread, recipient, NULL);
 
     message_set_osrf_xid(tmsg, osrfLogGetXid());
-    client_send_message(osrf_handle, tmsg);
 
+    size_t stat = OK;
+    if (client_send_message(osrf_handle, tmsg) != 0) {
+        osrfLogError(OSRF_LOG_MARK, "WS failed sending data to OpenSRF");
+        stat = HTTP_INTERNAL_SERVER_ERROR;
+    }
 
     osrfLogClearXid();
     message_free(tmsg);                                                         
@@ -920,7 +924,7 @@ static size_t on_message_handler_body(void *data,
     free(msg_body);
 
     last_activity_time = time(NULL);
-    return OK;
+    return stat;
 }
 
 static size_t CALLBACK on_message_handler(void *data,
@@ -929,16 +933,25 @@ static size_t CALLBACK on_message_handler(void *data,
 
     if (apr_thread_mutex_lock(trans->mutex) != APR_SUCCESS) {
         osrfLogError(OSRF_LOG_MARK, "WS error locking thread mutex");
-        return 1; // TODO: map to apr_status_t value?
+        return 1;
     }
 
-    apr_status_t stat = on_message_handler_body(data, server, type, buffer, buffer_size);
+    size_t stat = on_message_handler_body(data, server, type, buffer, buffer_size);
 
     if (apr_thread_mutex_unlock(trans->mutex) != APR_SUCCESS) {
         osrfLogError(OSRF_LOG_MARK, "WS error locking thread mutex");
         return 1;
     }
 
+    if (stat != OK) {
+        // Returning a non-OK status alone won't force a disconnect.
+        // Once disconnected, the on_disconnect_handler() handler
+        // will run, clean it all up, and kill the process.
+        osrfLogError(OSRF_LOG_MARK,
+            "Error relaying message, forcing client disconnect");
+        trans->server->close(trans->server);
+    }
+
     return stat;
 }
 

commit 50a6bcad0b6d94e8edd15ee460b84466bc55c941
Author: Bill Erickson <berickxx at gmail.com>
Date:   Wed Jan 31 13:07:41 2018 -0500

    LP#1746577 Websocket responder exits on jabber disconnect
    
    Regularly check for Jabber socket disconnects in the websocket gateway
    "responder" thread (that relays messages from opensrf to the WS client)
    and force a client disconnect when a broken jabber socket is detected.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    Signed-off-by: Jason Stephenson <jason at sigio.com>

diff --git a/src/gateway/osrf_websocket_translator.c b/src/gateway/osrf_websocket_translator.c
index ef8d4af..f43fb62 100644
--- a/src/gateway/osrf_websocket_translator.c
+++ b/src/gateway/osrf_websocket_translator.c
@@ -344,10 +344,26 @@ void* APR_THREAD_FUNC osrf_responder_thread_main(apr_thread_t *thread, void *dat
             return NULL;
         }
 
-        // wait for a response
+        // wait indefinitely for a response
         tmsg = client_recv(osrf_handle, -1);
 
-        if (!tmsg) continue; // interrupt
+        if (!tmsg) {
+            // tmsg can only be NULL if the underlying select() call is
+            // interrupted or the jabber socket connection was severed.
+
+            if (client_connected(osrf_handle) &&
+                socket_connected(osrf_handle->session->sock_id)) {
+                continue; // interrupted.  restart loop.
+            }
+
+            // Socket connection was broken.  Send disconnect to client,
+            // causing on_disconnect_handler to run and cleanup.
+            osrfLogWarning(OSRF_LOG_MARK, 
+                "WS: Jabber socket disconnected. Sending close() to client");
+
+            trans->server->close(trans->server);
+            return NULL; // exit thread
+        }
 
         if (trans->client_connected) {
 

-----------------------------------------------------------------------

Summary of changes:
 src/gateway/osrf_websocket_translator.c |   41 ++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list