summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrwastl <mrwastl@users.sourceforge.net>2011-09-21 00:32:07 +0200
committermrwastl <mrwastl@users.sourceforge.net>2011-09-21 00:32:07 +0200
commit72fa990816f5feadb561f75b78dd4324153dc8c0 (patch)
treed75abb5d2f6f063a1587123bdc6a7035737df090
parent36315d4f3ed507bcc613eb92155d561b78e81af6 (diff)
downloadgraphlcd-base-72fa990816f5feadb561f75b78dd4324153dc8c0.tar.gz
graphlcd-base-72fa990816f5feadb561f75b78dd4324153dc8c0.tar.bz2
temporary workaround for thread-safe skin parsing
-rw-r--r--glcdskin/parser.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/glcdskin/parser.c b/glcdskin/parser.c
index 8ae0e43..8445449 100644
--- a/glcdskin/parser.c
+++ b/glcdskin/parser.c
@@ -22,6 +22,9 @@
#include "xml.h"
#include "skin.h"
+/* workaround for thread-safe parsing */
+#include <pthread.h>
+
namespace GLCD
{
@@ -502,11 +505,28 @@ bool EndElem(const std::string & name)
return true;
}
+static pthread_mutex_t parse_mutex; // temp. workaround of thread-safe parsing problem
+
cSkin * XmlParse(cSkinConfig & Config, const std::string & Name, const std::string & fileName, std::string & errorString)
{
+ pthread_mutex_lock(&parse_mutex); // temp. workaround
+ //fprintf(stderr, ">>>>> XmlParse, Config: %s, Name: %s\n", Config.GetDriver()->ConfigName().c_str(), Name.c_str());
skin = new cSkin(Config, Name);
context.clear();
+ { // temp. workaround for thread-safe parsing
+ font = NULL;
+ variable = NULL;
+ variable_default = NULL;
+ display = NULL;
+ parents.clear();
+ object = NULL;
+ oindex = 0;
+ errorDetail = "";
+ condblock_cond = "";
+ includeDepth = 0;
+ subErrorDetail = "";
+ }
cXML xml(fileName, skin->Config().CharSet());
xml.SetNodeStartCB(StartElem);
xml.SetNodeEndCB(EndElem);
@@ -526,12 +546,16 @@ cSkin * XmlParse(cSkinConfig & Config, const std::string & Name, const std::stri
display = NULL;
delete object;
object = NULL;
+ //fprintf(stderr, "<<<<< XmlParse ERROR, Config: %s, Name: %s\n", Config.GetDriver()->ConfigName().c_str(), Name.c_str());
+ pthread_mutex_unlock(&parse_mutex);
return NULL;
}
cSkin * result = skin;
skin = NULL;
errorString = "";
+ //fprintf(stderr, "<<<<< XmlParse, Config: %s, Name: %s\n", Config.GetDriver()->ConfigName().c_str(), Name.c_str());
+ pthread_mutex_unlock(&parse_mutex);
return result;
}