From df919a9691b008f8728ad4e2400c53aec0567c59 Mon Sep 17 00:00:00 2001
From: Karl Heyes <karl@xiph.org>
Date: Tue, 11 Jan 2005 16:36:34 +0000
Subject: [PATCH] only unlock when we have finished with the stylesheet,
 potential race otherwise

svn path=/icecast/trunk/icecast/; revision=8723
---
 src/xslt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/xslt.c b/src/xslt.c
index a3a97f1d..866a0004 100644
--- a/src/xslt.c
+++ b/src/xslt.c
@@ -161,9 +161,9 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
 
     thread_mutex_lock(&xsltlock);
     cur = xslt_get_stylesheet(xslfilename);
-    thread_mutex_unlock(&xsltlock);
 
     if (cur == NULL) {
+        thread_mutex_unlock(&xsltlock);
         bytes = sock_write_string(client->con->sock, 
                 (char *)"Could not parse XSLT file");
         if(bytes > 0) client->con->sent_bytes += bytes;
@@ -176,6 +176,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
     outputBuffer = xmlAllocOutputBuffer(NULL);
 
     count = xsltSaveResultTo(outputBuffer, res, cur);
+    thread_mutex_unlock(&xsltlock);
 
     /*  Add null byte to end. */
     bytes = xmlOutputBufferWrite(outputBuffer, 1, "");