2 This patch used the jcr stored in the BSOCK packet during callbacks
3 to the Director rather than looking them up in the JCR list.
5 It can be applied to Bacula version 2.4.3 (or earlier) with:
8 patch -p0 <2.4.3-getmsg.patch
9 ./configure <your options>
15 Index: src/dird/getmsg.c
16 ===================================================================
17 --- src/dird/getmsg.c (revision 7970)
18 +++ src/dird/getmsg.c (working copy)
21 Bacula® - The Network Backup Solution
23 - Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
24 + Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
26 The main author of Bacula is Kern Sibbald, with contributions from
27 many others, a complete list can be found in the file AUTHORS.
29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 - Bacula® is a registered trademark of John Walker.
33 + Bacula® is a registered trademark of Kern Sibbald.
34 The licensor of Bacula is the Free Software Foundation Europe
35 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
36 Switzerland, email:ftf@fsfeurope.org.
38 char Job[MAX_NAME_LENGTH];
42 + JCR *jcr = bs->jcr();
47 - Dmsg2(100, "bget_dirmsg %d: %s", n, bs->msg);
48 + Dmsg2(300, "bget_dirmsg %d: %s\n", n, bs->msg);
50 if (is_bnet_stop(bs)) {
51 return n; /* error or terminate */
53 bs->fsend("btime %s\n", edit_uint64(get_current_btime(),ed1));
56 - Emsg1(M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen);
57 + Jmsg1(jcr, M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen);
64 if (sscanf(bs->msg, "%020s Job=%127s ", MsgType, Job) != 2) {
65 - Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
66 + Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
69 - if (strcmp(Job, "*System*") == 0) {
70 - jcr = NULL; /* No jcr */
71 - } else if (!(jcr=get_jcr_by_full_name(Job))) {
72 - Emsg1(M_ERROR, 0, _("Job not found: %s\n"), bs->msg);
75 - Dmsg1(900, "Getmsg got jcr 0x%x\n", jcr);
77 /* Skip past "Jmsg Job=nnn" */
78 if (!(msg=find_msg_start(bs->msg))) {
79 - Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
81 + Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
86 if (bs->msg[0] == 'J') { /* Job message */
87 if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%d",
88 Job, &type, &level) != 3) {
89 - Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
91 + Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
94 Dmsg1(900, "Got msg: %s\n", bs->msg);
97 Dmsg1(900, "Dispatch msg: %s", msg);
98 dispatch_message(jcr, type, level, msg);
103 @@ -209,21 +199,16 @@
104 if (bs->msg[0] == 'C') { /* Catalog request */
105 Dmsg2(900, "Catalog req jcr 0x%x: %s", jcr, bs->msg);
106 catalog_request(jcr, bs);
107 - Dmsg1(900, "Calling freejcr 0x%x\n", jcr);
111 if (bs->msg[0] == 'U') { /* SD sending attributes */
112 Dmsg2(900, "Catalog upd jcr 0x%x: %s", jcr, bs->msg);
113 catalog_update(jcr, bs);
114 - Dmsg1(900, "Calling freejcr 0x%x\n", jcr);
118 if (bs->msg[0] == 'M') { /* Mount request */
119 Dmsg1(900, "Mount req: %s", bs->msg);
120 mount_request(jcr, bs, msg);
124 if (bs->msg[0] == 'S') { /* Status change */
126 if (sscanf(bs->msg, Job_status, &Job, &JobStatus) == 2) {
127 jcr->SDJobStatus = JobStatus; /* current status */
129 - Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
130 + Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);