]> git.sur5r.net Git - bacula/bacula/commitdiff
- Fix compile problems on Win32
authorKern Sibbald <kern@sibbald.com>
Sat, 4 Jun 2005 19:20:35 +0000 (19:20 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 4 Jun 2005 19:20:35 +0000 (19:20 +0000)
- Start writing Volume reservation list (already exists, but
  is not really very good).

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2107 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kes-1.37
bacula/src/baconfig.h
bacula/src/filed/heartbeat.c
bacula/src/lib/jcr.c
bacula/src/lib/protos.h
bacula/src/lib/tls.c
bacula/src/lib/winapi.c
bacula/src/stored/askdir.c
bacula/src/stored/stored.c
bacula/src/stored/stored_conf.c
bacula/src/stored/stored_conf.h

index f19a2db5704be42743954066ee8e61b11999ba23..aae8e7fbc28068e053812c3e039619d5a42d8392 100644 (file)
@@ -4,6 +4,9 @@
 General:
 
 Changes to 1.37.21:
+- Fix compile problems on Win32
+- Start writing Volume reservation list (already exists, but
+  is not really very good).
 - Implement attribute caching to put Signature into database     
   at the same time as the file attributes thus eliminating a
   number of database accesses.
index 7e665ae10a90b78932faf9bd9cd4b3c124306be0..db4c77f255e00b7342a9daa5419144ea4b463d33 100644 (file)
@@ -425,7 +425,7 @@ int  Mmsg(POOLMEM *&msgbuf, const char *fmt,...);
 int  Mmsg(POOL_MEM &msgbuf, const char *fmt,...);
 
 
-struct JCR;
+class JCR;
 void d_msg(const char *file, int line, int level, const char *fmt,...);
 void p_msg(const char *file, int line, int level, const char *fmt,...);
 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
index 15c755b4fd18641633b9c1196397ecada4a362a3..93e2bc45431d2ad98ce76b7bed04acdf32cafcae 100644 (file)
@@ -44,15 +44,17 @@ extern "C" void *sd_heartbeat_thread(void *arg)
    BSOCK *sd, *dir;
    time_t last_heartbeat = time(NULL);
    time_t now;
-   int oflags;
 
    pthread_detach(pthread_self());
 
    /* Get our own local copy */
    sd = dup_bsock(jcr->store_bsock);
+#ifndef WIN32
+   int oflags;
    if ((oflags = fcntl(sd->fd, F_GETFL, 0)) != -1) {
       fcntl(sd->fd, F_SETFL, oflags|O_NONBLOCK);
    }
+#endif
    dir = dup_bsock(jcr->dir_bsock);
 
    jcr->hb_bsock = sd;
index 125db781231ca2f8e78cc659d44fe369264cfc49..c2d456b7221871b565351a1fb95e8e235cf31a1a 100755 (executable)
@@ -17,7 +17,7 @@
  *  in the list while traversing it rather than a single lock
  *  at the beginning of a traversal and one at the end.  This
  *  incurs slightly more overhead, but effectively eliminates 
- *  the possibilty of race conditions.  In addition, with the
+ *  the possibilty of race conditions. In addition, with the
  *  exception of the global locking of the list during the
  *  re-reading of the config file, no recursion is needed.
  *
@@ -61,7 +61,7 @@ int num_jobs_run;
 dlist *last_jobs = NULL;
 const int max_last_jobs = 10;
  
-static dlist *jcrs = NULL;            /* JCR chain */
+static dlist *jcrs = NULL;           /* JCR chain */
 static pthread_mutex_t jcr_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static pthread_mutex_t job_start_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -78,7 +78,7 @@ void unlock_jobs()
 
 void init_last_jobs_list()
 {
-   JCR *jcr;
+   JCR *jcr = NULL;
    struct s_last_job *job_entry = NULL;
    if (!last_jobs) {
       last_jobs = New(dlist(job_entry, &job_entry->link));
@@ -92,9 +92,9 @@ void term_last_jobs_list()
 {
    if (last_jobs) {
       while (!last_jobs->empty()) {
-         void *je = last_jobs->first();
-         last_jobs->remove(je);
-         free(je);
+        void *je = last_jobs->first();
+        last_jobs->remove(je);
+        free(je);
       }
       delete last_jobs;
       last_jobs = NULL;
@@ -124,20 +124,20 @@ void read_last_jobs_list(int fd, uint64_t addr)
    for ( ; num; num--) {
       if (read(fd, &job, sizeof(job)) != sizeof(job)) {
          Dmsg1(000, "Read job entry. ERR=%s\n", strerror(errno));
-         return;
+        return;
       }
       if (job.JobId > 0) {
-         je = (struct s_last_job *)malloc(sizeof(struct s_last_job));
-         memcpy((char *)je, (char *)&job, sizeof(job));
-         if (!last_jobs) {
-            init_last_jobs_list();
-         }
-         last_jobs->append(je);
-         if (last_jobs->size() > max_last_jobs) {
-            je = (struct s_last_job *)last_jobs->first();
-            last_jobs->remove(je);
-            free(je);
-         }
+        je = (struct s_last_job *)malloc(sizeof(struct s_last_job));
+        memcpy((char *)je, (char *)&job, sizeof(job));
+        if (!last_jobs) {
+           init_last_jobs_list();
+        }
+        last_jobs->append(je);
+        if (last_jobs->size() > max_last_jobs) {
+           je = (struct s_last_job *)last_jobs->first();
+           last_jobs->remove(je);
+           free(je);
+        }
       }
    }
 }
@@ -156,13 +156,13 @@ uint64_t write_last_jobs_list(int fd, uint64_t addr)
       num = last_jobs->size();
       if (write(fd, &num, sizeof(num)) != sizeof(num)) {
          Dmsg1(000, "Error writing num_items: ERR=%s\n", strerror(errno));
-         return 0;
+        return 0;
       }
       foreach_dlist(je, last_jobs) {
-         if (write(fd, je, sizeof(struct s_last_job)) != sizeof(struct s_last_job)) {
+        if (write(fd, je, sizeof(struct s_last_job)) != sizeof(struct s_last_job)) {
             Dmsg1(000, "Error writing job: ERR=%s\n", strerror(errno));
-            return 0;
-         }
+           return 0;
+        }
       }
    }
    /* Return current address */
@@ -237,7 +237,7 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr)
    /* Setup some dummy values */
    bstrncpy(jcr->Job, "*System*", sizeof(jcr->Job));
    jcr->JobId = 0;
-   jcr->JobType = JT_SYSTEM;          /* internal job until defined */
+   jcr->JobType = JT_SYSTEM;         /* internal job until defined */
    jcr->JobLevel = L_NONE;
    jcr->JobStatus = JS_Created;
 
@@ -268,7 +268,7 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr)
 /*
  * Remove a JCR from the chain
  * NOTE! The chain must be locked prior to calling
- *       this routine.
+ *      this routine.
  */
 static void remove_jcr(JCR *jcr)
 {
@@ -309,17 +309,17 @@ static void free_common_jcr(JCR *jcr)
       last_job.end_time = time(NULL);
       /* Keep list of last jobs, but not Console where JobId==0 */
       if (last_job.JobId > 0) {
-         je = (struct s_last_job *)malloc(sizeof(struct s_last_job));
-         memcpy((char *)je, (char *)&last_job, sizeof(last_job));
-         if (!last_jobs) {
-            init_last_jobs_list();
-         }
-         last_jobs->append(je);
-         if (last_jobs->size() > max_last_jobs) {
-            je = (struct s_last_job *)last_jobs->first();
-            last_jobs->remove(je);
-            free(je);
-         }
+        je = (struct s_last_job *)malloc(sizeof(struct s_last_job));
+        memcpy((char *)je, (char *)&last_job, sizeof(last_job));
+        if (!last_jobs) {
+           init_last_jobs_list();
+        }
+        last_jobs->append(je);
+        if (last_jobs->size() > max_last_jobs) {
+           je = (struct s_last_job *)last_jobs->first();
+           last_jobs->remove(je);
+           free(je);
+        }
       }
       break;
    default:
@@ -328,7 +328,7 @@ static void free_common_jcr(JCR *jcr)
    pthread_mutex_destroy(&jcr->mutex);
 
    delete jcr->msg_queue;
-   close_msg(jcr);                    /* close messages for this job */
+   close_msg(jcr);                   /* close messages for this job */
 
    /* do this after closing messages */
    if (jcr->client_name) {
@@ -391,29 +391,29 @@ void free_jcr(JCR *jcr)
 
    dequeue_messages(jcr);
    lock_jcr_chain();
-   jcr->dec_use_count();              /* decrement use count */
+   jcr->dec_use_count();             /* decrement use count */
    if (jcr->use_count < 0) {
       Emsg2(M_ERROR, 0, _("JCR use_count=%d JobId=%d\n"),
-         jcr->use_count, jcr->JobId);
+        jcr->use_count, jcr->JobId);
    }
    Dmsg3(3400, "Dec free_jcr 0x%x use_count=%d jobid=%d\n", jcr, jcr->use_count, jcr->JobId);
-   if (jcr->use_count > 0) {          /* if in use */
+   if (jcr->use_count > 0) {         /* if in use */
       unlock_jcr_chain();
       Dmsg2(3400, "free_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
       return;
    }
 
-   remove_jcr(jcr);                   /* remove Jcr from chain */
+   remove_jcr(jcr);                  /* remove Jcr from chain */
    unlock_jcr_chain();
 
-   job_end_pop(jcr);                  /* pop and call hooked routines */
+   job_end_pop(jcr);                 /* pop and call hooked routines */
 
    Dmsg1(3400, "End job=%d\n", jcr->JobId);
    if (jcr->daemon_free_jcr) {
       jcr->daemon_free_jcr(jcr);      /* call daemon free routine */
    }
    free_common_jcr(jcr);
-   close_msg(NULL);                   /* flush any daemon messages */
+   close_msg(NULL);                  /* flush any daemon messages */
    Dmsg0(3400, "Exit free_jcr\n");
 }
 
@@ -421,18 +421,18 @@ void free_jcr(JCR *jcr)
 /*
  * Given a JobId, find the JCR
  *   Returns: jcr on success
- *            NULL on failure
+ *           NULL on failure
  */
 JCR *get_jcr_by_id(uint32_t JobId)
 {
    JCR *jcr;
 
-   lock_jcr_chain();                    /* lock chain */
+   lock_jcr_chain();                   /* lock chain */
    foreach_dlist(jcr, jcrs) {
       if (jcr->JobId == JobId) {
-         jcr->inc_use_count();
+        jcr->inc_use_count();
          Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
-         break;
+        break;
       }
    }
    unlock_jcr_chain();
@@ -442,7 +442,7 @@ JCR *get_jcr_by_id(uint32_t JobId)
 /*
  * Given a SessionId and SessionTime, find the JCR
  *   Returns: jcr on success
- *            NULL on failure
+ *           NULL on failure
  */
 JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime)
 {
@@ -451,10 +451,10 @@ JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime)
    lock_jcr_chain();
    foreach_dlist(jcr, jcrs) {
       if (jcr->VolSessionId == SessionId &&
-          jcr->VolSessionTime == SessionTime) {
-         jcr->inc_use_count();
+         jcr->VolSessionTime == SessionTime) {
+        jcr->inc_use_count();
          Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
-         break;
+        break;
       }
    }
    unlock_jcr_chain();
@@ -467,7 +467,7 @@ JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime)
  *  compares on the number of characters in Job
  *  thus allowing partial matches.
  *   Returns: jcr on success
- *            NULL on failure
+ *           NULL on failure
  */
 JCR *get_jcr_by_partial_name(char *Job)
 {
@@ -481,9 +481,9 @@ JCR *get_jcr_by_partial_name(char *Job)
    len = strlen(Job);
    foreach_dlist(jcr, jcrs) {
       if (strncmp(Job, jcr->Job, len) == 0) {
-         jcr->inc_use_count();
+        jcr->inc_use_count();
          Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
-         break;
+        break;
       }
    }
    unlock_jcr_chain();
@@ -495,7 +495,7 @@ JCR *get_jcr_by_partial_name(char *Job)
  * Given a Job, find the JCR
  *  requires an exact match of names.
  *   Returns: jcr on success
- *            NULL on failure
+ *           NULL on failure
  */
 JCR *get_jcr_by_full_name(char *Job)
 {
@@ -507,9 +507,9 @@ JCR *get_jcr_by_full_name(char *Job)
    lock_jcr_chain();
    foreach_dlist(jcr, jcrs) {
       if (strcmp(jcr->Job, Job) == 0) {
-         jcr->inc_use_count();
+        jcr->inc_use_count();
          Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
-         break;
+        break;
       }
    }
    unlock_jcr_chain();
@@ -590,8 +590,8 @@ bool init_jcr_subsystem(void)
    watchdog_t *wd = new_watchdog();
 
    wd->one_shot = false;
-   wd->interval = 30;   /* FIXME: should be configurable somewhere, even
-                         if only with a #define */
+   wd->interval = 30;  /* FIXME: should be configurable somewhere, even
+                        if only with a #define */
    wd->callback = jcr_timeout_check;
 
    register_watchdog(wd);
@@ -612,44 +612,44 @@ static void jcr_timeout_check(watchdog_t *self)
     */
    foreach_jcr(jcr) {
       if (jcr->JobId == 0) {
-         free_jcr(jcr);
-         continue;
+        free_jcr(jcr);
+        continue;
       }
       fd = jcr->store_bsock;
       if (fd) {
-         timer_start = fd->timer_start;
-         if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
-            fd->timer_start = 0;      /* turn off timer */
-            fd->timed_out = TRUE;
-            Jmsg(jcr, M_ERROR, 0, _(
+        timer_start = fd->timer_start;
+        if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
+           fd->timer_start = 0;      /* turn off timer */
+           fd->timed_out = TRUE;
+           Jmsg(jcr, M_ERROR, 0, _(
 "Watchdog sending kill after %d secs to thread stalled reading Storage daemon.\n"),
-                 watchdog_time - timer_start);
-            pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
-         }
+                watchdog_time - timer_start);
+           pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
+        }
       }
       fd = jcr->file_bsock;
       if (fd) {
-         timer_start = fd->timer_start;
-         if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
-            fd->timer_start = 0;      /* turn off timer */
-            fd->timed_out = TRUE;
-            Jmsg(jcr, M_ERROR, 0, _(
+        timer_start = fd->timer_start;
+        if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
+           fd->timer_start = 0;      /* turn off timer */
+           fd->timed_out = TRUE;
+           Jmsg(jcr, M_ERROR, 0, _(
 "Watchdog sending kill after %d secs to thread stalled reading File daemon.\n"),
-                 watchdog_time - timer_start);
-            pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
-         }
+                watchdog_time - timer_start);
+           pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
+        }
       }
       fd = jcr->dir_bsock;
       if (fd) {
-         timer_start = fd->timer_start;
-         if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
-            fd->timer_start = 0;      /* turn off timer */
-            fd->timed_out = TRUE;
-            Jmsg(jcr, M_ERROR, 0, _(
+        timer_start = fd->timer_start;
+        if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
+           fd->timer_start = 0;      /* turn off timer */
+           fd->timed_out = TRUE;
+           Jmsg(jcr, M_ERROR, 0, _(
 "Watchdog sending kill after %d secs to thread stalled reading Director.\n"),
-                 watchdog_time - timer_start);
-            pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
-         }
+                watchdog_time - timer_start);
+           pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
+        }
       }
       free_jcr(jcr);
    }
@@ -662,5 +662,5 @@ static void jcr_timeout_check(watchdog_t *self)
  */
 extern "C" void timeout_handler(int sig)
 {
-   return;                            /* thus interrupting the function */
+   return;                           /* thus interrupting the function */
 }
index 6519503fed7de2f6c7c5de94f800515c91fa83c0..5addbd397b8aa9ad5677c2b0efe944f4ad1ec739 100644 (file)
@@ -23,7 +23,7 @@
 
  */
 
-struct JCR;
+class JCR;
 
 /* attr.c */
 ATTR     *new_attr();
@@ -213,7 +213,6 @@ int             bsscanf(const char *buf, const char *fmt, ...);
 int              init_tls                (void);
 int              cleanup_tls             (void);
 
-#ifdef HAVE_TLS
 TLS_CONTEXT      *new_tls_context        (const char *ca_certfile,
                                           const char *ca_certdir,
                                           const char *certfile,
@@ -223,6 +222,7 @@ TLS_CONTEXT      *new_tls_context        (const char *ca_certfile,
                                           const char *dhfile,
                                           bool verify_peer);
 void             free_tls_context        (TLS_CONTEXT *ctx);
+#ifdef HAVE_TLS
 bool             tls_postconnect_verify_host  (TLS_CONNECTION *tls,
                                                const char *host);
 bool             tls_postconnect_verify_cn    (TLS_CONNECTION *tls,
index 0401dee39bf029853bb8a206f54e286debccf049..ae596b8d82f9fdc97a50253321f1fd4ba7d42b0f 100644 (file)
@@ -928,6 +928,14 @@ int cleanup_tls (void)
 /* Dummy routines */
 int init_tls(void) { return 0; }
 int cleanup_tls (void) { return 0; }
-
+TLS_CONTEXT *new_tls_context(const char *ca_certfile, const char *ca_certdir,
+                             const char *certfile, const char *keyfile,
+                             TLS_PEM_PASSWD_CB *pem_callback,
+                             const void *pem_userdata, const char *dhfile,
+                             bool verify_peer)
+{
+   return NULL;
+}
+void free_tls_context(TLS_CONTEXT *ctx) { }
 
 #endif /* HAVE_TLS */
index 0f640a49adeb3852c7867a1b156943cf4166e3d2..976a33a24c2d7bffce1329ab8f89930155313348 100644 (file)
 
 // init with win9x, but maybe set to NT in InitWinAPI
 DWORD  g_platform_id = VER_PLATFORM_WIN32_WINDOWS;
+#ifdef WIN32_VSS
 /* preset VSSClient to NULL */
 VSSClient* g_pVSSClient = NULL;
+#endif
 
 
 /* API Pointers */
 
-t_OpenProcessToken      p_OpenProcessToken = NULL;
+t_OpenProcessToken     p_OpenProcessToken = NULL;
 t_AdjustTokenPrivileges p_AdjustTokenPrivileges = NULL;
-t_LookupPrivilegeValue  p_LookupPrivilegeValue = NULL;
+t_LookupPrivilegeValue p_LookupPrivilegeValue = NULL;
 
 t_SetProcessShutdownParameters p_SetProcessShutdownParameters = NULL;
 
-t_CreateFileA   p_CreateFileA = NULL;
-t_CreateFileW   p_CreateFileW = NULL;
+t_CreateFileA  p_CreateFileA = NULL;
+t_CreateFileW  p_CreateFileW = NULL;
 
 t_wunlink p_wunlink = NULL;
 t_wmkdir p_wmkdir = NULL;
 t_wopen p_wopen = NULL;
 
-t_GetFileAttributesA    p_GetFileAttributesA = NULL;
-t_GetFileAttributesW    p_GetFileAttributesW = NULL;
+t_GetFileAttributesA   p_GetFileAttributesA = NULL;
+t_GetFileAttributesW   p_GetFileAttributesW = NULL;
 
-t_GetFileAttributesExA  p_GetFileAttributesExA = NULL;
-t_GetFileAttributesExW  p_GetFileAttributesExW = NULL;
+t_GetFileAttributesExA p_GetFileAttributesExA = NULL;
+t_GetFileAttributesExW p_GetFileAttributesExW = NULL;
 
-t_SetFileAttributesA    p_SetFileAttributesA = NULL;
-t_SetFileAttributesW    p_SetFileAttributesW = NULL;
-t_BackupRead            p_BackupRead = NULL;
-t_BackupWrite           p_BackupWrite = NULL;
+t_SetFileAttributesA   p_SetFileAttributesA = NULL;
+t_SetFileAttributesW   p_SetFileAttributesW = NULL;
+t_BackupRead           p_BackupRead = NULL;
+t_BackupWrite          p_BackupWrite = NULL;
 t_WideCharToMultiByte p_WideCharToMultiByte = NULL;
 t_MultiByteToWideChar p_MultiByteToWideChar = NULL;
 
@@ -160,7 +162,7 @@ InitWinAPIWrapper()
       /* wopen */
       p_wopen = (t_wopen)
       GetProcAddress(hLib, "_wopen");
-        
+       
       FreeLibrary(hLib);
    }
    
@@ -195,12 +197,12 @@ InitWinAPIWrapper()
       p_BackupRead = NULL;
       p_BackupWrite = NULL;
 
-      p_CreateFileW = NULL;          
-      p_GetFileAttributesW = NULL;          
+      p_CreateFileW = NULL;         
+      p_GetFileAttributesW = NULL;         
       p_GetFileAttributesExW = NULL;
-          
+         
       p_SetFileAttributesW = NULL;
-                
+               
       p_FindFirstFileW = NULL;
       p_FindNextFileW = NULL;
       p_SetCurrentDirectoryW = NULL;
@@ -215,13 +217,13 @@ InitWinAPIWrapper()
 #ifdef WIN32_VSS
    switch (dwMinorVersion) {
       case 1: 
-         g_pVSSClient = new VSSClientXP();
-         atexit(VSSCleanup);
-         break;
+        g_pVSSClient = new VSSClientXP();
+        atexit(VSSCleanup);
+        break;
       case 2: 
-         g_pVSSClient = new VSSClient2003();
-         atexit(VSSCleanup);
-         break;
+        g_pVSSClient = new VSSClient2003();
+        atexit(VSSCleanup);
+        break;
    }
 #endif
 }
index d449634709a204d3fd09181954d48f882b282061..675f17b1f286438732d7d5d55a30732347628e3d 100644 (file)
    Copyright (C) 2000-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as ammended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -217,6 +212,37 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing)
     return do_get_volume_info(dcr);
 }
 
