From 131344777ae4cbc4ca47952b3a95f35b11713f23 Mon Sep 17 00:00:00 2001 From: Aaron Gresch Date: Tue, 23 Oct 2018 08:57:52 -0500 Subject: [PATCH 1/2] STORM-3272 allow worker-launcher to delete dead symlinks --- .../native/worker-launcher/impl/worker-launcher.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/storm-core/src/native/worker-launcher/impl/worker-launcher.c b/storm-core/src/native/worker-launcher/impl/worker-launcher.c index 02c0bec3795..d08531580f4 100644 --- a/storm-core/src/native/worker-launcher/impl/worker-launcher.c +++ b/storm-core/src/native/worker-launcher/impl/worker-launcher.c @@ -593,14 +593,17 @@ int recursive_delete(const char *path, int supervisor_owns_dir) { return UNABLE_TO_BUILD_PATH; } + struct stat file_stat; + if(access(path, F_OK) != 0) { if(errno == ENOENT) { - return 0; - } - // Can probably return here, but we'll try to lstat anyway. - } + // we need to handle symlinks that target missing files. + if((lstat(path, &file_stat) != 0) || ((file_stat.st_mode & S_IFMT) != S_IFLNK)) { + return 0; + } + } + } - struct stat file_stat; if(lstat(path, &file_stat) != 0) { fprintf(LOGFILE, "Failed to delete %s: %s", path, strerror(errno)); return UNABLE_TO_STAT_FILE; From 3fe0021379c1b491bc45bd5cc8efbc91cedd8536 Mon Sep 17 00:00:00 2001 From: Aaron Gresch Date: Tue, 23 Oct 2018 09:59:35 -0500 Subject: [PATCH 2/2] STORM-3272 log stat failure --- .../src/native/worker-launcher/impl/worker-launcher.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storm-core/src/native/worker-launcher/impl/worker-launcher.c b/storm-core/src/native/worker-launcher/impl/worker-launcher.c index d08531580f4..5155ed8f73b 100644 --- a/storm-core/src/native/worker-launcher/impl/worker-launcher.c +++ b/storm-core/src/native/worker-launcher/impl/worker-launcher.c @@ -597,8 +597,12 @@ int recursive_delete(const char *path, int supervisor_owns_dir) { if(access(path, F_OK) != 0) { if(errno == ENOENT) { + if(lstat(path, &file_stat) != 0) { + fprintf(LOGFILE, "Failed to stat %s: %s", path, strerror(errno)); + return 0; + } // we need to handle symlinks that target missing files. - if((lstat(path, &file_stat) != 0) || ((file_stat.st_mode & S_IFMT) != S_IFLNK)) { + if((file_stat.st_mode & S_IFMT) != S_IFLNK) { return 0; } }