return jcr;
}
+/*
+ * Given a thread id, find the JobId
+ * Returns: JobId on success
+ * 0 on failure
+ */
+uint32_t get_jobid_from_tid(pthread_t tid)
+{
+ JCR *jcr = NULL;
+ bool found = false;
+
+ foreach_jcr(jcr) {
+ if (pthread_equal(jcr->my_thread_id, tid)) {
+ found = true;
+ break;
+ }
+ }
+ endeach_jcr(jcr);
+ if (found) {
+ return jcr->JobId;
+ }
+ return 0;
+}
+
+
/*
* Given a SessionId and SessionTime, find the JCR
* Returns: jcr on success
bool is_name_valid (char *name, POOLMEM **msg);
/* jcr.c (most definitions are in src/jcr.h) */
-void init_last_jobs_list();
-void term_last_jobs_list();
-void lock_last_jobs_list();
-void unlock_last_jobs_list();
-bool read_last_jobs_list(int fd, uint64_t addr);
+void init_last_jobs_list();
+void term_last_jobs_list();
+void lock_last_jobs_list();
+void unlock_last_jobs_list();
+bool read_last_jobs_list(int fd, uint64_t addr);
uint64_t write_last_jobs_list(int fd, uint64_t addr);
-void write_state_file(char *dir, const char *progname, int port);
-void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx);
-void lock_jobs();
-void unlock_jobs();
-JCR *jcr_walk_start();
-JCR *jcr_walk_next(JCR *prev_jcr);
-void jcr_walk_end(JCR *jcr);
+void write_state_file(char *dir, const char *progname, int port);
+void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx);
+void lock_jobs();
+void unlock_jobs();
+JCR *jcr_walk_start();
+JCR *jcr_walk_next(JCR *prev_jcr);
+void jcr_walk_end(JCR *jcr);
+JCR *get_jcr_from_tsd();
+void set_jcr_in_tsd(JCR *jcr);
+void remove_jcr_from_tsd(JCR *jcr);
uint32_t get_jobid_from_tsd();
-JCR *get_jcr_from_tsd();
-void set_jcr_in_tsd(JCR *jcr);
-void remove_jcr_from_tsd(JCR *jcr);
+uint32_t get_jobid_from_tid(pthread_t tid);
/* lex.c */
/* Print also B_DB and RWLOCK structure
* Can add more info about JCR with dbg_jcr_add_hook()
*/
+ dbg_print_lock(fp);
_dbg_print_jcr(fp);
-
_dbg_print_plugin(fp);
- dbg_print_lock(fp);
if (fp != stderr) {
fclose(fp);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2009 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
#endif
void dblock(int why); /* in lock.c */
void dunblock(bool locked=false); /* in lock.c */
+ bool is_device_unmounted(); /* in lock.c */
void set_blocked(int block) { m_blocked = block; };
int blocked() const { return m_blocked; };
bool is_blocked() const { return m_blocked != BST_NOT_BLOCKED; };
void clear_found_in_use() { m_found_in_use = false; };
bool is_reserved() const { return m_reserved; };
bool is_dev_locked() { return m_dev_locked; }
+#ifdef SD_DEBUG_LOCK
+ void _dlock(const char *, int); /* in lock.c */
+ void _dunlock(const char *, int); /* in lock.c */
+#else
void dlock() { dev->dlock(); m_dev_locked = true; }
void dunlock() { m_dev_locked = false; dev->dunlock(); }
+#endif
void dblock(int why) { dev->dblock(why); }
#ifdef SD_DEBUG_LOCK
+void DCR::_dlock(const char *file, int line)
+{
+ dev->_dlock(file, line);
+ m_dev_locked = true;
+}
+void DCR::_dunlock(const char *file, int line)
+{
+ m_dev_locked = false;
+ dev->_dunlock(file, line);
+
+}
+
void DEVICE::_dlock(const char *file, int line)
{
- Dmsg4(sd_dbglvl, "dlock from %s:%d precnt=%d JobId=%u\n", file, line,
- m_count, get_jobid_from_tid());
+ Dmsg3(sd_dbglvl, "dlock from %s:%d precnt=%d\n", file, line, m_count);
/* Note, this *really* should be protected by a mutex, but
* since it is only debug code we don't worry too much.
*/
if (m_count > 0 && pthread_equal(m_pid, pthread_self())) {
- Dmsg5(sd_dbglvl, "Possible DEADLOCK!! lock held by JobId=%u from %s:%d m_count=%d JobId=%u\n",
+ Dmsg4(sd_dbglvl, "Possible DEADLOCK!! lock held by JobId=%u from %s:%d m_count=%d\n",
get_jobid_from_tid(m_pid),
- file, line, m_count, get_jobid_from_tid());
+ file, line, m_count);
}
P(m_mutex);
m_pid = pthread_self();
void DEVICE::_dunlock(const char *file, int line)
{
m_count--;
- Dmsg4(sd_dbglvl+1, "dunlock from %s:%d postcnt=%d JobId=%u\n", file, line,
- m_count, get_jobid_from_tid());
+ Dmsg3(sd_dbglvl+1, "dunlock from %s:%d postcnt=%d\n", file, line, m_count);
V(m_mutex);
}
#ifdef SD_DEBUG_LOCK
void DEVICE::_r_dlock(const char *file, int line)
{
- Dmsg4(sd_dbglvl+1, "r_dlock blked=%s from %s:%d JobId=%u\n", this->print_blocked(),
- file, line, get_jobid_from_tid());
+ Dmsg3(sd_dbglvl+1, "r_dlock blked=%s from %s:%d\n", this->print_blocked(),
+ file, line);
#else
void DEVICE::r_dlock()
{
#endif
int stat;
- this->dlock();
+ P(m_mutex); /* this->dlock(); */
+ m_count++; /* this->dlock() */
if (this->blocked() && !pthread_equal(this->no_wait_id, pthread_self())) {
this->num_waiting++; /* indicate that I am waiting */
while (this->blocked()) {
void set_start_vol_position(DCR *dcr);
void set_new_volume_parameters(DCR *dcr);
void set_new_file_parameters(DCR *dcr);
-bool is_device_unmounted(DEVICE *dev);
/* From dircmd.c */
void *handle_connection_request(void *arg);
#ifdef SD_DEBUG_LOCK
#define lock_reservations() \
- do { Dmsg4(sd_dbglvl, "lock_reservations at %s:%d precnt=%d JobId=%u\n", \
+ do { Dmsg3(sd_dbglvl, "lock_reservations at %s:%d precnt=%d\n", \
__FILE__, __LINE__, \
- reservations_lock_count, get_jobid_from_tid(pthread_self())); \
+ reservations_lock_count); \
_lock_reservations(); \
- Dmsg1(sd_dbglvl, "lock_reservations: got lock JobId=%u\n", \
- get_jobid_from_tid(pthread_self())); \
+ Dmsg0(sd_dbglvl, "lock_reservations: got lock\n"); \
} while (0)
#define unlock_reservations() \
- do { Dmsg4(sd_dbglvl, "unlock_reservations at %s:%d precnt=%d JobId=%u\n", \
+ do { Dmsg3(sd_dbglvl, "unlock_reservations at %s:%d precnt=%d\n", \
__FILE__, __LINE__, \
- reservations_lock_count, get_jobid_from_tid(pthread_self())); \
+ reservations_lock_count); \
_unlock_reservations(); } while (0)
#define lock_volumes() \
- do { Dmsg4(sd_dbglvl, "lock_volumes at %s:%d precnt=%d JobId=%u\n", \
+ do { Dmsg3(sd_dbglvl, "lock_volumes at %s:%d precnt=%d\n", \
__FILE__, __LINE__, \
- vol_list_lock_count, get_jobid_from_tid(pthread_self())); \
+ vol_list_lock_count); \
_lock_volumes(); \
- Dmsg1(sd_dbglvl, "lock_volumes: got lock JobId=%u\n", \
- get_jobid_from_tid(pthread_self())); \
+ Dmsg0(sd_dbglvl, "lock_volumes: got lock\n"); \
} while (0)
#define unlock_volumes() \
- do { Dmsg4(sd_dbglvl, "unlock_volumes at %s:%d precnt=%d JobId=%u\n", \
+ do { Dmsg3(sd_dbglvl, "unlock_volumes at %s:%d precnt=%d\n", \
__FILE__, __LINE__, \
- vol_list_lock_count, get_jobid_from_tid(pthread_self())); \
+ vol_list_lock_count); \
_unlock_volumes(); } while (0)
#else
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
/* Set to debug mutexes */
//#define SD_DEBUG_LOCK
+#ifdef SD_DEBUG_LOCK
+const int sd_dbglvl = 3;
+#else
const int sd_dbglvl = 300;
+#endif
#ifdef HAVE_MTIO_H
#include <mtio.h>
General:
+13Aug09
+kes Make SD lock tracing work again. Has not worked for some time.
12Aug09
kes Make new big-virtual-changer test. Test concurrency.
ebl Add .lsfiles, .lsdirs, .update command to interface user with bvfs object
@output /dev/null
messages
@$out ${cwd}/tmp/log1.out
-setdebug level=100 storage=Virtual
+setdebug level=10 storage=Virtual
@#setdebug level=200 client=$CLIENT
label storage=Virtual volume=TestVolume001 slot=1 Pool=Default drive=0
label storage=Virtual volume=TestVolume002 slot=2 Pool=Full drive=0