From: Kern Sibbald Date: Tue, 25 Nov 2008 08:09:23 +0000 (+0000) Subject: Ensure that consoles attach jcr to thread, and that only the X-Git-Tag: Release-3.0.0~549 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b0c41e7b7b06abfeef99304d063f59eb4e544f69;p=bacula%2Fbacula Ensure that consoles attach jcr to thread, and that only the thread attached is removed from the TSD. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8081 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index 34c4b89c61..3a6076b449 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -126,6 +126,7 @@ static void *handle_UA_client_request(void *arg) ua = new_ua_context(jcr); ua->UA_sock = user; + set_jcr_in_tsd(jcr); user->recv(); /* Get first message */ if (!authenticate_user_agent(ua)) { diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 961376bf72..b7ce11cbb9 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -474,8 +474,7 @@ static void free_common_jcr(JCR *jcr) free_guid_list(jcr->id_list); jcr->id_list = NULL; } - /* Invalidate the tsd jcr data */ - set_jcr_in_tsd(INVALID_JCR); + remove_jcr_from_tsd(jcr); free(jcr); } @@ -579,6 +578,21 @@ void free_jcr(JCR *jcr) Dmsg0(dbglvl, "Exit free_jcr\n"); } +/* + * Remove jcr from thread specific data, but + * but make sure it is us who are attached. + */ +void remove_jcr_from_tsd(JCR *jcr) +{ + JCR *tjcr = get_gcr_from_tsd(); + if (tjcr == jcr) { + set_jcr_in_tsd(INVALID_JCR); + } +} + +/* + * Put this jcr in the thread specifc data + */ void set_jcr_in_tsd(JCR *jcr) { int status = pthread_setspecific(jcr_key, (void *)jcr); @@ -588,6 +602,9 @@ void set_jcr_in_tsd(JCR *jcr) } } +/* + * Give me the jcr that is attached to this thread + */ JCR *get_jcr_from_tsd() { JCR *jcr = (JCR *)pthread_getspecific(jcr_key); diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 34a336295b..fa662a4881 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -206,6 +206,7 @@ void jcr_walk_end(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); /* lex.c */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 454485e50e..41b6ccfe37 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.20" -#define BDATE "22 November 2008" -#define LSMDATE "22Nov08" +#define BDATE "25 November 2008" +#define LSMDATE "25Nov08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 2c00e81093..10ab6e02d0 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -10,6 +10,9 @@ filepattern (restore with regex in bsr) mixed priorities General: +25Nov08 +kes Ensure that consoles attach jcr to thread, and that only the + thread attached is removed from the TSD. 24Nov08 kes Move definition of FileId_t to bc_types and define it once in the jcr. 22Nov08