Re: [xslt] xsltproc error during parallel docbook building
- From: Alexander Shigin <shigin rambler-co ru>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] xsltproc error during parallel docbook building
- Date: Tue, 08 Dec 2009 14:40:10 +0300
В Пнд, 07/12/2009 в 18:56 -0800, C Y пишет:
> Hi! BRL-CAD is attempting to use xsltproc to build our docbook
> documentation, and we're getting an intermittent error when doing
> parallel building (e.g. firing off a lot of xsltproc commands at
> once):
>
> xsltApplyStylesheet: saving to lessons/en/mged11_refining_mug.html may
> not be possible
>
> it's not specific to that one file and appears to occur randomly when
> a lot of xsltproc instances are running. Restarting the make process
> usually immediately succeeds. Is this a known limitation of xsltproc?
Can you specify the full command line? But it seems there is race
condition in xsltCheckWritePath: the two processes can try to make the
directory at the same time.
The attached patch can solve the problem, but may cause some security
risk.
diff --git a/libxslt/security.c b/libxslt/security.c
index b766cf7..76033aa 100644
--- a/libxslt/security.c
+++ b/libxslt/security.c
@@ -10,6 +10,7 @@
#include "libxslt.h"
#include <string.h>
+#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -342,8 +343,19 @@ xsltCheckWritePath(xsltSecurityPrefsPtr sec,
}
}
ret = xsltCheckWritePath(sec, ctxt, directory);
- if (ret == 1)
+ if (ret == 1) {
ret = mkdir(directory, 0755);
+ /* The another process can create the same directory.
+ * I'm not sure it's a good check: it can be wise to check
+ * owner of the directory before continue */
+ if (ret == -1 && errno == EEXIST) {
+ struct stat buf;
+ ret = stat(path, &buf);
+ if (ret == 0) {
+ ret = S_ISDIR(buf.st_mode) ? 0 : -1;
+ }
+ }
+ }
}
xmlFree(directory);
if (ret < 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]