+/*
+ * Rewrite this to use a list, but need something to add
+ *   and remove volumes from the list.
+ */
+static bool is_volume_in_use(JCR *jcr, const char *VolumeName) {
+    bool in_use = false;
+    JCR *njcr;
+    Dmsg2(300, "JobId=%d got possible Vol=%s\n", jcr->JobId, VolumeName);
+    /*
+     * Walk through all jobs and see if the volume is
+     *  already mounted. If so, try a different one.
+     * This would be better done by walking through
+     *  all the devices.
+     */
+    foreach_jcr(njcr) {
+       if (jcr == njcr) {
+          free_jcr(njcr);
+          continue;             /* us */
+       }
+       Dmsg2(300, "Compare to JobId=%d using Vol=%s\n", njcr->JobId, njcr->dcr->VolumeName);
+       if (njcr->dcr && strcmp(VolumeName, njcr->dcr->VolumeName) == 0) {
+          in_use = true;
+          Dmsg1(400, "Vol in use by JobId=%u\n", njcr->JobId);
+          free_jcr(njcr);
+          break;
+       }
+       free_jcr(njcr);
+    }
+    return in_use;
+ }
+
 
 
 /*
@@ -231,15 +257,14 @@ bool dir_find_next_appendable_volume(DCR *dcr)
 {
     JCR *jcr = dcr->jcr;
     BSOCK *dir = jcr->dir_bsock;
-    JCR *njcr;
 
     Dmsg0(200, "dir_find_next_appendable_volume\n");
     /*
-     * Try the three oldest or most available volumes.  Note,
+     * Try the twenty oldest or most available volumes.  Note,
      *   the most available could already be mounted on another
      *   drive, so we continue looking for a not in use Volume.
      */
