From: Kern S. <ke...@us...> - 2005-01-29 22:39:53
|
Update of /cvsroot/bacula/bacula/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29956/src/lib Modified Files: alist.h bnet.c bpipe.c daemon.c edit.c htable.c htable.h jcr.c message.c parse_conf.c protos.h scan.c watchdog.c workq.c Log Message: Vacation work -- see tech log Index: bpipe.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/bpipe.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- bpipe.c 8 Jan 2005 14:44:23 -0000 1.25 +++ bpipe.c 29 Jan 2005 22:39:01 -0000 1.26 @@ -195,38 +195,38 @@ /* wait for worker child to exit */ for ( ;; ) { - Dmsg2(200, "Wait for %d opt=%d\n", bpipe->worker_pid, wait_option); + Dmsg2(800, "Wait for %d opt=%d\n", bpipe->worker_pid, wait_option); do { wpid = waitpid(bpipe->worker_pid, &chldstatus, wait_option); } while (wpid == -1 && (errno == EINTR || errno == EAGAIN)); if (wpid == bpipe->worker_pid || wpid == -1) { stat = errno; - Dmsg3(200, "Got break wpid=%d status=%d ERR=%s\n", wpid, chldstatus, - wpid==-1?strerror(errno):"none"); + Dmsg3(800, "Got break wpid=%d status=%d ERR=%s\n", wpid, chldstatus, + wpid==-1?strerror(errno):"none"); break; } - Dmsg3(200, "Got wpid=%d status=%d ERR=%s\n", wpid, chldstatus, - wpid==-1?strerror(errno):"none"); + Dmsg3(800, "Got wpid=%d status=%d ERR=%s\n", wpid, chldstatus, + wpid==-1?strerror(errno):"none"); if (remaining_wait > 0) { bmicrosleep(1, 0); /* wait one second */ remaining_wait--; } else { stat = ETIME; /* set error status */ wpid = -1; - break; /* don't wait any longer */ + break; /* don't wait any longer */ } } if (wpid > 0) { if (WIFEXITED(chldstatus)) { /* process exit()ed */ stat = WEXITSTATUS(chldstatus); if (stat != 0) { - Dmsg1(200, "Non-zero status %d returned from child.\n", stat); + Dmsg1(800, "Non-zero status %d returned from child.\n", stat); stat |= b_errno_exit; /* exit status returned */ } - Dmsg1(200, "child status=%d\n", stat & ~b_errno_exit); + Dmsg1(800, "child status=%d\n", stat & ~b_errno_exit); } else if (WIFSIGNALED(chldstatus)) { /* process died */ stat = WTERMSIG(chldstatus); - Dmsg1(200, "Child died from signale %d\n", stat); + Dmsg1(800, "Child died from signale %d\n", stat); stat |= b_errno_signal; /* exit signal returned */ } } @@ -234,7 +234,7 @@ stop_child_timer(bpipe->timer_id); } free(bpipe); - Dmsg1(200, "returning stat = %d\n", stat); + Dmsg1(800, "returning stat = %d\n", stat); return stat; } @@ -269,9 +269,9 @@ stat1 = ferror(bpipe->rfd); } if (stat1 < 0) { - Dmsg2(100, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno)); + Dmsg2(100, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno)); } else if (stat1 != 0) { - Dmsg1(100, "Run program fgets stat=%d\n", stat1); + Dmsg1(100, "Run program fgets stat=%d\n", stat1); } } else { stat1 = 0; @@ -317,18 +317,18 @@ while (1) { fgets(tmp, sizeof_pool_memory(tmp), bpipe->rfd); - Dmsg1(200, "Run program fgets=%s", tmp); + Dmsg1(800, "Run program fgets=%s", tmp); pm_strcat(results, tmp); if (feof(bpipe->rfd)) { - stat1 = 0; + stat1 = 0; Dmsg1(100, "Run program fgets stat=%d\n", stat1); - break; + break; } else { - stat1 = ferror(bpipe->rfd); + stat1 = ferror(bpipe->rfd); } if (stat1 < 0) { Dmsg2(100, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno)); - break; + break; } else if (stat1 != 0) { Dmsg1(100, "Run program fgets stat=%d\n", stat1); } @@ -371,16 +371,16 @@ q++; quote = 0; } else { - while (*q && *q != ' ') + while (*q && *q != ' ') q++; } if (*q) - *(q++) = '\0'; + *(q++) = '\0'; bargv[argc++] = p; p = q; - while (*p && (*p == ' ' || *p == '\t')) + while (*p && (*p == ' ' || *p == '\t')) p++; - if (*p == '\"' || *p == '\'') { + if (*p == '\"' || *p == '\'') { quote = *p; p++; } Index: message.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/message.c,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- message.c 21 Dec 2004 16:18:39 -0000 1.102 +++ message.c 29 Jan 2005 22:39:01 -0000 1.103 @@ -115,7 +115,7 @@ if (argc>0 && argv && argv[0]) { /* strip trailing filename and save exepath */ for (l=p=argv[0]; *p; p++) { - if (*p == '/') { + if (*p == '/') { l = p; /* set pos of last slash */ } } @@ -125,7 +125,7 @@ l = argv[0]; #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) /* On Windows allow c: junk */ - if (l[1] == ':') { + if (l[1] == ':') { l += 2; } #endif @@ -297,7 +297,7 @@ for (d=msg->dest_chain; d; d=d->next) { if (dest_code == d->dest_code && ((where == NULL && d->where == NULL) || (strcmp(where, d->where) == 0))) { - Dmsg4(200, "Add to existing d=%x msgtype=%d destcode=%d where=%s\n", + Dmsg4(850, "Add to existing d=%x msgtype=%d destcode=%d where=%s\n", d, msg_type, dest_code, NPRT(where)); set_bit(msg_type, d->msg_types); set_bit(msg_type, msg->send_msg); /* set msg_type bit in our local */ @@ -317,7 +317,7 @@ if (mail_cmd) { d->mail_cmd = bstrdup(mail_cmd); } - Dmsg5(200, "add new d=%x msgtype=%d destcode=%d where=%s mailcmd=%s\n", + Dmsg5(850, "add new d=%x msgtype=%d destcode=%d where=%s mailcmd=%s\n", d, msg_type, dest_code, NPRT(where), NPRT(d->mail_cmd)); msg->dest_chain = d; } @@ -332,14 +332,14 @@ DEST *d; for (d=msg->dest_chain; d; d=d->next) { - Dmsg2(200, "Remove_msg_dest d=%x where=%s\n", d, NPRT(d->where)); + Dmsg2(850, "Remove_msg_dest d=%x where=%s\n", d, NPRT(d->where)); if (bit_is_set(msg_type, d->msg_types) && (dest_code == d->dest_code) && ((where == NULL && d->where == NULL) || (strcmp(where, d->where) == 0))) { - Dmsg3(200, "Found for remove d=%x msgtype=%d destcode=%d\n", + Dmsg3(850, "Found for remove d=%x msgtype=%d destcode=%d\n", d, msg_type, dest_code); clear_bit(msg_type, d->msg_types); - Dmsg0(200, "Return rem_msg_dest\n"); + Dmsg0(850, "Return rem_msg_dest\n"); return; } } @@ -358,7 +358,7 @@ Mmsg(name, "%s/%s.mail.%s.%d", working_directory, my_name, my_name, (int)(long)d); } - Dmsg1(200, "mailname=%s\n", name); + Dmsg1(850, "mailname=%s\n", name); } /* @@ -401,7 +401,7 @@ POOLMEM *cmd, *line; int len, stat; - Dmsg1(350, "Close_msg jcr=0x%x\n", jcr); + Dmsg1(850, "Close_msg jcr=0x%x\n", jcr); if (jcr == NULL) { /* NULL -> global chain */ msgs = daemon_msgs; @@ -413,7 +413,7 @@ if (msgs == NULL) { return; } - Dmsg1(350, "===Begin close msg resource at 0x%x\n", msgs); + Dmsg1(850, "===Begin close msg resource at 0x%x\n", msgs); cmd = get_pool_memory(PM_MESSAGE); for (d=msgs->dest_chain; d; ) { if (d->fd) { @@ -426,7 +426,7 @@ break; case MD_MAIL: case MD_MAIL_ON_ERROR: - Dmsg0(350, "Got MD_MAIL or MD_MAIL_ON_ERROR\n"); + Dmsg0(850, "Got MD_MAIL or MD_MAIL_ON_ERROR\n"); if (!d->fd) { break; } @@ -436,10 +436,10 @@ } if (!(bpipe=open_mail_pipe(jcr, cmd, d))) { - Pmsg0(000, "open mail pipe failed.\n"); + Pmsg0(000, "open mail pipe failed.\n"); goto rem_temp_file; } - Dmsg0(350, "Opened mail pipe\n"); + Dmsg0(850, "Opened mail pipe\n"); len = d->max_len+10; line = get_memory(len); rewind(d->fd); @@ -448,18 +448,18 @@ } if (!close_wpipe(bpipe)) { /* close write pipe sending mail */ berrno be; - Pmsg1(000, "close error: ERR=%s\n", be.strerror()); + Pmsg1(000, "close error: ERR=%s\n", be.strerror()); } /* - * Since we are closing all messages, before "recursing" + * Since we are closing all messages, before "recursing" * make sure we are not closing the daemon messages, otherwise * kaboom. */ if (msgs != daemon_msgs) { /* read what mail prog returned -- should be nothing */ while (fgets(line, len, bpipe->rfd)) { - Jmsg1(jcr, M_INFO, 0, _("Mail prog: %s"), line); + Jmsg1(jcr, M_INFO, 0, _("Mail prog: %s"), line); } } @@ -467,10 +467,10 @@ if (stat != 0 && msgs != daemon_msgs) { berrno be; be.set_errno(stat); - Dmsg1(350, "Calling emsg. CMD=%s\n", cmd); - Jmsg2(jcr, M_ERROR, 0, _("Mail program terminated in error.\n" - "CMD=%s\n" - "ERR=%s\n"), cmd, be.strerror()); + Dmsg1(850, "Calling emsg. CMD=%s\n", cmd); + Jmsg2(jcr, M_ERROR, 0, _("Mail program terminated in error.\n" + "CMD=%s\n" + "ERR=%s\n"), cmd, be.strerror()); } free_memory(line); rem_temp_file: @@ -479,7 +479,7 @@ unlink(d->mail_filename); free_pool_memory(d->mail_filename); d->mail_filename = NULL; - Dmsg0(350, "end mail or mail on error\n"); + Dmsg0(850, "end mail or mail on error\n"); break; default: break; @@ -489,14 +489,14 @@ d = d->next; /* point to next buffer */ } free_pool_memory(cmd); - Dmsg0(350, "Done walking message chain.\n"); + Dmsg0(850, "Done walking message chain.\n"); if (jcr) { free_msgs_res(msgs); msgs = NULL; } else { V(mutex); } - Dmsg0(350, "===End close msg resource\n"); + Dmsg0(850, "===End close msg resource\n"); } /* @@ -532,7 +532,7 @@ */ void term_msg() { - Dmsg0(300, "Enter term_msg\n"); + Dmsg0(850, "Enter term_msg\n"); close_msg(NULL); /* close global chain */ free_msgs_res(daemon_msgs); /* free the resources */ daemon_msgs = NULL; @@ -570,7 +570,7 @@ MSGS *msgs; BPIPE *bpipe; - Dmsg2(800, "Enter dispatch_msg type=%d msg=%s\n", type, msg); + Dmsg2(850, "Enter dispatch_msg type=%d msg=%s\n", type, msg); /* * Most messages are prefixed by a date and time. If mtime is @@ -601,7 +601,7 @@ #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) /* If we don't exit on error, error messages are parsed by UA */ if (exit_on_error) { - MessageBox(NULL, msg, "Bacula", MB_OK); + MessageBox(NULL, msg, "Bacula", MB_OK); } #endif #endif @@ -619,10 +619,10 @@ if (bit_is_set(type, d->msg_types)) { switch (d->dest_code) { case MD_CONSOLE: - Dmsg1(800, "CONSOLE for following msg: %s", msg); + Dmsg1(850, "CONSOLE for following msg: %s", msg); if (!con_fd) { - con_fd = fopen(con_fname, "a+"); - Dmsg0(800, "Console file not open.\n"); + con_fd = fopen(con_fname, "a+"); + Dmsg0(850, "Console file not open.\n"); } if (con_fd) { Pw(con_lock); /* get write lock on console message file */ @@ -633,11 +633,11 @@ len = strlen(msg); if (len > 0) { fwrite(msg, len, 1, con_fd); - if (msg[len-1] != '\n') { - fwrite("\n", 2, 1, con_fd); + if (msg[len-1] != '\n') { + fwrite("\n", 2, 1, con_fd); } } else { - fwrite("\n", 2, 1, con_fd); + fwrite("\n", 2, 1, con_fd); } fflush(con_fd); console_msg_pending = TRUE; @@ -645,14 +645,14 @@ } break; case MD_SYSLOG: - Dmsg1(800, "SYSLOG for collowing msg: %s\n", msg); + Dmsg1(850, "SYSLOG for collowing msg: %s\n", msg); /* * We really should do an openlog() here. */ - syslog(LOG_DAEMON|LOG_ERR, "%s", msg); + syslog(LOG_DAEMON|LOG_ERR, "%s", msg); break; case MD_OPERATOR: - Dmsg1(800, "OPERATOR for following msg: %s\n", msg); + Dmsg1(850, "OPERATOR for following msg: %s\n", msg); mcmd = get_pool_memory(PM_MESSAGE); if ((bpipe=open_mail_pipe(jcr, mcmd, d))) { int stat; @@ -663,24 +663,24 @@ if (stat != 0) { berrno be; be.set_errno(stat); - Qmsg2(jcr, M_ERROR, 0, _("Operator mail program terminated in error.\n" - "CMD=%s\n" - "ERR=%s\n"), mcmd, be.strerror()); + Qmsg2(jcr, M_ERROR, 0, _("Operator mail program terminated in error.\n" + "CMD=%s\n" + "ERR=%s\n"), mcmd, be.strerror()); } } free_pool_memory(mcmd); break; case MD_MAIL: case MD_MAIL_ON_ERROR: - Dmsg1(800, "MAIL for following msg: %s", msg); + Dmsg1(850, "MAIL for following msg: %s", msg); if (!d->fd) { POOLMEM *name = get_pool_memory(PM_MESSAGE); make_unique_mail_filename(jcr, name, d); - d->fd = fopen(name, "w+"); + d->fd = fopen(name, "w+"); if (!d->fd) { berrno be; d->fd = stdout; - Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", name, + Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", name, be.strerror()); d->fd = NULL; free_pool_memory(name); @@ -696,13 +696,13 @@ fputs(msg, d->fd); break; case MD_FILE: - Dmsg1(800, "FILE for following msg: %s", msg); + Dmsg1(850, "FILE for following msg: %s", msg); if (!d->fd) { - d->fd = fopen(d->where, "w+"); + d->fd = fopen(d->where, "w+"); if (!d->fd) { berrno be; d->fd = stdout; - Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, + Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, be.strerror()); d->fd = NULL; break; @@ -712,13 +712,13 @@ fputs(msg, d->fd); break; case MD_APPEND: - Dmsg1(800, "APPEND for following msg: %s", msg); + Dmsg1(850, "APPEND for following msg: %s", msg); if (!d->fd) { - d->fd = fopen(d->where, "a"); + d->fd = fopen(d->where, "a"); if (!d->fd) { berrno be; d->fd = stdout; - Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, + Qmsg2(jcr, M_ERROR, 0, "fopen %s failed: ERR=%s\n", d->where, be.strerror()); d->fd = NULL; break; @@ -728,21 +728,21 @@ fputs(msg, d->fd); break; case MD_DIRECTOR: - Dmsg1(800, "DIRECTOR for following msg: %s", msg); + Dmsg1(850, "DIRECTOR for following msg: %s", msg); if (jcr && jcr->dir_bsock && !jcr->dir_bsock->errors) { - bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%d %s", + bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%d %s", jcr->Job, type, mtime, msg); } break; case MD_STDOUT: - Dmsg1(800, "STDOUT for following msg: %s", msg); + Dmsg1(850, "STDOUT for following msg: %s", msg); if (type != M_ABORT && type != M_ERROR_TERM) { /* already printed */ fputs(dt, stdout); fputs(msg, stdout); } break; case MD_STDERR: - Dmsg1(800, "STDERR for following msg: %s", msg); + Dmsg1(850, "STDERR for following msg: %s", msg); fputs(dt, stderr); fputs(msg, stderr); break; @@ -783,9 +783,9 @@ /* visual studio passes the whole path to the file as well * which makes for very long lines */ - const char *f = strrchr(file, '\\'); + const char *f = strrchr(file, '\\'); if (f) file = f + 1; - len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line); + len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line); } else { len = 0; } @@ -797,13 +797,13 @@ va_end(arg_ptr); /* - * Used the "trace on" command in the console to turn on - * output to the trace file. "trace off" will close the file. + * Used the "trace on" command in the console to turn on + * output to the trace file. "trace off" will close the file. */ if (trace) { if (!trace_fd) { - bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory ? working_directory : "."); - trace_fd = fopen(buf, "a+"); + bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory ? working_directory : "."); + trace_fd = fopen(buf, "a+"); } if (trace_fd) { fputs(buf, trace_fd); @@ -895,13 +895,13 @@ if (level <= debug_level) { if (!trace_fd) { - bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory); - trace_fd = fopen(buf, "a+"); + bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory); + trace_fd = fopen(buf, "a+"); } #ifdef FULL_LOCATION if (details) { - len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line); + len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line); } else { len = 0; } @@ -951,15 +951,15 @@ break; case M_FATAL: if (level == -1) /* skip details */ - len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error because: ", my_name); + len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error because: ", my_name); else - len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error at %s:%d because:\n", my_name, file, line); + len = bsnprintf(buf, sizeof(buf), "%s: Fatal Error at %s:%d because:\n", my_name, file, line); break; case M_ERROR: if (level == -1) /* skip details */ - len = bsnprintf(buf, sizeof(buf), "%s: ERROR: ", my_name); + len = bsnprintf(buf, sizeof(buf), "%s: ERROR: ", my_name); else - len = bsnprintf(buf, sizeof(buf), "%s: ERROR in %s:%d ", my_name, file, line); + len = bsnprintf(buf, sizeof(buf), "%s: ERROR in %s:%d ", my_name, file, line); break; case M_WARNING: len = bsnprintf(buf, sizeof(buf), "%s: Warning: ", my_name); @@ -1002,7 +1002,7 @@ const char *job; - Dmsg1(800, "Enter Jmsg type=%d\n", type); + Dmsg1(850, "Enter Jmsg type=%d\n", type); /* Special case for the console, which has a dir_bsock and JobId==0, * in that case, we send the message directly back to the Index: bnet.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/bnet.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- bnet.c 11 Jan 2005 21:36:17 -0000 1.86 +++ bnet.c 29 Jan 2005 22:39:01 -0000 1.87 @@ -370,7 +370,7 @@ if (rc < 0) { if (!bsock->suppress_error_msgs && !bsock->timed_out) { Qmsg4(bsock->jcr, M_ERROR, 0, - _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who, + _("Write error sending len to %s:%s:%d: ERR=%s\n"), bsock->who, bsock->host, bsock->port, bnet_strerror(bsock)); } } else { @@ -400,8 +400,9 @@ } if (rc < 0) { if (!bsock->suppress_error_msgs) { - Qmsg4(bsock->jcr, M_ERROR, 0, - _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who, + Qmsg5(bsock->jcr, M_ERROR, 0, + _("Write error sending %d bytes to %s:%s:%d: ERR=%s\n"), + bsock->msglen, bsock->who, bsock->host, bsock->port, bnet_strerror(bsock)); } } else { Index: jcr.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/jcr.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- jcr.c 21 Dec 2004 16:18:39 -0000 1.63 +++ jcr.c 29 Jan 2005 22:39:01 -0000 1.64 @@ -9,7 +9,7 @@ * */ /* - Copyright (C) 2000-2004 Kern Sibbald and John Walker + 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 @@ -53,7 +53,7 @@ if (!last_jobs) { last_jobs = New(dlist(job_entry, &job_entry->link)); if ((errstat=rwl_init(&lock)) != 0) { - Emsg1(M_ABORT, 0, _("Unable to initialize jcr_chain lock. ERR=%s\n"), + Emsg1(M_ABORT, 0, _("Unable to initialize jcr_chain lock. ERR=%s\n"), strerror(errstat)); } } @@ -92,7 +92,7 @@ } for ( ; num; num--) { if (read(fd, &job, sizeof(job)) != sizeof(job)) { - Dmsg1(000, "Read job entry. ERR=%s\n", strerror(errno)); + Dmsg1(000, "Read job entry. ERR=%s\n", strerror(errno)); return; } if (job.JobId > 0) { @@ -124,12 +124,12 @@ /* First record is number of entires */ num = last_jobs->size(); if (write(fd, &num, sizeof(num)) != sizeof(num)) { - Dmsg1(000, "Error writing num_items: ERR=%s\n", strerror(errno)); + Dmsg1(000, "Error writing num_items: ERR=%s\n", strerror(errno)); return 0; } foreach_dlist(je, last_jobs) { if (write(fd, je, sizeof(struct s_last_job)) != sizeof(struct s_last_job)) { - Dmsg1(000, "Error writing job: ERR=%s\n", strerror(errno)); + Dmsg1(000, "Error writing job: ERR=%s\n", strerror(errno)); return 0; } } @@ -188,7 +188,7 @@ MQUEUE_ITEM *item = NULL; struct sigaction sigtimer; - Dmsg0(400, "Enter new_jcr\n"); + Dmsg0(3400, "Enter new_jcr\n"); jcr = (JCR *)malloc(size); memset(jcr, 0, size); jcr->my_thread_id = pthread_self(); @@ -234,7 +234,7 @@ */ static void remove_jcr(JCR *jcr) { - Dmsg0(400, "Enter remove_jcr\n"); + Dmsg0(3400, "Enter remove_jcr\n"); if (!jcr) { Emsg0(M_ABORT, 0, "NULL jcr.\n"); } @@ -246,7 +246,7 @@ if (jcr->next) { jcr->next->prev = jcr->prev; } - Dmsg0(400, "Leave remove_jcr\n"); + Dmsg0(3400, "Leave remove_jcr\n"); } /* @@ -342,14 +342,14 @@ #ifdef DEBUG void b_free_jcr(const char *file, int line, JCR *jcr) { - Dmsg3(400, "Enter free_jcr 0x%x from %s:%d\n", jcr, file, line); + Dmsg3(3400, "Enter free_jcr 0x%x from %s:%d\n", jcr, file, line); #else void free_jcr(JCR *jcr) { - Dmsg1(400, "Enter free_jcr 0x%x\n", jcr); + Dmsg1(3400, "Enter free_jcr 0x%x\n", jcr); #endif @@ -360,10 +360,10 @@ Emsg2(M_ERROR, 0, _("JCR use_count=%d JobId=%d\n"), jcr->use_count, jcr->JobId); } - Dmsg3(400, "Dec free_jcr 0x%x use_count=%d jobid=%d\n", jcr, 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 */ unlock_jcr_chain(); - Dmsg2(400, "free_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(3400, "free_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); return; } remove_jcr(jcr); /* remove Jcr from chain */ @@ -371,13 +371,13 @@ job_end_pop(jcr); /* pop and call hooked routines */ - Dmsg1(400, "End job=%d\n", jcr->JobId); + 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 */ - Dmsg0(400, "Exit free_jcr\n"); + Dmsg0(3400, "Exit free_jcr\n"); } @@ -388,7 +388,7 @@ void free_locked_jcr(JCR *jcr) { jcr->use_count--; /* decrement use count */ - Dmsg2(400, "Dec free_locked_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(3400, "Dec free_locked_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); if (jcr->use_count > 0) { /* if in use */ return; } @@ -414,7 +414,7 @@ P(jcr->mutex); jcr->use_count++; V(jcr->mutex); - Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -438,7 +438,7 @@ P(jcr->mutex); jcr->use_count++; V(jcr->mutex); - Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -469,7 +469,7 @@ P(jcr->mutex); jcr->use_count++; V(jcr->mutex); - Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -497,7 +497,7 @@ P(jcr->mutex); jcr->use_count++; V(jcr->mutex); - Dmsg2(400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(3400, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -538,7 +538,7 @@ { int errstat; #ifdef TRACE_JCR_CHAIN - Dmsg3(400, "Lock jcr chain %d from %s:%d\n", ++lock_count, + Dmsg3(3400, "Lock jcr chain %d from %s:%d\n", ++lock_count, fname, line); #endif if ((errstat=rwl_writelock(&lock)) != 0) { @@ -558,7 +558,7 @@ { int errstat; #ifdef TRACE_JCR_CHAIN - Dmsg3(400, "Unlock jcr chain %d from %s:%d\n", lock_count--, + Dmsg3(3400, "Unlock jcr chain %d from %s:%d\n", lock_count--, fname, line); #endif if ((errstat=rwl_writeunlock(&lock)) != 0) { @@ -581,7 +581,7 @@ P(jcr->mutex); jcr->use_count++; V(jcr->mutex); - Dmsg2(400, "Inc get_next_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(3400, "Inc get_next_jcr 0x%x use_count=%d\n", jcr, jcr->use_count); } return jcr; } @@ -606,7 +606,7 @@ BSOCK *fd; time_t timer_start; - Dmsg0(400, "Start JCR timeout checks\n"); + Dmsg0(3400, "Start JCR timeout checks\n"); /* Walk through all JCRs checking if any one is * blocked for more than specified max time. @@ -657,7 +657,7 @@ } unlock_jcr_chain(); - Dmsg0(400, "Finished JCR timeout checks\n"); + Dmsg0(3400, "Finished JCR timeout checks\n"); } /* Index: htable.h =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/htable.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- htable.h 21 Dec 2004 16:18:39 -0000 1.7 +++ htable.h 29 Jan 2005 22:39:01 -0000 1.8 @@ -3,7 +3,7 @@ */ /* - Copyright (C) 2000-2003 Kern Sibbald and John Walker + Copyright (C) 2003-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 @@ -32,9 +32,9 @@ * Loop var through each member of table */ #define foreach_htable(var, tbl) \ - for(((void *)(var))=(tbl)->first(); \ - (var); \ - ((void *)(var))=(tbl)->next()) + for((*((void **)&(var))=(void *)((tbl)->first())); \ + (var); \ + (*((void **)&(var))=(void *)((tbl)->next()))) struct hlink { void *next; /* next hash item */ Index: parse_conf.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/parse_conf.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- parse_conf.c 21 Dec 2004 16:18:39 -0000 1.61 +++ parse_conf.c 29 Jan 2005 22:39:01 -0000 1.62 @@ -176,7 +176,7 @@ for (i=0; items[i].name; i++) { Dmsg3(900, "Item=%s def=%s defval=%d\n", items[i].name, - (items[i].flags & ITEM_DEFAULT) ? "yes" : "no", + (items[i].flags & ITEM_DEFAULT) ? "yes" : "no", items[i].default_value); if (items[i].flags & ITEM_DEFAULT && items[i].default_value != 0) { if (items[i].handler == store_yesno) { @@ -196,7 +196,7 @@ } /* If this triggers, take a look at lib/parse_conf.h */ if (i >= MAX_RES_ITEMS) { - Emsg1(M_ERROR_TERM, 0, _("Too many items in %s resource\n"), resources[rindex]); + Emsg1(M_ERROR_TERM, 0, _("Too many items in %s resource\n"), resources[rindex]); } } } @@ -236,25 +236,25 @@ token = lex_get_token(lc, T_NAME); /* scan destination */ dest = check_pool_memory_size(dest, dest_len + lc->str_len + 2); if (dest[0] != 0) { - pm_strcat(dest, " "); /* separate multiple destinations with space */ + pm_strcat(dest, " "); /* separate multiple destinations with space */ dest_len++; } pm_strcat(dest, lc->str); dest_len += lc->str_len; - Dmsg2(900, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest)); + Dmsg2(900, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest)); token = lex_get_token(lc, T_SKIP_EOL); if (token == T_COMMA) { continue; /* get another destination */ } if (token != T_EQUALS) { - scan_err1(lc, _("expected an =, got: %s"), lc->str); + scan_err1(lc, _("expected an =, got: %s"), lc->str); } break; } - Dmsg1(900, "mail_cmd=%s\n", NPRT(cmd)); + Dmsg1(900, "mail_cmd=%s\n", NPRT(cmd)); scan_types(lc, (MSGS *)(item->value), item->code, dest, cmd); free_pool_memory(dest); - Dmsg0(900, "done with dest codes\n"); + Dmsg0(900, "done with dest codes\n"); break; case MD_FILE: /* file */ case MD_APPEND: /* append */ @@ -264,17 +264,17 @@ pm_strcpy(dest, lc->str); dest_len = lc->str_len; token = lex_get_token(lc, T_SKIP_EOL); - Dmsg1(900, "store_msgs dest=%s:\n", NPRT(dest)); + Dmsg1(900, "store_msgs dest=%s:\n", NPRT(dest)); if (token != T_EQUALS) { - scan_err1(lc, _("expected an =, got: %s"), lc->str); + scan_err1(lc, _("expected an =, got: %s"), lc->str); } scan_types(lc, (MSGS *)(item->value), item->code, dest, NULL); free_pool_memory(dest); - Dmsg0(900, "done with dest codes\n"); + Dmsg0(900, "done with dest codes\n"); break; default: - scan_err1(lc, _("Unknown item code: %d\n"), item->code); + scan_err1(lc, _("Unknown item code: %d\n"), item->code); break; } } @@ -313,7 +313,7 @@ } } if (!found) { - scan_err1(lc, _("message type: %s not found"), str); + scan_err1(lc, _("message type: %s not found"), str); /* NOT REACHED */ } @@ -421,7 +421,7 @@ MD5Update(&md5c, (unsigned char *) (lc->str), lc->str_len); MD5Final(signature, &md5c); for (i = j = 0; i < sizeof(signature); i++) { - sprintf(&sig[j], "%02x", signature[i]); + sprintf(&sig[j], "%02x", signature[i]); j += 2; } *(item->value) = bstrdup(sig); @@ -443,11 +443,11 @@ if (pass == 2) { res = GetResWithName(item->code, lc->str); if (res == NULL) { - scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"), + scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"), lc->str, lc->line_no, lc->line); } if (*(item->value)) { - scan_err3(lc, _("Attempt to redefine resource \"%s\" referenced on line %d : %s\n"), + scan_err3(lc, _("Attempt to redefine resource \"%s\" referenced on line %d : %s\n"), item->name, lc->line_no, lc->line); } *(item->value) = (char *)res; @@ -457,7 +457,7 @@ } /* - * Store a resource in an alist. default_value indicates how many + * Store a resource pointer in an alist. default_value indicates how many * times this routine can be called -- i.e. how many alists * there are. * If we are in pass 2, do a lookup of the @@ -471,24 +471,35 @@ alist *list; if (pass == 2) { - /* Find empty place to store this directive */ - while ((item->value)[i] != NULL && i++ < count) { } - if (i >= count) { - scan_err3(lc, _("Too many Storage directives. Max. is %d. line %d: %s\n"), - count, lc->line_no, lc->line); + if (count == 0) { /* always store in item->value */ + i = 0; + if ((item->value)[i] == NULL) { + list = New(alist(10, not_owned_by_alist)); + } else { + list = (alist *)(item->value)[i]; + } + } else { + /* Find empty place to store this directive */ + while ((item->value)[i] != NULL && i++ < count) { } + if (i >= count) { + scan_err4(lc, _("Too many %s directives. Max. is %d. line %d: %s\n"), + lc->str, count, lc->line_no, lc->line); + } + list = New(alist(10, not_owned_by_alist)); } - list = New(alist(10, not_owned_by_alist)); for (;;) { lex_get_token(lc, T_NAME); /* scan next item */ res = GetResWithName(item->code, lc->str); if (res == NULL) { - scan_err3(lc, _("Could not find config Resource \"%s\" referenced on line %d : %s\n"), - lc->str, lc->line_no, lc->line); + scan_err3(lc, _("Could not find config Resource \"%s\" referenced on line %d : %s\n"), + item->name, lc->line_no, lc->line); } + Dmsg5(900, "Append %p to alist %p size=%d i=%d %s\n", + res, list, list->size(), i, item->name); list->append(res); (item->value)[i] = (char *)list; - if (lc->ch != ',') { /* if no other item follows */ + if (lc->ch != ',') { /* if no other item follows */ break; /* get out */ } lex_get_token(lc, T_ALL); /* eat comma */ @@ -517,16 +528,16 @@ Dmsg2(900, "Code=%d name=%s\n", item->code, lc->str); res = GetResWithName(item->code, lc->str); if (res == NULL) { - scan_err3(lc, _("Missing config Resource \"%s\" referenced on line %d : %s\n"), + scan_err3(lc, _("Missing config Resource \"%s\" referenced on line %d : %s\n"), lc->str, lc->line_no, lc->line); } /* for each item not set, we copy the field from res */ #ifdef xxx for (int i=0; item->name;; i++, item++) { if (bit_is_set(i, res->item_present)) { - Dmsg2(900, "Item %d is present in %s\n", i, res->name); + Dmsg2(900, "Item %d is present in %s\n", i, res->name); } else { - Dmsg2(900, "Item %d is not present in %s\n", i, res->name); + Dmsg2(900, "Item %d is not present in %s\n", i, res->name); } } /* ***FIXME **** add code */ @@ -579,7 +590,7 @@ case T_IDENTIFIER: case T_UNQUOTED_STRING: if (!size_to_uint64(lc->str, lc->str_len, &uvalue)) { - scan_err1(lc, _("expected a size number, got: %s"), lc->str); + scan_err1(lc, _("expected a size number, got: %s"), lc->str); } *(uint64_t *)(item->value) = uvalue; break; @@ -617,7 +628,7 @@ } } if (!duration_to_utime(period, &utime)) { - scan_err1(lc, _("expected a time period, got: %s"), period); + scan_err1(lc, _("expected a time period, got: %s"), period); } *(utime_t *)(item->value) = utime; break; @@ -654,7 +665,7 @@ { int errstat; #ifdef TRACE_RES - Dmsg4(000, "LockRes %d,%d at %s:%d\n", res_locked, res_lock.w_active, + Pmsg4(000, "LockRes %d,%d at %s:%d\n", res_locked, res_lock.w_active, file, line); #endif if ((errstat=rwl_writelock(&res_lock)) != 0) { @@ -669,7 +680,7 @@ int errstat; res_locked--; #ifdef TRACE_RES - Dmsg4(000, "UnLockRes %d,%d at %s:%d\n", res_locked, res_lock.w_active, + Pmsg4(000, "UnLockRes %d,%d at %s:%d\n", res_locked, res_lock.w_active, file, line); #endif if ((errstat=rwl_writeunlock(&res_lock)) != 0) { @@ -758,14 +769,14 @@ return 0; } while ((token=lex_get_token(lc, T_ALL)) != T_EOF) { - Dmsg1(900, "parse got token=%s\n", lex_tok_to_str(token)); + Dmsg1(900, "parse got token=%s\n", lex_tok_to_str(token)); switch (state) { case p_none: if (token == T_EOL) { break; } if (token != T_IDENTIFIER) { - scan_err1(lc, _("Expected a Resource name identifier, got: %s"), lc->str); + scan_err1(lc, _("Expected a Resource name identifier, got: %s"), lc->str); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } @@ -778,7 +789,7 @@ break; } if (state == p_none) { - scan_err1(lc, _("expected resource name, got: %s"), lc->str); + scan_err1(lc, _("expected resource name, got: %s"), lc->str); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } @@ -790,7 +801,7 @@ break; case T_IDENTIFIER: if (level != 1) { - scan_err1(lc, _("not in resource definition: %s"), lc->str); + scan_err1(lc, _("not in resource definition: %s"), lc->str); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } @@ -800,14 +811,14 @@ * scan for = after the keyword */ if (!(items[i].flags & ITEM_NO_EQUALS)) { token = lex_get_token(lc, T_SKIP_EOL); - Dmsg1 (900, "in T_IDENT got token=%s\n", lex_tok_to_str(token)); + Dmsg1 (900, "in T_IDENT got token=%s\n", lex_tok_to_str(token)); if (token != T_EQUALS) { - scan_err1(lc, _("expected an equals, got: %s"), lc->str); + scan_err1(lc, _("expected an equals, got: %s"), lc->str); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } } - Dmsg1(900, "calling handler for %s\n", items[i].name); + Dmsg1(900, "calling handler for %s\n", items[i].name); /* Call item handler */ items[i].handler(lc, &items[i], i, pass); i = -1; @@ -815,10 +826,10 @@ } } if (i >= 0) { - Dmsg2(900, "level=%d id=%s\n", level, lc->str); - Dmsg1(900, "Keyword = %s\n", lc->str); - scan_err1(lc, _("Keyword \"%s\" not permitted in this resource.\n" - "Perhaps you left the trailing brace off of the previous resource."), lc->str); + Dmsg2(900, "level=%d id=%s\n", level, lc->str); + Dmsg1(900, "Keyword = %s\n", lc->str); + scan_err1(lc, _("Keyword \"%s\" not permitted in this resource.\n" + "Perhaps you left the trailing brace off of the previous resource."), lc->str); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } @@ -827,7 +838,7 @@ case T_EOB: level--; state = p_none; - Dmsg0(900, "T_EOB => define new resource\n"); + Dmsg0(900, "T_EOB => define new resource\n"); save_resource(res_type, items, pass); /* save resource */ break; @@ -835,20 +846,20 @@ break; default: - scan_err2(lc, _("unexpected token %d %s in resource definition"), + scan_err2(lc, _("unexpected token %d %s in resource definition"), token, lex_tok_to_str(token)); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } break; default: - scan_err1(lc, _("Unknown parser state %d\n"), state); + scan_err1(lc, _("Unknown parser state %d\n"), state); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } } if (state != p_none) { - scan_err0(lc, _("End of conf file reached with unclosed resource.")); + scan_err0(lc, _("End of conf file reached with unclosed resource.")); set_exit_on_error(1); /* Never reached if exit_on_error == 1 */ return 0; } Index: workq.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/workq.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- workq.c 21 Dec 2004 16:18:41 -0000 1.9 +++ workq.c 29 Jan 2005 22:39:02 -0000 1.10 @@ -149,7 +149,7 @@ workq_ele_t *item; pthread_t id; - Dmsg0(400, "workq_add\n"); + Dmsg0(1400, "workq_add\n"); if (wq->valid != WORKQ_VALID) { return EINVAL; } @@ -164,7 +164,7 @@ return stat; } - Dmsg0(400, "add item to queue\n"); + Dmsg0(1400, "add item to queue\n"); if (priority) { /* Add to head of queue */ if (wq->first == NULL) { @@ -186,13 +186,13 @@ /* if any threads are idle, wake one */ if (wq->idle_workers > 0) { - Dmsg0(400, "Signal worker\n"); + Dmsg0(1400, "Signal worker\n"); if ((stat = pthread_cond_signal(&wq->work)) != 0) { pthread_mutex_unlock(&wq->mutex); return stat; } } else if (wq->num_workers < wq->max_workers) { - Dmsg0(400, "Create worker thread\n"); + Dmsg0(1400, "Create worker thread\n"); /* No idle threads so create a new one */ set_thread_concurrency(wq->max_workers + 1); if ((stat = pthread_create(&id, &wq->attr, workq_server, (void *)wq)) != 0) { @@ -202,7 +202,7 @@ wq->num_workers++; } pthread_mutex_unlock(&wq->mutex); - Dmsg0(400, "Return workq_add\n"); + Dmsg0(1400, "Return workq_add\n"); /* Return work_item if requested */ if (work_item) { *work_item = item; @@ -225,7 +225,7 @@ pthread_t id; workq_ele_t *item, *prev; - Dmsg0(400, "workq_remove\n"); + Dmsg0(1400, "workq_remove\n"); if (wq->valid != WORKQ_VALID) { return EINVAL; } @@ -257,13 +257,13 @@ /* if any threads are idle, wake one */ if (wq->idle_workers > 0) { - Dmsg0(400, "Signal worker\n"); + Dmsg0(1400, "Signal worker\n"); if ((stat = pthread_cond_signal(&wq->work)) != 0) { pthread_mutex_unlock(&wq->mutex); return stat; } } else { - Dmsg0(400, "Create worker thread\n"); + Dmsg0(1400, "Create worker thread\n"); /* No idle threads so create a new one */ set_thread_concurrency(wq->max_workers + 1); if ((stat = pthread_create(&id, &wq->attr, workq_server, (void *)wq)) != 0) { @@ -273,7 +273,7 @@ wq->num_workers++; } pthread_mutex_unlock(&wq->mutex); - Dmsg0(400, "Return workq_remove\n"); + Dmsg0(1400, "Return workq_remove\n"); return stat; } @@ -290,7 +290,7 @@ workq_ele_t *we; int stat, timedout; - Dmsg0(400, "Start workq_server\n"); + Dmsg0(1400, "Start workq_server\n"); if ((stat = pthread_mutex_lock(&wq->mutex)) != 0) { return NULL; } @@ -299,9 +299,9 @@ struct timeval tv; struct timezone tz; - Dmsg0(400, "Top of for loop\n"); + Dmsg0(1400, "Top of for loop\n"); timedout = 0; - Dmsg0(400, "gettimeofday()\n"); + Dmsg0(1400, "gettimeofday()\n"); gettimeofday(&tv, &tz); timeout.tv_nsec = 0; timeout.tv_sec = tv.tv_sec + 2; @@ -310,7 +310,7 @@ /* * Wait 2 seconds, then if no more work, exit */ - Dmsg0(400, "pthread_cond_timedwait()\n"); + Dmsg0(1400, "pthread_cond_timedwait()\n"); #ifdef xxxxxxxxxxxxxxxx_was_HAVE_CYGWIN /* CYGWIN dies with a page fault the second * time that pthread_cond_timedwait() is called @@ -321,13 +321,13 @@ #else stat = pthread_cond_timedwait(&wq->work, &wq->mutex, &timeout); #endif - Dmsg1(400, "timedwait=%d\n", stat); + Dmsg1(1400, "timedwait=%d\n", stat); if (stat == ETIMEDOUT) { timedout = 1; break; } else if (stat != 0) { - /* This shouldn't happen */ - Dmsg0(400, "This shouldn't happen\n"); + /* This shouldn't happen */ + Dmsg0(1400, "This shouldn't happen\n"); wq->num_workers--; pthread_mutex_unlock(&wq->mutex); return NULL; @@ -342,16 +342,16 @@ if ((stat = pthread_mutex_unlock(&wq->mutex)) != 0) { return NULL; } - /* Call user's routine here */ - Dmsg0(400, "Calling user engine.\n"); + /* Call user's routine here */ + Dmsg0(1400, "Calling user engine.\n"); wq->engine(we->data); - Dmsg0(400, "Back from user engine.\n"); + Dmsg0(1400, "Back from user engine.\n"); free(we); /* release work entry */ - Dmsg0(400, "relock mutex\n"); + Dmsg0(1400, "relock mutex\n"); if ((stat = pthread_mutex_lock(&wq->mutex)) != 0) { return NULL; } - Dmsg0(400, "Done lock mutex\n"); + Dmsg0(1400, "Done lock mutex\n"); } /* * If no more work request, and we are asked to quit, then do it @@ -359,31 +359,31 @@ if (wq->first == NULL && wq->quit) { wq->num_workers--; if (wq->num_workers == 0) { - Dmsg0(400, "Wake up destroy routine\n"); + Dmsg0(1400, "Wake up destroy routine\n"); /* Wake up destroy routine if he is waiting */ pthread_cond_broadcast(&wq->work); } - Dmsg0(400, "Unlock mutex\n"); + Dmsg0(1400, "Unlock mutex\n"); pthread_mutex_unlock(&wq->mutex); - Dmsg0(400, "Return from workq_server\n"); + Dmsg0(1400, "Return from workq_server\n"); return NULL; } - Dmsg0(400, "Check for work request\n"); + Dmsg0(1400, "Check for work request\n"); /* * If no more work requests, and we waited long enough, quit */ - Dmsg1(400, "wq->first==NULL = %d\n", wq->first==NULL); - Dmsg1(400, "timedout=%d\n", timedout); + Dmsg1(1400, "wq->first==NULL = %d\n", wq->first==NULL); + Dmsg1(1400, "timedout=%d\n", timedout); if (wq->first == NULL && timedout) { - Dmsg0(400, "break big loop\n"); + Dmsg0(1400, "break big loop\n"); wq->num_workers--; break; } - Dmsg0(400, "Loop again\n"); + Dmsg0(1400, "Loop again\n"); } /* end of big for loop */ - Dmsg0(400, "unlock mutex\n"); + Dmsg0(1400, "unlock mutex\n"); pthread_mutex_unlock(&wq->mutex); - Dmsg0(400, "End workq_server\n"); + Dmsg0(1400, "End workq_server\n"); return NULL; } Index: alist.h =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/alist.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- alist.h 21 Dec 2004 16:18:38 -0000 1.13 +++ alist.h 29 Jan 2005 22:39:01 -0000 1.14 @@ -3,7 +3,7 @@ */ /* - Copyright (C) 2003-2004 Kern Sibbald and John Walker + Copyright (C) 2003-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 @@ -32,11 +32,13 @@ * Loop var through each member of list */ #define foreach_alist(var, list) \ - for((*((void **)&(var))=(void*)((list)->first())); (var); (*((void **)&(var))=(void*)((list)->next()))) + for((*((void **)&(var))=(void*)((list)->first())); \ + (var); \ + (*((void **)&(var))=(void*)((list)->next()))) #ifdef the_easy_way #define foreach_alist(var, list) \ - for((void*(var))=(list)->first(); (var); (void *(var))=(list)->next(var)); ) + for((void*(var))=(list)->first(); (var); (void *(var))=(list)->next(var)); ) #endif Index: htable.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/htable.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- htable.c 21 Dec 2004 16:18:39 -0000 1.8 +++ htable.c 29 Jan 2005 22:39:01 -0000 1.9 @@ -8,10 +8,10 @@ * the randomness. In this program, the hash table can grow when * it gets too full, so the table size here is a binary number. The * hashing is provided using an idea from Tcl where the initial - * hash code is then "randomized" using a simple calculation from + * hash code is "randomized" using a simple calculation from * a random number generator that multiplies by a big number * (I multiply by a prime number, while Tcl did not) - * then shifts the results down and does the binary division + * then shifts the result down and does the binary division * by masking. Increasing the size of the hash table is simple. * Just create a new larger table, walk the old table and * re-hash insert each entry into the new table. @@ -23,7 +23,7 @@ * */ /* - Copyright (C) 2003-2004 Kern Sibbald and John Walker + Copyright (C) 2003-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 @@ -90,33 +90,30 @@ walk_index = 0; } -#ifdef xxx -void * htable::operator new(size_t) -{ - return malloc(sizeof(htable)); -} - -void htable::operator delete(void *tbl) -{ - ((htable *)tbl)->destroy(); - free(tbl); -} -#endif - uint32_t htable::size() { return num_items; } +/* + * Take each hash link and walk down the chain of items + * that hash there counting them (i.e. the hits), + * then report that number. + * Obiously, the more hits in a chain, the more time + * it takes to reference them. Empty chains are not so + * hot either -- as it means unused or wasted space. + */ +#define MAX_COUNT 20 void htable::stats() { - int count[10]; + int hits[MAX_COUNT]; int max = 0; int i, j; hlink *p; - printf("\n\nNumItems=%d\nBuckets=%d\n", num_items, buckets); - for (i=0; i<10; i++) { - count[i] = 0; + printf("\n\nNumItems=%d\nTotal buckets=%d\n", num_items, buckets); + printf("Hits/bucket: buckets\n"); + for (i=0; i < MAX_COUNT; i++) { + hits[i] = 0; } for (i=0; i<(int)buckets; i++) { p = table[i]; @@ -128,14 +125,14 @@ if (j > max) { max = j; } - if (j < 10) { - count[j]++; + if (j < MAX_COUNT) { + hits[j]++; } } - for (i=0; i<10; i++) { - printf("%2d: %d\n",i, count[i]); + for (i=0; i < MAX_COUNT; i++) { + printf("%2d: %d\n",i, hits[i]); } - printf("max = %d\n", max); + printf("max hits in a bucket = %d\n", max); } void htable::grow_table() @@ -217,7 +214,7 @@ for (hlink *hp=table[index]; hp; hp=(hlink *)hp->next) { // Dmsg2(100, "hp=0x%x key=%s\n", (long)hp, hp->key); if (hash == hp->hash && strcmp(key, hp->key) == 0) { - Dmsg1(100, "lookup return %x\n", ((char *)hp)-loffset); + Dmsg1(100, "lookup return %x\n", ((char *)hp)-loffset); return ((char *)hp)-loffset; } } @@ -233,7 +230,7 @@ while (!walkptr && walk_index < buckets) { walkptr = table[walk_index++]; if (walkptr) { - Dmsg3(100, "new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr, + Dmsg3(100, "new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr, (unsigned)(walkptr->next), walk_index-1); } } @@ -254,7 +251,7 @@ while (!walkptr && walk_index < buckets) { walkptr = table[walk_index++]; /* go to next bucket */ if (walkptr) { - Dmsg3(100, "first new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr, + Dmsg3(100, "first new walkptr=0x%x next=0x%x inx=%d\n", (unsigned)walkptr, (unsigned)(walkptr->next), walk_index-1); } } Index: daemon.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/daemon.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- daemon.c 21 Dec 2004 16:18:39 -0000 1.15 +++ daemon.c 29 Jan 2005 22:39:01 -0000 1.16 @@ -53,7 +53,7 @@ * Become a daemon. */ - Dmsg0(200, "Enter daemon_start\n"); + Dmsg0(900, "Enter daemon_start\n"); if ( (cpid = fork() ) < 0) Emsg1(M_ABORT, 0, "Cannot fork to become daemon: %s\n", strerror(errno)); else if (cpid > 0) @@ -106,5 +106,5 @@ } #endif /* HAVE_CYGWIN */ - Dmsg0(200, "Exit daemon_start\n"); + Dmsg0(900, "Exit daemon_start\n"); } Index: scan.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/scan.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- scan.c 21 Dec 2004 16:18:40 -0000 1.12 +++ scan.c 29 Jan 2005 22:39:02 -0000 1.13 @@ -135,7 +135,7 @@ for (p=*s; *p && B_ISSPACE(*p); ) { p++; } - Dmsg1(400, "Next arg=%s\n", p); + Dmsg1(900, "Next arg=%s\n", p); for (n = q = p; *p ; ) { if (*p == '\\') { p++; @@ -164,7 +164,7 @@ } *q = 0; *s = p; - Dmsg2(400, "End arg=%s next=%s\n", n, p); + Dmsg2(900, "End arg=%s next=%s\n", n, p); return n; } @@ -213,9 +213,9 @@ if (p) { *p++ = 0; /* terminate keyword and point to value */ /* Unquote quoted values */ - if (*p == '"') { - for (n = q = ++p; *p && *p != '"'; ) { - if (*p == '\\') { + if (*p == '"') { + for (n = q = ++p; *p && *p != '"'; ) { + if (*p == '\\') { p++; } *q++ = *p++; @@ -314,11 +314,11 @@ // Dmsg1(000, "Got %% nxt=%c\n", *fmt); switch_top: switch (*fmt++) { - case 'u': - case 'd': + case 'u': + case 'd': value = 0; while (B_ISDIGIT(*buf)) { - value = B_TIMES10(value) + *buf++ - '0'; + value = B_TIMES10(value) + *buf++ - '0'; } vp = (void *)va_arg(ap, void *); // Dmsg2(000, "val=%lld at 0x%lx\n", value, (long unsigned)vp); @@ -332,28 +332,28 @@ count++; l = 0; break; - case 'l': + case 'l': // Dmsg0(000, "got l\n"); l = 1; - if (*fmt == 'l') { + if (*fmt == 'l') { l++; fmt++; } - if (*fmt == 'd' || *fmt == 'u') { + if (*fmt == 'd' || *fmt == 'u') { goto switch_top; } // Dmsg1(000, "fmt=%c !=d,u\n", *fmt); error = true; break; - case 'q': + case 'q': l = 2; - if (*fmt == 'd' || *fmt == 'u') { + if (*fmt == 'd' || *fmt == 'u') { goto switch_top; } // Dmsg1(000, "fmt=%c !=d,u\n", *fmt); error = true; break; - case 's': + case 's': // Dmsg1(000, "Store string max_len=%d\n", max_len); cp = (char *)va_arg(ap, char *); while (*buf && !B_ISSPACE(*buf) && max_len-- > 0) { @@ -363,13 +363,13 @@ count++; max_len = BIG; break; - case 'c': + case 'c': cp = (char *)va_arg(ap, char *); *cp = *buf++; count++; break; - case '%': - if (*buf++ != '%') { + case '%': + if (*buf++ != '%') { error = true; } break; @@ -377,10 +377,10 @@ fmt--; max_len = 0; while (B_ISDIGIT(*fmt)) { - max_len = B_TIMES10(max_len) + *fmt++ - '0'; + max_len = B_TIMES10(max_len) + *fmt++ - '0'; } // Dmsg1(000, "Default max_len=%d\n", max_len); - if (*fmt == 's') { + if (*fmt == 's') { goto switch_top; } // Dmsg1(000, "Default c=%c\n", *fmt); Index: protos.h =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/protos.h,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- protos.h 8 Jan 2005 14:44:23 -0000 1.95 +++ protos.h 29 Jan 2005 22:39:01 -0000 1.96 @@ -4,7 +4,7 @@ * Version $Id$ */ /* - Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker + 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 @@ -73,11 +73,11 @@ int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need); BSOCK * bnet_connect (JCR *jcr, int retry_interval, - int max_retry_time, const char *name, char *host, char *service, - int port, int verbose); + int max_retry_time, const char *name, char *host, char *service, + int port, int verbose); void bnet_close (BSOCK *bsock); BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, const char *ip, - int port, struct sockaddr *client_addr); + int port, struct sockaddr *client_addr); BSOCK * dup_bsock (BSOCK *bsock); void term_bsock (BSOCK *bsock); const char *bnet_strerror (BSOCK *bsock); @@ -102,7 +102,7 @@ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need); int cram_md5_auth(BSOCK *bs, char *password, int ssl_need); void hmac_md5(uint8_t* text, int text_len, uint8_t* key, - int key_len, uint8_t *hmac); + int key_len, uint8_t *hmac); /* crc32.c */ @@ -117,6 +117,7 @@ char * edit_uint64_with_commas (uint64_t val, char *buf); char * add_commas (char *val, char *buf); char * edit_uint64 (uint64_t val, char *buf); +char * edit_int64 (int64_t val, char *buf); int duration_to_utime (char *str, utime_t *value); int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); char *edit_utime (utime_t val, char *buf, int buf_len); @@ -160,7 +161,7 @@ /* bnet_server.c */ void bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq, - void *handle_client_request(void *bsock)); + void *handle_client_request(void *bsock)); void bnet_stop_thread_server(pthread_t tid); void bnet_server (int port, void handle_client_request(BSOCK *bsock)); int net_connect (int port); @@ -191,9 +192,9 @@ int fstrsch (const char *a, const char *b); char *next_arg(char **s); int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, - char **argk, char **argv, int max_args); + char **argk, char **argv, int max_args); void split_path_and_filename(const char *fname, POOLMEM **path, - int *pnl, POOLMEM **file, int *fnl); + int *pnl, POOLMEM **file, int *fnl); int bsscanf(const char *buf, const char *fmt, ...); Index: edit.c =================================================================== RCS file: /cvsroot/bacula/bacula/src/lib/edit.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- edit.c 21 Dec 2004 16:18:39 -0000 1.21 +++ edit.c 29 Jan 2005 22:39:01 -0000 1.22 @@ -7,7 +7,7 @@ */ /* - Copyright (C) 2000-2004 Kern Sibbald and John Walker + 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 @@ -94,7 +94,7 @@ mbuf[i--] = '0'; } else { while (val != 0) { - mbuf[i--] = "0123456789"[val%10]; + mbuf[i--] = "0123456789"[val%10]; val /= 10; } } @@ -119,7 +119,7 @@ mbuf[i--] = '0'; } else { while (val != 0) { - mbuf[i--] = "0123456789"[val%10]; + mbuf[i--] = "0123456789"[val%10]; val /= 10; } } @@ -127,6 +127,35 @@ return buf; } +char *edit_int64(int64_t val, char *buf) +{ + /* + * Replacement for sprintf(buf, "%" llu, val) + */ + char mbuf[50]; + bool negative = false; + mbuf[sizeof(mbuf)-1] = 0; + int i = sizeof(mbuf)-2; /* edit backward */ + if (val == 0) { + mbuf[i--] = '0'; + } else { + if (val < 0) { + negative = true; + val = -val; + } + while (val != 0) { + mbuf[i--] = "0123456789"[val%10]; + val /= 10; + } + } + if (negative) { + mbuf[i--] = '-'; + } + strcpy(buf, &mbuf[i+1]); + return buf; +} + + /* * Given a string "str", separate the integer part into * str, and the modifier into mod. @@ -206,7 +235,7 @@ * Baculas. */ static const char *mod[] = {"n", "seconds", "months", "minutes", - "hours", "days", "weeks", "quarters", "years", NULL}; + "hours", "days", "weeks", "quarters", "years", NULL}; static const int32_t mult[] = {60, 1, 60*60*24*30, 60, 60*60, 60*60*24, 60*60*24*7, 60*60*24*91, 60*60*24*365}; @@ -256,7 +285,7 @@ times = (uint32_t)(val / mult[i]); if (times > 0) { val = val - (utime_t)times * mult[i]; - bsnprintf(mybuf, sizeof(mybuf), "%d %s%s ", times, mod[i], times>1?"s":""); + bsnprintf(mybuf, sizeof(mybuf), "%d %s%s ", times, mod[i], times>1?"s":""); bstrncat(buf, mybuf, buf_len); } } @@ -372,20 +401,20 @@ continue; } if (msg) { - Mmsg(msg, _("Illegal character \"%c\" in name.\n"), *p); + Mmsg(msg, _("Illegal character \"%c\" in name.\n"), *p); } return false; } len = strlen(name); if (len >= MAX_NAME_LENGTH) { if (msg) { - Mmsg(msg, _("Name too long.\n")); + Mmsg(msg,... [truncated message content] |