LP#1268619: websockets; free temporary osrf msgs; minor comment change
authorBill Erickson <berick@esilibrary.com>
Mon, 21 Jan 2013 16:34:57 +0000 (11:34 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 19 Aug 2014 22:50:47 +0000 (15:50 -0700)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
src/gateway/osrf_websocket_translator.c

index 6bf8066..dc8653e 100644 (file)
@@ -26,7 +26,7 @@
  *   "service"  : "opensrf.foo", // required
  *   "thread"   : "123454321",   // AKA thread. required for follow-up requests; max 64 chars.
  *   "log_xid"  : "123..32",     // optional log trace ID, max 64 chars;
  *   "service"  : "opensrf.foo", // required
  *   "thread"   : "123454321",   // AKA thread. required for follow-up requests; max 64 chars.
  *   "log_xid"  : "123..32",     // optional log trace ID, max 64 chars;
- *   "osrf_msg" : {<osrf_msg>}   // required
+ *   "osrf_msg" : [<osrf_msg>, <osrf_msg>, ...]   // required
  * }
  *
  * Each translator operates with two threads.  One thread receives messages
  * }
  *
  * Each translator operates with two threads.  One thread receives messages
@@ -214,6 +214,7 @@ void* osrf_responder_thread_main_body(transport_message *tmsg) {
     }
 
     // maintenance is done
     }
 
     // maintenance is done
+    msg_list->freeItem = osrfMessageFree;
     osrfListFree(msg_list);
 
     if (!trans->client_connected) {
     osrfListFree(msg_list);
 
     if (!trans->client_connected) {
@@ -478,9 +479,17 @@ static char* extract_inbound_messages(
                 clear_cached_recipient(thread);
                 break;
         }
                 clear_cached_recipient(thread);
                 break;
         }
+
+        osrfMessageFree(msg);
     }
 
     }
 
-    return osrfMessageSerializeBatch(msg_list, num_msgs);
+    char* finalMsg = osrfMessageSerializeBatch(msg_list, num_msgs);
+
+    // clean up our messages
+    for(i = 0; i < num_msgs; i++) 
+        osrfMessageFree(msg_list[i]);
+
+    return finalMsg;
 }
 
 /**
 }
 
 /**