-    for (int vol_index=1;  vol_index < 3; vol_index++) {
+    for (int vol_index=1;  vol_index < 20; vol_index++) {
        bash_spaces(dcr->media_type);
        bash_spaces(dcr->pool_name);
        bnet_fsend(dir, Find_media, jcr->Job, vol_index, dcr->pool_name, dcr->media_type);
@@ -247,31 +272,10 @@ bool dir_find_next_appendable_volume(DCR *dcr)
        unbash_spaces(dcr->pool_name);
        Dmsg1(100, ">dird: %s", dir->msg);
        if (do_get_volume_info(dcr)) {
-          Dmsg2(300, "JobId=%d got possible Vol=%s\n", jcr->JobId, dcr->VolumeName);
-          bool found = false;
-          /*
-           * Walk through all jobs and see if the volume is
-           *  already mounted. If so, try a different one.
-           * This would be better done by walking through
-           *  all the devices.
-           */
-          foreach_jcr(njcr) {
-             if (jcr == njcr) {
-                free_jcr(njcr);
-                continue;             /* us */
-             }
-             Dmsg2(300, "Compare to JobId=%d using Vol=%s\n", njcr->JobId, njcr->dcr->VolumeName);
-             if (njcr->dcr && strcmp(dcr->VolumeName, njcr->dcr->VolumeName) == 0) {
-                found = true;
-                Dmsg1(400, "Vol in use by JobId=%u\n", njcr->JobId);
-                free_jcr(njcr);
-                break;
-             }
-             free_jcr(njcr);
-          }
-          if (!found) {
-             Dmsg0(400, "dir_find_next_appendable_volume return true\n");
-             return true;             /* Got good Volume */
+          if (is_volume_in_use(jcr, dcr->VolumeName)) {
+             continue;
+          } else {
+             break;
           }
        } else {
           Dmsg0(200, "No volume info, return false\n");
index 2695fa70efc794018eba28a52bf1df51f32308b9..cca3248ffc0e5a33142510eae3a5eb40f4740725 100644 (file)
@@ -302,13 +302,18 @@ static int check_resources()
       OK = false;
    }
 
-#ifdef HAVE_TLS
    DIRRES *director;
    STORES *store;
    foreach_res(store, R_STORAGE) { 
       /* tls_require implies tls_enable */
       if (store->tls_require) {
+#ifndef HAVE_TLS
+         Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
+         OK = false;
+         continue;
+#else
          store->tls_enable = true;
+#endif
       }
 
       if (!store->tls_certfile && store->tls_enable) {
@@ -394,7 +399,6 @@ static int check_resources()
          }
       }
    }
-#endif /* HAVE_TLS */
 
    /* Ensure that the media_type for each device is the same */
    foreach_res(changer, R_AUTOCHANGER) {
index b3dea456bc6ac5e0daf8b8138448536b0c1c02c0..876bf8470b41e2327c8921ef8106359999e65cdf 100644 (file)
@@ -59,7 +59,6 @@ static RES_ITEM store_items[] = {
    {"scriptsdirectory",      store_dir,  ITEM(res_store.scripts_directory), 0, 0, 0},
    {"maximumconcurrentjobs", store_pint, ITEM(res_store.max_concurrent_jobs), 0, ITEM_DEFAULT, 10},
    {"heartbeatinterval",     store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0},
-#ifdef HAVE_TLS
    {"tlsenable",             store_yesno,     ITEM(res_store.tls_enable), 1, ITEM_DEFAULT, 0},
    {"tlsrequire",            store_yesno,     ITEM(res_store.tls_require), 1, ITEM_DEFAULT, 0},
    {"tlsverifypeer",         store_yesno,     ITEM(res_store.tls_verify_peer), 1, ITEM_DEFAULT, 0},
@@ -69,7 +68,6 @@ static RES_ITEM store_items[] = {
    {"tlskey",                store_dir,       ITEM(res_store.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",             store_dir,       ITEM(res_store.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",          store_alist_str, ITEM(res_store.tls_allowed_cns), 0, 0, 0},
-#endif /* HAVE_TLS */
    {NULL, NULL, 0, 0, 0, 0}
 };
 
@@ -80,7 +78,6 @@ static RES_ITEM dir_items[] = {
    {"description", store_str,      ITEM(res_dir.hdr.desc),   0, 0, 0},
    {"password",    store_password, ITEM(res_dir.password),   0, ITEM_REQUIRED, 0},
    {"monitor",     store_yesno,    ITEM(res_dir.monitor),   1, ITEM_DEFAULT, 0},
-#ifdef HAVE_TLS
    {"tlsenable",            store_yesno,     ITEM(res_dir.tls_enable), 1, ITEM_DEFAULT, 0},
    {"tlsrequire",           store_yesno,     ITEM(res_dir.tls_require), 1, ITEM_DEFAULT, 0},
    {"tlsverifypeer",        store_yesno,     ITEM(res_dir.tls_verify_peer), 1, ITEM_DEFAULT, 0},
@@ -90,7 +87,6 @@ static RES_ITEM dir_items[] = {
    {"tlskey",               store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",            store_dir,       ITEM(res_dir.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",         store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0},
-#endif /* HAVE_TLS */
    {NULL, NULL, 0, 0, 0, 0}
 };
 
@@ -342,7 +338,6 @@ void free_resource(RES *sres, int type)
       if (res->res_dir.address) {
          free(res->res_dir.address);
       }
-#ifdef HAVE_TLS
       if (res->res_dir.tls_ctx) { 
          free_tls_context(res->res_dir.tls_ctx);
       }
@@ -364,7 +359,6 @@ void free_resource(RES *sres, int type)
       if (res->res_dir.tls_allowed_cns) {
          delete res->res_dir.tls_allowed_cns;
       }
-#endif /* HAVE_TLS */
       break;
    case R_AUTOCHANGER:
       if (res->res_changer.changer_name) {
@@ -396,7 +390,6 @@ void free_resource(RES *sres, int type)
       if (res->res_store.scripts_directory) {
          free(res->res_store.scripts_directory);
       }
-#ifdef HAVE_TLS
       if (res->res_store.tls_ctx) { 
          free_tls_context(res->res_store.tls_ctx);
       }
@@ -418,7 +411,6 @@ void free_resource(RES *sres, int type)
       if (res->res_store.tls_allowed_cns) {
          delete res->res_store.tls_allowed_cns;
       }
-#endif /* HAVE_TLS */
       break;
    case R_DEVICE:
       if (res->res_dev.media_type) {
@@ -524,18 +516,14 @@ void save_resource(int type, RES_ITEM *items, int pass)
          if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) {
             Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource \"%s\"\n", res_all.res_dir.hdr.name);
          }
-#ifdef HAVE_TLS
          res->res_dir.tls_allowed_cns = res_all.res_dir.tls_allowed_cns;
-#endif
          break;
       case R_STORAGE:
          if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) {
             Emsg1(M_ERROR_TERM, 0, "Cannot find Storage resource \"%s\"\n", res_all.res_dir.hdr.name);
          }
          res->res_store.messages = res_all.res_store.messages;
-#ifdef HAVE_TLS
          res->res_store.tls_allowed_cns = res_all.res_store.tls_allowed_cns;
-#endif
          break;
       case R_AUTOCHANGER:
          if ((res = (URES *)GetResWithName(type, res_all.res_changer.hdr.name)) == NULL) {
index 8819f3cc98972345b3f79a1619b301b77bede4e4..caaf77d05b1557598956bb8605b1c7663a049ca7 100644 (file)
@@ -50,7 +50,6 @@ public:
    char *password;                    /* Director password */
    char *address;                     /* Director IP address or zero */
    int monitor;                       /* Have only access to status and .status functions */
-#ifdef HAVE_TLS
    int tls_enable;                    /* Enable TLS */
    int tls_require;                   /* Require TLS */
    int tls_verify_peer;              /* TLS Verify Client Certificate */
@@ -62,7 +61,6 @@ public:
    alist *tls_allowed_cns;            /* TLS Allowed Clients */
 
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
-#endif /* HAVE_TLS */
 };
 
 
@@ -80,7 +78,6 @@ public:
    uint32_t max_concurrent_jobs;      /* maximum concurrent jobs to run */
    MSGS *messages;                    /* Daemon message handler */
    utime_t heartbeat_interval;        /* Interval to send hb to FD */
-#ifdef HAVE_TLS
    int tls_enable;                    /* Enable TLS */
    int tls_require;                   /* Require TLS */
    int tls_verify_peer;              /* TLS Verify Client Certificate */
@@ -92,7 +89,6 @@ public:
    alist *tls_allowed_cns;            /* TLS Allowed Clients */
 
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
-#endif /* HAVE_TLS */
 };
 typedef struct s_res_store STORES;