summaryrefslogtreecommitdiffhomepage
path: root/auto/modules
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2019-12-09 18:17:16 +0300
committerMax Romanov <max.romanov@nginx.com>2019-12-09 18:17:16 +0300
commit55a368e5058451b99600b983f6cb98402fcd57cc (patch)
tree5ee441a638131648868058f8ce195c4da31f18ec /auto/modules
parentc2a7e403ef1ed51ef72af536a2915e33a0a5ab19 (diff)
downloadunit-55a368e5058451b99600b983f6cb98402fcd57cc.tar.gz
unit-55a368e5058451b99600b983f6cb98402fcd57cc.tar.bz2
Java: fixing racing condition in external JAR download.
Temporary file name with configure process PID used to download JAR from external repository. Then file renamed using command 'mv'. The issue reproduced in clean environment when 2 or more concurrent builds started.
Diffstat (limited to 'auto/modules')
-rw-r--r--auto/modules/java_get_jar9
1 files changed, 6 insertions, 3 deletions
diff --git a/auto/modules/java_get_jar b/auto/modules/java_get_jar
index c61d0a53..52cd146f 100644
--- a/auto/modules/java_get_jar
+++ b/auto/modules/java_get_jar
@@ -8,7 +8,9 @@
# NXT_JAR_LOCAL_REPO=$HOME/.m2/repository/
NXT_JAR_FILE=${NXT_JAR_NAME}-${NXT_JAR_VERSION}.jar
-NXT_JAR_LOCAL="${NXT_JAR_LOCAL_REPO}${NXT_JAR_NAMESPACE}${NXT_JAR_NAME}/${NXT_JAR_VERSION}/${NXT_JAR_FILE}"
+NXT_JAR_LOCAL_DIR="${NXT_JAR_LOCAL_REPO}${NXT_JAR_NAMESPACE}${NXT_JAR_NAME}/${NXT_JAR_VERSION}"
+NXT_JAR_LOCAL="${NXT_JAR_LOCAL_DIR}/${NXT_JAR_FILE}"
+NXT_JAR_LOCAL_TMP="${NXT_JAR_LOCAL_DIR}/.${NXT_JAR_FILE}.$$"
NXT_JAR_URL=${NXT_JAR_REPO}${NXT_JAR_NAMESPACE}${NXT_JAR_NAME}/${NXT_JAR_VERSION}/${NXT_JAR_FILE}
if [ ! -f "$NXT_BUILD_DIR/$NXT_JAR_FILE" ]; then
@@ -16,8 +18,9 @@ if [ ! -f "$NXT_BUILD_DIR/$NXT_JAR_FILE" ]; then
$echo "getting remote $NXT_JAR_FILE ... "
$echo "getting remote $NXT_JAR_FILE ..." >> $NXT_AUTOCONF_ERR
- mkdir -p "${NXT_JAR_LOCAL_REPO}${NXT_JAR_NAMESPACE}${NXT_JAR_NAME}/${NXT_JAR_VERSION}/"
- curl --progress-bar "$NXT_JAR_URL" -o "$NXT_JAR_LOCAL"
+ mkdir -p "${NXT_JAR_LOCAL_DIR}"
+ curl --progress-bar "$NXT_JAR_URL" -o "$NXT_JAR_LOCAL_TMP"
+ mv "$NXT_JAR_LOCAL_TMP" "$NXT_JAR_LOCAL"
else
$echo "getting local $NXT_JAR_FILE"
$echo "getting local $NXT_JAR_FILE ..." >> $NXT_AUTOCONF_ERR