From f2d01375946373f4356e5b4812c7f215affc1758 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 16 Feb 2005 12:48:46 +0000 Subject: [PATCH] Make another attempt at fixing the ClientRunXXX return code bug on Win32 machines. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1831 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/ua_status.c | 21 +++++--- bacula/src/win32/compat/compat.cpp | 78 ++++++++++++++++-------------- 2 files changed, 54 insertions(+), 45 deletions(-) diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 4040e9af6e..0b204a064e 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -665,6 +665,19 @@ static void list_terminated_jobs(UAContext *ua) char JobName[MAX_NAME_LENGTH]; const char *termstat; + bstrncpy(JobName, je->Job, sizeof(JobName)); + /* There are three periods after the Job name */ + char *p; + for (int i=0; i<3; i++) { + if ((p=strrchr(JobName, '.')) != NULL) { + *p = 0; + } + } + + if (!acl_access_ok(ua, Job_ACL, JobName)) { + continue; + } + bstrftime_nc(dt, sizeof(dt), je->end_time); switch (je->JobType) { case JT_ADMIN: @@ -697,14 +710,6 @@ static void list_terminated_jobs(UAContext *ua) termstat = "Other"; break; } - bstrncpy(JobName, je->Job, sizeof(JobName)); - /* There are three periods after the Job name */ - char *p; - for (int i=0; i<3; i++) { - if ((p=strrchr(JobName, '.')) != NULL) { - *p = 0; - } - } bsendmsg(ua, _("%6d %-6s %8s %14s %-7s %-8s %s\n"), je->JobId, level, diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index 8bcfa7fdf7..5ba631a717 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -98,30 +98,30 @@ wchar_win32_path(const char *name, WCHAR *win32_name) } } -int -umask(int) +int umask(int) { - return 0; + return 0; } -int -chmod(const char *, mode_t) +int chmod(const char *, mode_t) { - return 0; + return 0; } -int -chown(const char *k, uid_t, gid_t) +int chown(const char *k, uid_t, gid_t) { - return 0; + return 0; } -int -lchown(const char *k, uid_t, gid_t) +int lchown(const char *k, uid_t, gid_t) { - return 0; + return 0; } +bool fstype(const char *fname, char *fs, int fslen) +{ + return true; /* accept anything */ +} long int @@ -133,7 +133,7 @@ random(void) void srandom(unsigned int seed) { - srand(seed); + srand(seed); } // ///////////////////////////////////////////////////////////////// // convert from Windows concept of time to Unix concept of time @@ -1105,37 +1105,41 @@ int close_bpipe(BPIPE *bpipe) { int rval = 0; - if (bpipe->rfd) fclose(bpipe->rfd); - if (bpipe->wfd) fclose(bpipe->wfd); + int32_t remaining_wait = bpipe->wait; - if (bpipe->wait) { - int remaining_wait = bpipe->wait; - do { - DWORD exitCode; - if (!GetExitCodeProcess((HANDLE)bpipe->worker_pid, &exitCode)) { - const char *err = errorString(); - rval = b_errno_win32; - d_msg(__FILE__, __LINE__, 0, - "GetExitCode error %s\n", err); - LocalFree((void *)err); - break; - } - - if (exitCode == STILL_ACTIVE) { - bmicrosleep(1, 0); /* wait one second */ - remaining_wait--; - } else if (exitCode != 0) { - rval = exitCode | b_errno_exit; - break; - } else { + if (remaining_wait == 0) { /* wait indefinitely */ + remaining_wait = INT32_MAX; + } + for ( ;; ) { + DWORD exitCode; + if (!GetExitCodeProcess((HANDLE)bpipe->worker_pid, &exitCode)) { + const char *err = errorString(); + rval = b_errno_win32; + d_msg(__FILE__, __LINE__, 0, + "GetExitCode error %s\n", err); + LocalFree((void *)err); + break; + } + if (exitCode == STILL_ACTIVE) { + if (remaining_wait <= 0) { + rval = ETIME; /* timed out */ break; } - } while(remaining_wait); - rval = ETIME; /* timed out */ } + bmicrosleep(1, 0); /* wait one second */ + remaining_wait--; + } else if (exitCode != 0) { + rval = exitCode | b_errno_exit; + break; + } else { + break; /* Shouldn't get here */ + } + } if (bpipe->timer_id) { stop_child_timer(bpipe->timer_id); } + if (bpipe->rfd) fclose(bpipe->rfd); + if (bpipe->wfd) fclose(bpipe->wfd); free((void *)bpipe); return rval; } -- 2.39.5