From 010dccf54d7cb0110a0a626d424fc8f8ce7d7196 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 8 Aug 2009 16:11:24 +0200 Subject: [PATCH] Minor bsock cleanup in stored --- bacula/src/lib/bnet.c | 5 ++--- bacula/src/stored/append.c | 11 ++++++----- bacula/src/stored/spool.c | 13 +++++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index ee2415db8d..8f802b1511 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -192,7 +192,7 @@ int32_t bnet_recv(BSOCK * bsock) */ bool is_bnet_stop(BSOCK * bsock) { - return bsock->errors || bsock->is_terminated(); + return bsock->is_stop(); } /* @@ -200,8 +200,7 @@ bool is_bnet_stop(BSOCK * bsock) */ int is_bnet_error(BSOCK * bsock) { - errno = bsock->b_errno; - return bsock->errors; + return bsock->is_error(); } /* diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 9a00694638..df97cc9df0 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -219,25 +219,26 @@ bool do_append_data(JCR *jcr) if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_UNIX_ATTRIBUTES_EX || crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) { if (!jcr->no_attributes) { + BSOCK *dir = jcr->dir_bsock; if (are_attributes_spooled(jcr)) { - jcr->dir_bsock->set_spooling(); + dir->set_spooling(); } Dmsg0(850, "Send attributes to dir.\n"); if (!dir_update_file_attributes(dcr, &rec)) { - jcr->dir_bsock->clear_spooling(); + dir->clear_spooling(); Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"), - jcr->dir_bsock->bstrerror()); + dir->bstrerror()); ok = false; break; } - jcr->dir_bsock->clear_spooling(); + dir->clear_spooling(); } } Dmsg0(650, "Enter bnet_get\n"); } Dmsg1(650, "End read loop with FD. Stat=%d\n", n); - if (is_bnet_error(ds)) { + if (ds->is_error()) { Dmsg1(350, "Network read error from FD. ERR=%s\n", ds->bstrerror()); Jmsg1(jcr, M_FATAL, 0, _("Network error on data channel. ERR=%s\n"), ds->bstrerror()); diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index f13bfdf3e2..f462538bf7 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -642,14 +642,19 @@ static void make_unique_spool_filename(JCR *jcr, POOLMEM **name, int fd) jcr->Job, fd); } +/* + * Tell Director where to find the attributes spool file + * Note, if we are not on the same machine, the Director will + * return an error, and the higher level routine will transmit + * the data record by record -- using bsock->despool(). + */ static bool blast_attr_spool_file(JCR *jcr, boffset_t size) { /* send full spool file name */ POOLMEM *name = get_pool_memory(PM_MESSAGE); make_unique_spool_filename(jcr, &name, jcr->dir_bsock->m_fd); bash_spaces(name); - jcr->dir_bsock->fsend("BlastAttr Job=%s File=%s\n", - jcr->Job, name); + jcr->dir_bsock->fsend("BlastAttr Job=%s File=%s\n", jcr->Job, name); free_pool_memory(name); if (jcr->dir_bsock->recv() <= 0) { @@ -711,7 +716,7 @@ bail_out: return false; } -bool open_attr_spool_file(JCR *jcr, BSOCK *bs) +static bool open_attr_spool_file(JCR *jcr, BSOCK *bs) { POOLMEM *name = get_pool_memory(PM_MESSAGE); @@ -731,7 +736,7 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs) return true; } -bool close_attr_spool_file(JCR *jcr, BSOCK *bs) +static bool close_attr_spool_file(JCR *jcr, BSOCK *bs) { POOLMEM *name; -- 2.39.2