From 542fd81999909615f2e21668a378a7b4dd4d1f18 Mon Sep 17 00:00:00 2001 From: dbs Date: Thu, 28 Jan 2010 03:14:32 +0000 Subject: [PATCH] Provide a thread if the translator wasn't passed one in the request headers 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gateway/osrf_http_translator.c b/src/gateway/osrf_http_translator.c index df2d273..b1eb619 100644 --- a/src/gateway/osrf_http_translator.c +++ b/src/gateway/osrf_http_translator.c @@ -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; } -- 2.43.2