diff --git a/src/daemon/status-file.c b/src/daemon/status-file.c index 6cdca09517..a1b96a817f 100644 --- a/src/daemon/status-file.c +++ b/src/daemon/status-file.c @@ -715,25 +715,39 @@ struct log_priority PRI_KILLED_HARD = { NDLP_ERR, NDLP_WARNING }; static bool is_ci(void) { // List of known CI environment variables. const char *ci_vars[] = { - "CI", // Generic CI flag - "TRAVIS", // Travis CI - "GITHUB_ACTIONS", // GitHub Actions - "GITLAB_CI", // GitLab CI - "CIRCLECI", // CircleCI - "APPVEYOR", // AppVeyor + "CI", // Generic CI flag + "CONTINUOUS_INTEGRATION", // Alternate generic flag + "BUILD_NUMBER", // Jenkins, TeamCity + "RUN_ID", // AWS CodeBuild, some others + "TRAVIS", // Travis CI + "GITHUB_ACTIONS", // GitHub Actions + "GITHUB_TOKEN", // GitHub Actions + "GITLAB_CI", // GitLab CI + "CIRCLECI", // CircleCI + "APPVEYOR", // AppVeyor + "BITBUCKET_BUILD_NUMBER", // Bitbucket Pipelines + "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", // Azure DevOps + "TF_BUILD", // Azure DevOps (alternate) + "BAMBOO_BUILDKEY", // Bamboo CI + "GO_PIPELINE_NAME", // GoCD + "HUDSON_URL", // Hudson CI + "TEAMCITY_VERSION", // TeamCity + "CI_NAME", // Some environments (e.g., CodeShip) + "CI_WORKER", // AppVeyor (alternate) + "CI_SERVER", // Generic + "HEROKU_TEST_RUN_ID", // Heroku CI + "BUILDKITE", // Buildkite + "DRONE", // Drone CI + "SEMAPHORE", // Semaphore CI + "NETLIFY", // Netlify CI + "NOW_BUILDER", // Vercel (formerly Zeit Now) NULL }; // Iterate over the CI environment variable names. for (const char **env = ci_vars; *env; env++) { - const char *val = getenv(*env); - if (val && *val && - (strcasecmp(val, "true") == 0 || - strcasecmp(val, "yes") == 0 || - strcasecmp(val, "on") == 0 || - strcasecmp(val, "1") == 0)) { + if(getenv(*env)) return true; - } } return false; @@ -990,7 +1004,7 @@ void daemon_status_file_check_crash(void) { (!no_previous_status || daemon_status_file_saved) && // we have more than 2 restarts, or this is not a CI run - (last_session_status.restarts > 2 || !is_ci()) && + (last_session_status.restarts > 1 || !is_ci()) && // we have not reported this !dedup_already_posted(&session_status, daemon_status_file_hash(&last_session_status, msg, cause), false) diff --git a/src/libnetdata/os/disk_space.c b/src/libnetdata/os/disk_space.c index 765d7e41d7..8079ba8629 100644 --- a/src/libnetdata/os/disk_space.c +++ b/src/libnetdata/os/disk_space.c @@ -52,17 +52,12 @@ OS_SYSTEM_DISK_SPACE os_disk_space(const char *path) { OS_SYSTEM_DISK_SPACE os_disk_space(const char *path_utf8) { OS_SYSTEM_DISK_SPACE space = OS_SYSTEM_DISK_SPACE_EMPTY; - // Convert the UTF-8 path to a wide-character string. - int wlen = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path_utf8, -1, NULL, 0); - if (wlen == 0) { - // Conversion error; optionally, GetLastError() can provide more details. + ssize_t wpath_size = cygwin_conv_path(CCP_POSIX_TO_WIN_W, path_utf8, NULL, 0); + if(wpath_size < 0) return space; - } - wchar_t *wpath = (wchar_t *)mallocz(wlen * sizeof(wchar_t)); - - if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path_utf8, -1, wpath, wlen) == 0) { - // Conversion error. + wchar_t *wpath = mallocz(wpath_size); + if(cygwin_conv_path(CCP_POSIX_TO_WIN_W, path_utf8, wpath, wpath_size) != 0) { freez(wpath); return space; } diff --git a/src/libnetdata/os/file_lock.c b/src/libnetdata/os/file_lock.c index 9cd19b6be5..9b665d96c9 100644 --- a/src/libnetdata/os/file_lock.c +++ b/src/libnetdata/os/file_lock.c @@ -37,9 +37,6 @@ FILE_LOCK file_lock_get(const char *filename) { return FILE_LOCK_INVALID; wchar_t *wpath = mallocz(wpath_size); - if(!wpath) - return FILE_LOCK_INVALID; - if(cygwin_conv_path(CCP_POSIX_TO_WIN_W, filename, wpath, wpath_size) != 0) { freez(wpath); return FILE_LOCK_INVALID;