Provide a thread if the translator wasn't passed one in the request headers
authordbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 28 Jan 2010 03:14:32 +0000 (03:14 +0000)
committerdbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 28 Jan 2010 03:14:32 +0000 (03:14 +0000)
The OpenSRF-over-HTTP spec says that the translator will generate a thread
in the response if one wasn't passed in the request; however, we were trying
to pass a null pointer back and that doesn't work so well.

As we're already generating a reasonably unique string for the purposes
of delim in the multipart data response, let's also use that for the
response thread when necessary.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1906 9efc2488-bf62-4759-914b-345cdb29e865

src/gateway/osrf_http_translator.c

index df2d273..b1eb619 100644 (file)
@@ -127,7 +127,6 @@ static osrfHttpTranslator* osrfNewHttpTranslator(request_rec* apreq) {
     trans->handle = osrfSystemGetTransportClient();
     trans->recipient = apr_table_get(apreq->headers_in, OSRF_HTTP_HEADER_TO);
     trans->service = apr_table_get(apreq->headers_in, OSRF_HTTP_HEADER_SERVICE);
-    trans->thread = apr_table_get(apreq->headers_in, OSRF_HTTP_HEADER_THREAD); /* XXX create thread if necessary */
 
     const char* timeout = apr_table_get(apreq->headers_in, OSRF_HTTP_HEADER_TIMEOUT);
     if(timeout) 
@@ -145,6 +144,11 @@ static osrfHttpTranslator* osrfNewHttpTranslator(request_rec* apreq) {
     snprintf(buf, sizeof(buf), "%d%ld", getpid(), time(NULL));
     trans->delim = md5sum(buf);
 
+    /* Use thread if it has been passed in; otherwise, just use the delimiter */
+    trans->thread = apr_table_get(apreq->headers_in, OSRF_HTTP_HEADER_THREAD)
+        ?  apr_table_get(apreq->headers_in, OSRF_HTTP_HEADER_THREAD)
+        : (const char*)trans->delim;
+
     return trans;
 }