int my_sqlite_query(B_DB *mdb, const char *cmd);
void my_sqlite_field_seek(B_DB *mdb, int field);
SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
-extern char* my_sqlite_batch_lock_query;
-extern char* my_sqlite_batch_unlock_query;
-extern char* my_sqlite_batch_fill_filename_query;
-extern char* my_sqlite_batch_fill_path_query;
+extern const char* my_sqlite_batch_lock_query;
+extern const char* my_sqlite_batch_unlock_query;
+extern const char* my_sqlite_batch_fill_filename_query;
+extern const char* my_sqlite_batch_fill_path_query;
#else
int my_sqlite_query(B_DB *mdb, const char *cmd);
void my_sqlite_field_seek(B_DB *mdb, int field);
SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
-extern char* my_sqlite_batch_lock_query;
-extern char* my_sqlite_batch_unlock_query;
-extern char* my_sqlite_batch_fill_filename_query;
-extern char* my_sqlite_batch_fill_path_query;
+extern const char* my_sqlite_batch_lock_query;
+extern const char* my_sqlite_batch_unlock_query;
+extern const char* my_sqlite_batch_fill_filename_query;
+extern const char* my_sqlite_batch_fill_path_query;
#else
#define sql_batch_fill_path_query my_mysql_batch_fill_path_query
-extern char* my_mysql_batch_lock_path_query;
-extern char* my_mysql_batch_lock_filename_query;
-extern char* my_mysql_batch_unlock_tables_query;
-extern char* my_mysql_batch_fill_filename_query;
-extern char* my_mysql_batch_fill_path_query;
+extern const char* my_mysql_batch_lock_path_query;
+extern const char* my_mysql_batch_lock_filename_query;
+extern const char* my_mysql_batch_unlock_tables_query;
+extern const char* my_mysql_batch_fill_filename_query;
+extern constchar* my_mysql_batch_fill_path_query;
extern void my_mysql_free_result(B_DB *mdb);
#else
int my_postgresql_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
char *my_postgresql_copy_escape(char *dest, char *src, size_t len);
-extern char* my_pg_batch_lock_path_query;
-extern char* my_pg_batch_lock_filename_query;
-extern char* my_pg_batch_unlock_tables_query;
-extern char* my_pg_batch_fill_filename_query;
-extern char* my_pg_batch_fill_path_query;
+extern const char* my_pg_batch_lock_path_query;
+extern const char* my_pg_batch_lock_filename_query;
+extern const char* my_pg_batch_unlock_tables_query;
+extern const char* my_pg_batch_fill_filename_query;
+extern const char* my_pg_batch_fill_path_query;
/* "Generic" names for easier conversion */
#define sql_store_result(x) ((x)->result)
}
#ifdef HAVE_BATCH_FILE_INSERT
-char *my_mysql_batch_lock_path_query = "LOCK TABLES Path write,"
- "batch write,"
- "Path as p write";
-
-
-char *my_mysql_batch_lock_filename_query = "LOCK TABLES Filename write,"
- "batch write,"
- "Filename as f write";
-
-char *my_mysql_batch_unlock_tables_query = "UNLOCK TABLES";
-
-char *my_mysql_batch_fill_path_query = "INSERT INTO Path (Path) "
- "SELECT a.Path FROM "
- "(SELECT DISTINCT Path "
- "FROM batch) AS a "
- "WHERE NOT EXISTS "
- "(SELECT Path "
- "FROM Path AS p "
- "WHERE p.Path = a.Path)";
-
-char *my_mysql_batch_fill_filename_query = "INSERT INTO Filename (Name) "
- "SELECT a.Name FROM "
- "(SELECT DISTINCT Name "
- "FROM batch) AS a "
- "WHERE NOT EXISTS "
- "(SELECT Name "
- "FROM Filename AS f "
- "WHERE f.Name = a.Name)";
+const char *my_mysql_batch_lock_path_query =
+ "LOCK TABLES Path write, batch write, Path as p write";
+
+
+const char *my_mysql_batch_lock_filename_query =
+ "LOCK TABLES Filename write, batch write, Filename as f write";
+
+const char *my_mysql_batch_unlock_tables_query = "UNLOCK TABLES";
+
+const char *my_mysql_batch_fill_path_query =
+ "INSERT INTO Path (Path) "
+ "SELECT a.Path FROM "
+ "(SELECT DISTINCT Path FROM batch) AS a WHERE NOT EXISTS "
+ "(SELECT Path FROM Path AS p WHERE p.Path = a.Path)";
+
+const char *my_mysql_batch_fill_filename_query =
+ "INSERT INTO Filename (Name) "
+ "SELECT a.Name FROM "
+ "(SELECT DISTINCT Name FROM batch) AS a WHERE NOT EXISTS "
+ "(SELECT Name FROM Filename AS f WHERE f.Name = a.Name)";
#endif /* HAVE_BATCH_FILE_INSERT */
#endif /* HAVE_MYSQL */
}
#ifdef HAVE_BATCH_FILE_INSERT
-char *my_pg_batch_lock_path_query = "BEGIN; LOCK TABLE Path IN SHARE ROW EXCLUSIVE MODE";
+const char *my_pg_batch_lock_path_query =
+ "BEGIN; LOCK TABLE Path IN SHARE ROW EXCLUSIVE MODE";
-char *my_pg_batch_lock_filename_query = "BEGIN; LOCK TABLE Filename IN SHARE ROW EXCLUSIVE MODE";
+const char *my_pg_batch_lock_filename_query =
+ "BEGIN; LOCK TABLE Filename IN SHARE ROW EXCLUSIVE MODE";
-char *my_pg_batch_unlock_tables_query = "COMMIT";
+const char *my_pg_batch_unlock_tables_query = "COMMIT";
-char *my_pg_batch_fill_path_query = "INSERT INTO Path (Path) "
- "SELECT a.Path FROM "
- "(SELECT DISTINCT Path FROM batch) AS a "
- "WHERE NOT EXISTS (SELECT Path FROM Path WHERE Path = a.Path) ";
+const char *my_pg_batch_fill_path_query =
+ "INSERT INTO Path (Path) "
+ "SELECT a.Path FROM "
+ "(SELECT DISTINCT Path FROM batch) AS a "
+ "WHERE NOT EXISTS (SELECT Path FROM Path WHERE Path = a.Path) ";
-char *my_pg_batch_fill_filename_query = "INSERT INTO Filename (Name) "
- "SELECT a.Name FROM "
- "(SELECT DISTINCT Name FROM batch) as a "
- "WHERE NOT EXISTS "
- "(SELECT Name FROM Filename WHERE Name = a.Name)";
+const char *my_pg_batch_fill_filename_query =
+ "INSERT INTO Filename (Name) "
+ "SELECT a.Name FROM "
+ "(SELECT DISTINCT Name FROM batch) as a "
+ "WHERE NOT EXISTS "
+ "(SELECT Name FROM Filename WHERE Name = a.Name)";
#endif /* HAVE_BATCH_FILE_INSERT */
#endif /* HAVE_POSTGRESQL */
bool my_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
{
size_t len;
- char *digest;
+ const char *digest;
char ed1[50];
mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->fnl*2+1);
*/
bool db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
{
- int retry = 0;
Dmsg1(dbglevel, "Fname=%s\n", ar->fname);
Dmsg0(dbglevel, "put_file_into_catalog\n");
}
#ifdef HAVE_BATCH_FILE_INSERT
-char *my_sqlite_batch_lock_query = "BEGIN";
-char *my_sqlite_batch_unlock_query = "COMMIT";
-char *my_sqlite_batch_fill_path_query = "INSERT INTO Path (Path) "
- " SELECT DISTINCT Path FROM batch "
- " EXCEPT SELECT Path FROM Path ";
-
-char *my_sqlite_batch_fill_filename_query = "INSERT INTO Filename (Name) "
- " SELECT DISTINCT Name FROM batch "
- " EXCEPT SELECT Name FROM Filename ";
+const char *my_sqlite_batch_lock_query = "BEGIN";
+const char *my_sqlite_batch_unlock_query = "COMMIT";
+
+const char *my_sqlite_batch_fill_path_query =
+ "INSERT INTO Path (Path)"
+ " SELECT DISTINCT Path FROM batch"
+ " EXCEPT SELECT Path FROM Path";
+
+const char *my_sqlite_batch_fill_filename_query =
+ "INSERT INTO Filename (Name)"
+ " SELECT DISTINCT Name FROM batch "
+ " EXCEPT SELECT Name FROM Filename";
#endif /* HAVE_BATCH_FILE_INSERT */
Dmsg0(1000, "Begin status jcr loop.\n");
len = Mmsg(msg, _("\nRunning Jobs:\n"));
sendit(msg.c_str(), len, arg);
- char *vss = "";
+ const char *vss = "";
#ifdef WIN32_VSS
if (g_pVSSClient && g_pVSSClient->IsInitialized()) {
vss = "VSS ";
/* escape sep char and \
* dest must be long enough (src*2+1)
* return end of the string */
-char *bregexp_escape_string(char *dest, char *src, char sep)
+char *bregexp_escape_string(char *dest, const char *src, const char sep)
{
char *ret = dest;
while (*src)
return ret;
}
-static char regexp_sep = '!';
-static char *str_strip_prefix = "!%s!!i";
-static char *str_add_prefix = "!^!%s!";
-static char *str_add_suffix = "!([^/])$!$1%s!";
+static const char regexp_sep = '!';
+static const char *str_strip_prefix = "!%s!!i";
+static const char *str_add_prefix = "!^!%s!";
+static const char *str_add_suffix = "!([^/])$!$1%s!";
int bregexp_get_build_where_size(char *strip_prefix,
char *add_prefix,
*/
class BREGEXP {
public:
- POOLMEM *result; /* match result */
- bool success; /* match is ok */
+ POOLMEM *result; /* match result */
+ bool success; /* match is ok */
char *replace(const char *fname); /* return this.result */
void debug();
/* private */
- POOLMEM *expr; /* search epression */
- POOLMEM *subst; /* substitution */
- regex_t preg; /* regex_t result of regcomp() */
+ POOLMEM *expr; /* search epression */
+ POOLMEM *subst; /* substitution */
+ regex_t preg; /* regex_t result of regcomp() */
regmatch_t regs[BREG_NREGS]; /* contains match */
- char *eor; /* end of regexp in expr */
+ char *eor; /* end of regexp in expr */
char *return_fname(const char *fname, int len); /* return fname as result */
char *edit_subst(const char *fname, regmatch_t regs[]);
/* get regexp size */
int bregexp_get_build_where_size(char *strip_prefix,
- char *add_prefix,
- char *add_suffix);
+ char *add_prefix,
+ char *add_suffix);
/* get a bregexp string from user arguments
* you must allocate it with bregexp_get_build_where_size();
*/
char *bregexp_build_where(char *dest, int str_size,
- char *strip_prefix,
+ char *strip_prefix,
char *add_prefix,
char *add_suffix);
/* escape a string to regexp format (sep and \)
* dest must be long enough (dest = 2*src + 1)
*/
-char *bregexp_escape_string(char *dest, char *src, char sep);
+char *bregexp_escape_string(char *dest, const char *src, const char sep);
#endif /* __BREG_H_ */
int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args);
static int32_t fmtstr(char *buffer, int32_t currlen, int32_t maxlen,
- char *value, int flags, int min, int max);
+ const char *value, int flags, int min, int max);
static int32_t fmtint(char *buffer, int32_t currlen, int32_t maxlen,
int64_t value, int base, int min, int max, int flags);
}
static int32_t fmtstr(char *buffer, int32_t currlen, int32_t maxlen,
- char *value, int flags, int min, int max)
+ const char *value, int flags, int min, int max)
{
int padlen, strln; /* amount to pad */
int cnt = 0;
{
int commas = 0;
char *c, mbuf[50];
- char *suffix[] =
+ const char *suffix[] =
{ "", "K", "M", "G", "T", "P", "E", "Z", "Y", "FIX ME" };
int suffixes = sizeof(suffix) / sizeof(*suffix);
#ifdef DEBUG
void b_free_jcr(const char *file, int line, JCR *jcr)
{
- Dmsg3(dbglvl, "Enter free_jcr 0x%x from %s:%d\n", jcr, file, line);
+ Dmsg3(dbglvl, "Enter free_jcr jid=%u from %s:%d\n", jcr->JobId, file, line);
#else
void free_jcr(JCR *jcr)
{
- Dmsg2(dbglvl, "Enter free_jcr 0x%x job=%d\n", jcr, jcr->JobId);
+ Dmsg3(dbglvl, "Enter free_jcr jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
#endif
Emsg2(M_ERROR, 0, _("JCR use_count=%d JobId=%d\n"),
jcr->use_count(), jcr->JobId);
}
- Dmsg3(dbglvl, "Dec free_jcr 0x%x use_count=%d jobid=%d\n", jcr, jcr->use_count(), jcr->JobId);
+ if (jcr->JobId > 0) {
+ Dmsg3(dbglvl, "Dec free_jcr jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
+ }
if (jcr->use_count() > 0) { /* if in use */
unlock_jcr_chain();
- Dmsg3(dbglvl, "free_jcr 0x%x job=%d use_count=%d\n", jcr, jcr->JobId, jcr->use_count());
return;
}
-
+ if (jcr->JobId > 0) {
+ Dmsg3(dbglvl, "remove jcr jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
+ }
remove_jcr(jcr); /* remove Jcr from chain */
unlock_jcr_chain();
foreach_jcr(jcr) {
if (jcr->JobId == JobId) {
jcr->inc_use_count();
- Dmsg2(dbglvl, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count());
+ Dmsg3(dbglvl, "Inc get_jcr jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
break;
}
}
if (jcr->VolSessionId == SessionId &&
jcr->VolSessionTime == SessionTime) {
jcr->inc_use_count();
- Dmsg2(dbglvl, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count());
+ Dmsg3(dbglvl, "Inc get_jcr jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
break;
}
}
foreach_jcr(jcr) {
if (strncmp(Job, jcr->Job, len) == 0) {
jcr->inc_use_count();
- Dmsg2(dbglvl, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count());
+ Dmsg3(dbglvl, "Inc get_jcr jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
break;
}
}
foreach_jcr(jcr) {
if (strcmp(jcr->Job, Job) == 0) {
jcr->inc_use_count();
- Dmsg2(dbglvl, "Inc get_jcr 0x%x use_count=%d\n", jcr, jcr->use_count());
+ Dmsg3(dbglvl, "Inc get_jcr jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
break;
}
}
jcr = (JCR *)jcrs->first();
if (jcr) {
jcr->inc_use_count();
- Dmsg3(dbglvl, "Inc jcr_walk_start 0x%x job=%d use_count=%d\n", jcr, jcr->JobId, jcr->use_count());
+ if (jcr->JobId > 0) {
+ Dmsg3(dbglvl, "Inc walk_start jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
+ }
}
unlock_jcr_chain();
return jcr;
jcr = (JCR *)jcrs->next(prev_jcr);
if (jcr) {
jcr->inc_use_count();
- Dmsg3(dbglvl, "Inc jcr_walk_next 0x%x job=%d use_count=%d\n", jcr, jcr->JobId, jcr->use_count());
+ if (jcr->JobId > 0) {
+ Dmsg3(dbglvl, "Inc walk_next jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
+ }
}
unlock_jcr_chain();
if (prev_jcr) {
void jcr_walk_end(JCR *jcr)
{
if (jcr) {
+ if (jcr->JobId > 0) {
+ Dmsg3(dbglvl, "Free walk_end jid=%u use_count=%d Job=%s\n",
+ jcr->JobId, jcr->use_count(), jcr->Job);
+ }
free_jcr(jcr);
}
}
int len, dtlen;
MSGS *msgs;
BPIPE *bpipe;
- char *mode;
+ const char *mode;
Dmsg2(850, "Enter dispatch_msg type=%d msg=%s", type, msg);
/* Resource routines */
-RES *GetResWithName(int rcode, char *name);
+RES *GetResWithName(int rcode, const char *name);
RES *GetNextRes(int rcode, RES *res);
void b_LockRes(const char *file, int line);
void b_UnlockRes(const char *file, int line);
* Return resource of type rcode that matches name
*/
RES *
-GetResWithName(int rcode, char *name)
+GetResWithName(int rcode, const char *name)
{
RES *res;
int rindex = rcode - r_first;
/* Forward referenced functions */
void set_os_device_parameters(DCR *dcr);
static bool dev_get_os_pos(DEVICE *dev, struct mtget *mt_stat);
-static char *mode_to_str(int mode);
+static const char *mode_to_str(int mode);
/*
* Allocate and initialize the DEVICE structure
};
-static char *mode_to_str(int mode)
+static const char *mode_to_str(int mode)
{
static char buf[100];
if (mode < 1 || mode > 4) {
* expires.
*/
P(mutex);
- for ( ; !job_canceled(jcr); ) {
+ while ( !jcr->authenticated && !job_canceled(jcr) ) {
errstat = pthread_cond_timedwait(&jcr->job_start_wait, &mutex, &timeout);
- if (errstat == 0 || errstat == ETIMEDOUT) {
+ if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) {
break;
}
}
main (int argc, char *const *argv)
{
FF_PKT *ff;
- char *configfile = "bacula-dir.conf";
- char *fileset_name = "Windows-Full-Set";
+ const char *configfile = "bacula-dir.conf";
+ const char *fileset_name = "Windows-Full-Set";
int ch, hard_links;
OSDependentInit();
*/
#undef VERSION
-#define VERSION "2.3.5"
-#define BDATE "26 September 2007"
-#define LSMDATE "26Sep07"
+#define VERSION "2.3.6"
+#define BDATE "27 September 2007"
+#define LSMDATE "27Sep07"
#define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n"
#define BYEAR "2007" /* year for copyright messages in progs */
General:
27Sep07
+kes Fix FD->SD authorization failure, which was due to spurious
+ wakeups from a pthread_cond_timedwait(). Simply check the
+ predicate before continuing.
kes Add const char where needed (more to do). Remove temp debug code.
26Sep07
kes Setup SQLite busy handler before doing queries.