From: Adam Dickmeiss Date: Thu, 8 Mar 2012 16:28:14 +0000 (+0100) Subject: Protect the two Usemarcon handles X-Git-Tag: v1.3.26~11 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=99277f256bd542a4bc259d0e8c88b2b7c1c256ad;p=metaproxy-moved-to-github.git Protect the two Usemarcon handles Multiple threads may use these. Allow only one at a time. --- diff --git a/src/filter_record_transform.cpp b/src/filter_record_transform.cpp index f6ddac0..5241d6e 100644 --- a/src/filter_record_transform.cpp +++ b/src/filter_record_transform.cpp @@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include + #if HAVE_USEMARCON #include #include @@ -53,6 +55,8 @@ namespace metaproxy_1 { #if HAVE_USEMARCON struct info_usemarcon { + boost::mutex m_mutex; + char *stage1; char *stage2; @@ -64,6 +68,8 @@ static int convert_usemarcon(void *info, WRBUF record, WRBUF wr_error) { struct info_usemarcon *p = (struct info_usemarcon *) info; + boost::mutex::scoped_lock lock(p->m_mutex); + if (p->usemarcon1) { char *converted; @@ -108,7 +114,7 @@ static void destroy_usemarcon(void *info) delete p->usemarcon2; xfree(p->stage1); xfree(p->stage2); - xfree(p); + delete p; } static void *construct_usemarcon(const xmlNode *ptr, const char *path, @@ -118,7 +124,7 @@ static void *construct_usemarcon(const xmlNode *ptr, const char *path, if (strcmp((const char *) ptr->name, "usemarcon")) return 0; - struct info_usemarcon *p = (struct info_usemarcon *) xmalloc(sizeof(*p)); + struct info_usemarcon *p = new(struct info_usemarcon); p->stage1 = 0; p->stage2 = 0; p->usemarcon1 = 0;