]> git.sur5r.net Git - bacula/bacula/commitdiff
Make another attempt at fixing the ClientRunXXX return code
authorKern Sibbald <kern@sibbald.com>
Wed, 16 Feb 2005 12:48:46 +0000 (12:48 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 16 Feb 2005 12:48:46 +0000 (12:48 +0000)
  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
bacula/src/win32/compat/compat.cpp

index 4040e9af6e3f7a6e439a60a9116f76978f95a67d..0b204a064e312aca61cf9e570679442d53f35f46 100644 (file)
@@ -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,
index 8bcfa7fdf7831bf58ef55491a9cc84dcbdfcb1a4..5ba631a717006df307c56bc612b0a0873922df69 100644 (file)
@@ -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;
 }