From 750c3d37b61a213a1806b4d442484f0988a9409a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 20 May 2007 16:19:49 +0000 Subject: [PATCH] Move more bnet functions into the BSOCK class. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4858 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/getmsg.c | 14 +- bacula/src/dird/msgchan.c | 4 +- bacula/src/filed/backup.c | 2 +- bacula/src/filed/heartbeat.c | 8 +- bacula/src/filed/job.c | 4 +- bacula/src/filed/status.c | 2 +- bacula/src/lib/bget_msg.c | 20 +- bacula/src/lib/bnet.c | 192 +++--------------- bacula/src/lib/bsock.c | 229 ++++++++++++++++++++-- bacula/src/lib/bsock.h | 35 ++-- bacula/src/lib/btimers.c | 2 +- bacula/src/lib/jcr.c | 6 +- bacula/src/lib/tls.c | 28 +-- bacula/src/qt-console/console/console.cpp | 2 +- bacula/src/stored/append.c | 6 +- bacula/src/stored/mac.c | 6 +- bacula/src/stored/spool.c | 22 +-- bacula/src/stored/status.c | 2 +- bacula/src/stored/stored.c | 2 +- bacula/technotes-2.1 | 1 + 20 files changed, 330 insertions(+), 257 deletions(-) diff --git a/bacula/src/dird/getmsg.c b/bacula/src/dird/getmsg.c index 4a7b758c93..44c8992a04 100644 --- a/bacula/src/dird/getmsg.c +++ b/bacula/src/dird/getmsg.c @@ -106,7 +106,7 @@ int bget_dirmsg(BSOCK *bs) char *msg; for (;;) { - n = bnet_recv(bs); + n = bs->recv(); Dmsg2(900, "bget_dirmsg %d: %s", n, bs->msg); if (is_bnet_stop(bs)) { @@ -118,13 +118,13 @@ int bget_dirmsg(BSOCK *bs) case BNET_EOD: /* end of data */ return n; case BNET_EOD_POLL: - bnet_fsend(bs, OK_msg);/* send response */ + bs->fsend(OK_msg);/* send response */ return n; /* end of data */ case BNET_TERMINATE: - bs->terminated = 1; + bs->m_terminated = 1; return n; case BNET_POLL: - bnet_fsend(bs, OK_msg); /* send response */ + bs->fsend(OK_msg); /* send response */ break; case BNET_HEARTBEAT: // encode_time(time(NULL), Job); @@ -134,12 +134,12 @@ int bget_dirmsg(BSOCK *bs) break; case BNET_STATUS: /* *****FIXME***** Implement more completely */ - bnet_fsend(bs, "Status OK\n"); - bnet_sig(bs, BNET_EOD); + bs->fsend("Status OK\n"); + bs->signal(BNET_EOD); break; case BNET_BTIME: /* send Bacula time */ char ed1[50]; - bnet_fsend(bs, "btime %s\n", edit_uint64(get_current_btime(),ed1)); + bs->fsend("btime %s\n", edit_uint64(get_current_btime(),ed1)); break; default: Emsg1(M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen); diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index e6f85cee49..7a99792130 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -409,8 +409,8 @@ void wait_for_storage_daemon_termination(JCR *jcr) V(mutex); if (job_canceled(jcr)) { if (jcr->SD_msg_chan) { - jcr->store_bsock->timed_out = 1; - jcr->store_bsock->terminated = 1; + jcr->store_bsock->m_timed_out = 1; + jcr->store_bsock->m_terminated = 1; Dmsg2(400, "kill jobid=%d use=%d\n", (int)jcr->JobId, jcr->use_count()); pthread_kill(jcr->SD_msg_chan, TIMEOUT_SIGNAL); } diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index ca770df552..a67df8373a 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -70,7 +70,7 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) set_jcr_job_status(jcr, JS_Running); - Dmsg1(300, "bfiled: opened data connection %d to stored\n", sd->fd); + Dmsg1(300, "bfiled: opened data connection %d to stored\n", sd->m_fd); LockRes(); CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL); diff --git a/bacula/src/filed/heartbeat.c b/bacula/src/filed/heartbeat.c index 32496e7a8e..5aed2cf57e 100644 --- a/bacula/src/filed/heartbeat.c +++ b/bacula/src/filed/heartbeat.c @@ -129,12 +129,12 @@ void stop_heartbeat_monitor(JCR *jcr) } if (jcr->hb_bsock) { - jcr->hb_bsock->timed_out = 1; /* set timed_out to terminate read */ - jcr->hb_bsock->terminated = 1; /* set to terminate read */ + jcr->hb_bsock->m_timed_out = true; /* set timed_out to terminate read */ + jcr->hb_bsock->m_terminated = true; /* set to terminate read */ } if (jcr->hb_dir_bsock) { - jcr->hb_dir_bsock->timed_out = 1; /* set timed_out to terminate read */ - jcr->hb_dir_bsock->terminated = 1; /* set to terminate read */ + jcr->hb_dir_bsock->m_timed_out = true; /* set timed_out to terminate read */ + jcr->hb_dir_bsock->m_terminated = true; /* set to terminate read */ } Dmsg0(100, "Send kill to heartbeat id\n"); pthread_kill(jcr->heartbeat_id, TIMEOUT_SIGNAL); /* make heartbeat thread go away */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 6d6a685e62..6e78537d38 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -372,8 +372,8 @@ static int cancel_cmd(JCR *jcr) bnet_fsend(dir, _("2901 Job %s not found.\n"), Job); } else { if (cjcr->store_bsock) { - cjcr->store_bsock->timed_out = 1; - cjcr->store_bsock->terminated = 1; + cjcr->store_bsock->m_timed_out = 1; + cjcr->store_bsock->m_terminated = 1; pthread_kill(cjcr->my_thread_id, TIMEOUT_SIGNAL); } set_jcr_job_status(cjcr, JS_Canceled); diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index 083fde9ef2..1e50bb4713 100644 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -187,7 +187,7 @@ void output_status(void sendit(const char *msg, int len, void *sarg), void *arg) found = true; if (njcr->store_bsock) { len = Mmsg(msg, " SDReadSeqNo=%" lld " fd=%d\n", - njcr->store_bsock->read_seqno, njcr->store_bsock->fd); + njcr->store_bsock->read_seqno, njcr->store_bsock->m_fd); sendit(msg.c_str(), len, arg); } else { len = Mmsg(msg, _(" SDSocket closed.\n")); diff --git a/bacula/src/lib/bget_msg.c b/bacula/src/lib/bget_msg.c index b33808f9dd..a946808a4e 100644 --- a/bacula/src/lib/bget_msg.c +++ b/bacula/src/lib/bget_msg.c @@ -57,7 +57,7 @@ int bget_msg(BSOCK *sock) { int n; for ( ;; ) { - n = bnet_recv(sock); + n = sock->recv(); if (n >= 0) { /* normal return */ return n; } @@ -72,22 +72,22 @@ int bget_msg(BSOCK *sock) return n; case BNET_EOD_POLL: Dmsg0(msglvl, "Got BNET_EOD_POLL\n"); - if (sock->terminated) { - bnet_fsend(sock, TERM_msg); + if (sock->is_terminated()) { + sock->fsend(TERM_msg); } else { - bnet_fsend(sock, OK_msg); /* send response */ + sock->fsend(OK_msg); /* send response */ } return n; /* end of data */ case BNET_TERMINATE: Dmsg0(msglvl, "Got BNET_TERMINATE\n"); - sock->terminated = 1; + sock->set_terminated(); return n; case BNET_POLL: Dmsg0(msglvl, "Got BNET_POLL\n"); - if (sock->terminated) { - bnet_fsend(sock, TERM_msg); + if (sock->is_terminated()) { + sock->fsend(TERM_msg); } else { - bnet_fsend(sock, OK_msg); /* send response */ + sock->fsend(OK_msg); /* send response */ } break; case BNET_HEARTBEAT: @@ -96,8 +96,8 @@ int bget_msg(BSOCK *sock) case BNET_STATUS: /* *****FIXME***** Implement BNET_STATUS */ Dmsg0(msglvl, "Got BNET_STATUS\n"); - bnet_fsend(sock, _("Status OK\n")); - bnet_sig(sock, BNET_EOD); + sock->fsend(_("Status OK\n")); + sock->signal(BNET_EOD); break; default: Emsg1(M_ERROR, 0, _("bget_msg: unknown signal %d\n"), sock->msglen); diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index b2d0fcdd05..b81d0bf52b 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -79,8 +79,8 @@ int32_t read_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes) nleft = nbytes; while (nleft > 0) { errno = 0; - nread = socketRead(bsock->fd, ptr, nleft); - if (bsock->timed_out || bsock->terminated) { + nread = socketRead(bsock->m_fd, ptr, nleft); + if (bsock->is_timed_out() || bsock->is_terminated()) { return nread; } if (nread == -1) { @@ -110,8 +110,8 @@ int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes) { int32_t nleft, nwritten; - if (bsock->spool) { - nwritten = fwrite(ptr, 1, nbytes, bsock->spool_fd); + if (bsock->m_spool) { + nwritten = fwrite(ptr, 1, nbytes, bsock->m_spool_fd); if (nwritten != nbytes) { berrno be; bsock->b_errno = errno; @@ -135,8 +135,8 @@ int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes) while (nleft > 0) { do { errno = 0; - nwritten = socketWrite(bsock->fd, ptr, nleft); - if (bsock->timed_out || bsock->terminated) { + nwritten = socketWrite(bsock->m_fd, ptr, nleft); + if (bsock->is_timed_out() || bsock->is_terminated()) { return nwritten; } } while (nwritten == -1 && errno == EINTR); @@ -150,10 +150,10 @@ int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes) struct timeval tv; FD_ZERO(&fdset); - FD_SET((unsigned)bsock->fd, &fdset); + FD_SET((unsigned)bsock->m_fd, &fdset); tv.tv_sec = 10; tv.tv_usec = 0; - select(bsock->fd + 1, NULL, &fdset, NULL, &tv); + select(bsock->m_fd + 1, NULL, &fdset, NULL, &tv); continue; } if (nwritten <= 0) { @@ -194,7 +194,7 @@ int32_t bnet_recv(BSOCK * bsock) */ bool is_bnet_stop(BSOCK * bsock) { - return bsock->errors || bsock->terminated; + return bsock->errors || bsock->is_terminated(); } /* @@ -212,7 +212,7 @@ int is_bnet_error(BSOCK * bsock) */ void bnet_suppress_error_messages(BSOCK * bsock, bool flag) { - bsock->suppress_error_msgs = flag; + bsock->m_suppress_error_msgs = flag; } /* @@ -239,7 +239,7 @@ bool bnet_tls_server(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list) { TLS_CONNECTION *tls; - tls = new_tls_connection(ctx, bsock->fd); + tls = new_tls_connection(ctx, bsock->m_fd); if (!tls) { Qmsg0(bsock->jcr(), M_FATAL, 0, _("TLS connection initialization failed.\n")); return false; @@ -278,7 +278,7 @@ bool bnet_tls_client(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list) { TLS_CONNECTION *tls; - tls = new_tls_connection(ctx, bsock->fd); + tls = new_tls_connection(ctx, bsock->m_fd); if (!tls) { Qmsg0(bsock->jcr(), M_FATAL, 0, _("TLS connection initialization failed.\n")); return false; @@ -345,11 +345,11 @@ int bnet_wait_data(BSOCK * bsock, int sec) struct timeval tv; FD_ZERO(&fdset); - FD_SET((unsigned)bsock->fd, &fdset); + FD_SET((unsigned)bsock->m_fd, &fdset); for (;;) { tv.tv_sec = sec; tv.tv_usec = 0; - switch (select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) { + switch (select(bsock->m_fd + 1, &fdset, NULL, NULL, &tv)) { case 0: /* timeout */ bsock->b_errno = 0; return 0; @@ -375,10 +375,10 @@ int bnet_wait_data_intr(BSOCK * bsock, int sec) struct timeval tv; FD_ZERO(&fdset); - FD_SET((unsigned)bsock->fd, &fdset); + FD_SET((unsigned)bsock->m_fd, &fdset); tv.tv_sec = sec; tv.tv_usec = 0; - switch (select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) { + switch (select(bsock->m_fd + 1, &fdset, NULL, NULL, &tv)) { case 0: /* timeout */ bsock->b_errno = 0; return 0; @@ -723,7 +723,7 @@ bool bnet_fsend(BSOCK * bs, const char *fmt, ...) va_list arg_ptr; int maxlen; - if (bs->errors || bs->terminated) { + if (bs->errors || bs->is_terminated()) { return false; } /* This probably won't work, but we vsnprintf, then if we @@ -746,20 +746,9 @@ bool bnet_fsend(BSOCK * bs, const char *fmt, ...) int bnet_get_peer(BSOCK *bs, char *buf, socklen_t buflen) { -#if !defined(HAVE_WIN32) - if (bs->peer_addr.sin_family == 0) { - socklen_t salen = sizeof(bs->peer_addr); - int rval = (getpeername)(bs->fd, (struct sockaddr *)&bs->peer_addr, &salen); - if (rval < 0) return rval; - } - if (!inet_ntop(bs->peer_addr.sin_family, &bs->peer_addr.sin_addr, buf, buflen)) - return -1; - - return 0; -#else - return -1; -#endif + return bs->get_peer(buf, buflen); } + /* * Set the network buffer size, suggested size is in size. * Actual size obtained is returned in bs->msglen @@ -769,136 +758,25 @@ int bnet_get_peer(BSOCK *bs, char *buf, socklen_t buflen) */ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw) { - uint32_t dbuf_size, start_size; -#if defined(IP_TOS) && defined(IPTOS_THROUGHPUT) - int opt; - opt = IPTOS_THROUGHPUT; - setsockopt(bs->fd, IPPROTO_IP, IP_TOS, (sockopt_val_t)&opt, sizeof(opt)); -#endif - - if (size != 0) { - dbuf_size = size; - } else { - dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE; - } - start_size = dbuf_size; - if ((bs->msg = realloc_pool_memory(bs->msg, dbuf_size + 100)) == NULL) { - Qmsg0(bs->jcr(), M_FATAL, 0, _("Could not malloc BSOCK data buffer\n")); - return false; - } - if (rw & BNET_SETBUF_READ) { - while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET, - SO_RCVBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) { - berrno be; - Qmsg1(bs->jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror()); - dbuf_size -= TAPE_BSIZE; - } - Dmsg1(200, "set network buffer size=%d\n", dbuf_size); - if (dbuf_size != start_size) { - Qmsg1(bs->jcr(), M_WARNING, 0, - _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); - } - if (dbuf_size % TAPE_BSIZE != 0) { - Qmsg1(bs->jcr(), M_ABORT, 0, - _("Network buffer size %d not multiple of tape block size.\n"), - dbuf_size); - } - } - if (size != 0) { - dbuf_size = size; - } else { - dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE; - } - start_size = dbuf_size; - if (rw & BNET_SETBUF_WRITE) { - while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET, - SO_SNDBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) { - berrno be; - Qmsg1(bs->jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror()); - dbuf_size -= TAPE_BSIZE; - } - Dmsg1(900, "set network buffer size=%d\n", dbuf_size); - if (dbuf_size != start_size) { - Qmsg1(bs->jcr(), M_WARNING, 0, - _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); - } - if (dbuf_size % TAPE_BSIZE != 0) { - Qmsg1(bs->jcr(), M_ABORT, 0, - _("Network buffer size %d not multiple of tape block size.\n"), - dbuf_size); - } - } - - bs->msglen = dbuf_size; - return true; + return bs->set_buffer_size(size, rw); } /* * Set socket non-blocking * Returns previous socket flag */ -int bnet_set_nonblocking (BSOCK *bsock) { -#ifndef HAVE_WIN32 - int oflags; - - /* Get current flags */ - if ((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) { - berrno be; - Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror()); - } - - /* Set O_NONBLOCK flag */ - if ((fcntl(bsock->fd, F_SETFL, oflags|O_NONBLOCK)) < 0) { - berrno be; - Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror()); - } - - bsock->blocking = 0; - return oflags; -#else - int flags; - u_long ioctlArg = 1; - - flags = bsock->blocking; - ioctlsocket(bsock->fd, FIONBIO, &ioctlArg); - bsock->blocking = 0; - - return flags; -#endif +int bnet_set_nonblocking(BSOCK *bsock) +{ + return bsock->set_nonblocking(); } /* * Set socket blocking * Returns previous socket flags */ -int bnet_set_blocking (BSOCK *bsock) +int bnet_set_blocking(BSOCK *bsock) { -#ifndef HAVE_WIN32 - int oflags; - /* Get current flags */ - if ((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) { - berrno be; - Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror()); - } - - /* Set O_NONBLOCK flag */ - if ((fcntl(bsock->fd, F_SETFL, oflags & ~O_NONBLOCK)) < 0) { - berrno be; - Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror()); - } - - bsock->blocking = 1; - return oflags; -#else - int flags; - u_long ioctlArg = 0; - - flags = bsock->blocking; - ioctlsocket(bsock->fd, FIONBIO, &ioctlArg); - bsock->blocking = 1; - - return flags; -#endif + return bsock->set_blocking(); } /* @@ -906,19 +784,7 @@ int bnet_set_blocking (BSOCK *bsock) */ void bnet_restore_blocking (BSOCK *bsock, int flags) { -#ifndef HAVE_WIN32 - if ((fcntl(bsock->fd, F_SETFL, flags)) < 0) { - berrno be; - Jmsg1(bsock->jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror()); - } - - bsock->blocking = (flags & O_NONBLOCK); -#else - u_long ioctlArg = flags; - - ioctlsocket(bsock->fd, FIONBIO, &ioctlArg); - bsock->blocking = 1; -#endif + bsock->restore_blocking(flags); } @@ -974,10 +840,10 @@ BSOCK *init_bsock(JCR * jcr, int sockfd, const char *who, const char *host, int Dmsg3(100, "who=%s host=%s port=%d\n", who, host, port); BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK)); memset(bsock, 0, sizeof(BSOCK)); - bsock->fd = sockfd; + bsock->m_fd = sockfd; bsock->tls = NULL; bsock->errors = 0; - bsock->blocking = 1; + bsock->m_blocking = 1; bsock->msg = get_pool_memory(PM_MESSAGE); bsock->errmsg = get_pool_memory(PM_MESSAGE); bsock->set_who(bstrdup(who)); @@ -1006,7 +872,7 @@ BSOCK *dup_bsock(BSOCK * osock) if (osock->host()) { bsock->set_host(bstrdup(osock->host())); } - bsock->duped = true; + bsock->m_duped = true; return bsock; } diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index d9a0592a1b..bd2b15180c 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -66,7 +66,7 @@ bool BSOCK::send() int32_t pktsiz; int32_t *hdr; - if (errors || terminated || msglen > 1000000) { + if (errors || is_terminated() || msglen > 1000000) { return false; } /* Compute total packet length */ @@ -86,7 +86,7 @@ bool BSOCK::send() /* send data packet */ timer_start = watchdog_time; /* start timer */ - timed_out = 0; + m_timed_out = 0; /* Full I/O done in one write */ rc = write_nbytes(this, (char *)hdr, pktsiz); timer_start = 0; /* clear timer */ @@ -98,7 +98,7 @@ bool BSOCK::send() b_errno = errno; } if (rc < 0) { - if (!suppress_error_msgs) { + if (!m_suppress_error_msgs) { Qmsg5(m_jcr, M_ERROR, 0, _("Write error sending %d bytes to %s:%s:%d: ERR=%s\n"), msglen, m_who, @@ -124,7 +124,7 @@ bool BSOCK::fsend(const char *fmt, ...) va_list arg_ptr; int maxlen; - if (errors || terminated) { + if (errors || is_terminated()) { return false; } /* This probably won't work, but we vsnprintf, then if we @@ -169,13 +169,13 @@ int32_t BSOCK::recv() msg[0] = 0; msglen = 0; - if (errors || terminated) { + if (errors || is_terminated()) { return BNET_HARDEOF; } read_seqno++; /* bump sequence number */ timer_start = watchdog_time; /* set start wait time */ - timed_out = 0; + m_timed_out = 0; /* get data size -- in int32_t */ if ((nbytes = read_nbytes(this, (char *)&pktsiz, sizeof(int32_t))) <= 0) { timer_start = 0; /* clear timer */ @@ -215,7 +215,7 @@ int32_t BSOCK::recv() pktsiz = BNET_TERMINATE; /* hang up */ } if (pktsiz == BNET_TERMINATE) { - terminated = 1; + set_terminated(); } timer_start = 0; /* clear timer */ b_errno = ENODATA; @@ -229,7 +229,7 @@ int32_t BSOCK::recv() } timer_start = watchdog_time; /* set start wait time */ - timed_out = 0; + m_timed_out = 0; /* now read the actual data */ if ((nbytes = read_nbytes(this, msg, pktsiz)) <= 0) { timer_start = 0; /* clear timer */ @@ -270,7 +270,7 @@ bool BSOCK::signal(int signal) { msglen = signal; if (signal == BNET_TERMINATE) { - suppress_error_msgs = true; + m_suppress_error_msgs = true; } return send(); } @@ -285,13 +285,13 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize) ssize_t last = 0, size = 0; int count = 0; - rewind(spool_fd); + rewind(m_spool_fd); #if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED) - posix_fadvise(fileno(spool_fd), 0, 0, POSIX_FADV_WILLNEED); + posix_fadvise(fileno(m_spool_fd), 0, 0, POSIX_FADV_WILLNEED); #endif - while (fread((char *)&pktsiz, 1, sizeof(int32_t), spool_fd) == + while (fread((char *)&pktsiz, 1, sizeof(int32_t), m_spool_fd) == sizeof(int32_t)) { size += sizeof(int32_t); msglen = ntohl(pktsiz); @@ -299,7 +299,7 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize) if (msglen > (int32_t) sizeof_pool_memory(msg)) { msg = realloc_pool_memory(msg, msglen + 1); } - nbytes = fread(msg, 1, msglen, spool_fd); + nbytes = fread(msg, 1, msglen, m_spool_fd); if (nbytes != (size_t) msglen) { berrno be; Dmsg2(400, "nbytes=%d msglen=%d\n", nbytes, msglen); @@ -317,7 +317,7 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize) send(); } update_attr_spool_size(tsize - last); - if (ferror(spool_fd)) { + if (ferror(m_spool_fd)) { berrno be; Qmsg1(jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), be.bstrerror()); @@ -326,6 +326,199 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize) return true; } +/* + * Return the string for the error that occurred + * on the socket. Only the first error is retained. + */ +const char *BSOCK::bstrerror() +{ + berrno be; + if (errmsg == NULL) { + errmsg = get_pool_memory(PM_MESSAGE); + } + pm_strcpy(errmsg, be.bstrerror(b_errno)); + return errmsg; +} + +int BSOCK::get_peer(char *buf, socklen_t buflen) +{ +#if !defined(HAVE_WIN32) + if (peer_addr.sin_family == 0) { + socklen_t salen = sizeof(peer_addr); + int rval = (getpeername)(m_fd, (struct sockaddr *)&peer_addr, &salen); + if (rval < 0) return rval; + } + if (!inet_ntop(peer_addr.sin_family, &peer_addr.sin_addr, buf, buflen)) + return -1; + + return 0; +#else + return -1; +#endif +} + +/* + * Set the network buffer size, suggested size is in size. + * Actual size obtained is returned in bs->msglen + * + * Returns: false on failure + * true on success + */ +bool BSOCK::set_buffer_size(uint32_t size, int rw) +{ + uint32_t dbuf_size, start_size; +#if defined(IP_TOS) && defined(IPTOS_THROUGHPUT) + int opt; + opt = IPTOS_THROUGHPUT; + setsockopt(fd, IPPROTO_IP, IP_TOS, (sockopt_val_t)&opt, sizeof(opt)); +#endif + + if (size != 0) { + dbuf_size = size; + } else { + dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE; + } + start_size = dbuf_size; + if ((msg = realloc_pool_memory(msg, dbuf_size + 100)) == NULL) { + Qmsg0(jcr(), M_FATAL, 0, _("Could not malloc BSOCK data buffer\n")); + return false; + } + if (rw & BNET_SETBUF_READ) { + while ((dbuf_size > TAPE_BSIZE) && (setsockopt(m_fd, SOL_SOCKET, + SO_RCVBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) { + berrno be; + Qmsg1(jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror()); + dbuf_size -= TAPE_BSIZE; + } + Dmsg1(200, "set network buffer size=%d\n", dbuf_size); + if (dbuf_size != start_size) { + Qmsg1(jcr(), M_WARNING, 0, + _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); + } + if (dbuf_size % TAPE_BSIZE != 0) { + Qmsg1(jcr(), M_ABORT, 0, + _("Network buffer size %d not multiple of tape block size.\n"), + dbuf_size); + } + } + if (size != 0) { + dbuf_size = size; + } else { + dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE; + } + start_size = dbuf_size; + if (rw & BNET_SETBUF_WRITE) { + while ((dbuf_size > TAPE_BSIZE) && (setsockopt(m_fd, SOL_SOCKET, + SO_SNDBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) { + berrno be; + Qmsg1(jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror()); + dbuf_size -= TAPE_BSIZE; + } + Dmsg1(900, "set network buffer size=%d\n", dbuf_size); + if (dbuf_size != start_size) { + Qmsg1(jcr(), M_WARNING, 0, + _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); + } + if (dbuf_size % TAPE_BSIZE != 0) { + Qmsg1(jcr(), M_ABORT, 0, + _("Network buffer size %d not multiple of tape block size.\n"), + dbuf_size); + } + } + + msglen = dbuf_size; + return true; +} + +/* + * Set socket non-blocking + * Returns previous socket flag + */ +int BSOCK::set_nonblocking() +{ +#ifndef HAVE_WIN32 + int oflags; + + /* Get current flags */ + if ((oflags = fcntl(m_fd, F_GETFL, 0)) < 0) { + berrno be; + Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror()); + } + + /* Set O_NONBLOCK flag */ + if ((fcntl(m_fd, F_SETFL, oflags|O_NONBLOCK)) < 0) { + berrno be; + Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror()); + } + + m_blocking = 0; + return oflags; +#else + int flags; + u_long ioctlArg = 1; + + flags = m_blocking; + ioctlsocket(m_fd, FIONBIO, &ioctlArg); + m_blocking = 0; + + return flags; +#endif +} + +/* + * Set socket blocking + * Returns previous socket flags + */ +int BSOCK::set_blocking() +{ +#ifndef HAVE_WIN32 + int oflags; + /* Get current flags */ + if ((oflags = fcntl(m_fd, F_GETFL, 0)) < 0) { + berrno be; + Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror()); + } + + /* Set O_NONBLOCK flag */ + if ((fcntl(m_fd, F_SETFL, oflags & ~O_NONBLOCK)) < 0) { + berrno be; + Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror()); + } + + m_blocking = 1; + return oflags; +#else + int flags; + u_long ioctlArg = 0; + + flags = m_blocking; + ioctlsocket(m_fd, FIONBIO, &ioctlArg); + m_blocking = 1; + + return flags; +#endif +} + +/* + * Restores socket flags + */ +void BSOCK::restore_blocking (int flags) +{ +#ifndef HAVE_WIN32 + if ((fcntl(m_fd, F_SETFL, flags)) < 0) { + berrno be; + Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror()); + } + + m_blocking = (flags & O_NONBLOCK) ? true : false; +#else + u_long ioctlArg = flags; + + ioctlsocket(m_fd, FIONBIO, &ioctlArg); + m_blocking = 1; +#endif +} + void BSOCK::close() { @@ -334,7 +527,7 @@ void BSOCK::close() for (; bsock; bsock = next) { next = bsock->m_next; /* get possible pointer to next before destoryed */ - if (!bsock->duped) { + if (!bsock->m_duped) { #ifdef HAVE_TLS /* Shutdown tls cleanly. */ if (bsock->tls) { @@ -343,10 +536,10 @@ void BSOCK::close() bsock->tls = NULL; } #endif /* HAVE_TLS */ - if (bsock->timed_out) { - shutdown(bsock->fd, 2); /* discard any pending I/O */ + if (bsock->is_timed_out()) { + shutdown(bsock->m_fd, 2); /* discard any pending I/O */ } - socketClose(bsock->fd); /* normal close */ + socketClose(bsock->m_fd); /* normal close */ } destroy(); /* free the packet */ } diff --git a/bacula/src/lib/bsock.h b/bacula/src/lib/bsock.h index 1db9de0839..c363b7dc74 100644 --- a/bacula/src/lib/bsock.h +++ b/bacula/src/lib/bsock.h @@ -26,7 +26,9 @@ Switzerland, email:ftf@fsfeurope.org. */ /* - * Bacula Sock Structure definition + * Bacula Sock Class definition + * Note, the old non-class code is in bnet.c, and the + * new class code associated with this file is in bsock.c * * Kern Sibbald, May MM * @@ -52,23 +54,23 @@ public: uint64_t read_seqno; /* read sequence number */ uint32_t in_msg_no; /* input message number */ uint32_t out_msg_no; /* output message number */ - int fd; /* socket file descriptor */ + int m_fd; /* socket file descriptor */ TLS_CONNECTION *tls; /* associated tls connection */ int32_t msglen; /* message length */ int b_errno; /* bsock errno */ - int blocking; /* blocking state (0 = nonblocking, 1 = blocking) */ + int m_blocking; /* blocking state (0 = nonblocking, 1 = blocking) */ volatile int errors; /* incremented for each error on socket */ - volatile bool suppress_error_msgs: 1; /* set to suppress error messages */ - volatile bool timed_out: 1; /* timed out in read/write */ - volatile bool terminated: 1; /* set when BNET_TERMINATE arrives */ - bool duped: 1; /* set if duped BSOCK */ - bool spool: 1; /* set for spooling */ + volatile bool m_suppress_error_msgs: 1; /* set to suppress error messages */ + volatile bool m_timed_out: 1; /* timed out in read/write */ + volatile bool m_terminated: 1; /* set when BNET_TERMINATE arrives */ + bool m_duped: 1; /* set if duped BSOCK */ + bool m_spool: 1; /* set for spooling */ volatile time_t timer_start; /* time started read/write */ volatile time_t timeout; /* timeout BSOCK after this interval */ POOLMEM *msg; /* message pool buffer */ POOLMEM *errmsg; /* edited error message */ RES *res; /* Resource to which we are connected */ - FILE *spool_fd; /* spooling file */ + FILE *m_spool_fd; /* spooling file */ struct sockaddr client_addr; /* client's IP address */ struct sockaddr_in peer_addr; /* peer's IP address */ @@ -79,6 +81,15 @@ public: bool signal(int signal); void close(); /* close connection and destroy packet */ void destroy(); /* destroy socket packet */ + const char *bstrerror(); /* last error on socket */ + int get_peer(char *buf, socklen_t buflen); + bool despool(void update_attr_spool_size(ssize_t size), ssize_t tsize); + bool set_buffer_size(uint32_t size, int rw); + int set_nonblocking(); + int set_blocking(); + void restore_blocking(int flags); + + /* Inline functions */ void set_jcr(JCR *jcr) { m_jcr = jcr; }; void set_who(char *who) { m_who = who; }; void set_host(char *host) { m_host = host; }; @@ -87,13 +98,15 @@ public: char *host() { return m_host; }; int port() { return m_port; }; JCR *jcr() { return m_jcr; }; - bool despool(void update_attr_spool_size(ssize_t size), ssize_t tsize); + bool is_terminated() { return m_terminated; }; + bool is_timed_out() { return m_timed_out; }; + void set_terminated() { m_terminated = true; }; }; /* * Signal definitions for use in bnet_sig() * Note! These must be negative. There are signals that are generated - * by the software ... + * by the bsock software not by the OS ... */ enum { BNET_EOD = -1, /* End of data stream, new data may follow */ diff --git a/bacula/src/lib/btimers.c b/bacula/src/lib/btimers.c index 2001284f0e..8e3757e987 100644 --- a/bacula/src/lib/btimers.c +++ b/bacula/src/lib/btimers.c @@ -225,7 +225,7 @@ static void callback_thread_timer(watchdog_t *self) wid->type == TYPE_BSOCK ? "bsock" : "thread", wid->tid, time(NULL)); if (wid->type == TYPE_BSOCK && wid->bsock) { - wid->bsock->timed_out = true; + wid->bsock->m_timed_out = true; } pthread_kill(wid->tid, TIMEOUT_SIGNAL); } diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index b477230baa..40d641e103 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -699,7 +699,7 @@ static void jcr_timeout_check(watchdog_t *self) timer_start = fd->timer_start; if (timer_start && (watchdog_time - timer_start) > fd->timeout) { fd->timer_start = 0; /* turn off timer */ - fd->timed_out = true; + fd->m_timed_out = true; Jmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading Storage daemon.\n"), watchdog_time - timer_start); @@ -711,7 +711,7 @@ static void jcr_timeout_check(watchdog_t *self) timer_start = fd->timer_start; if (timer_start && (watchdog_time - timer_start) > fd->timeout) { fd->timer_start = 0; /* turn off timer */ - fd->timed_out = true; + fd->m_timed_out = true; Jmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading File daemon.\n"), watchdog_time - timer_start); @@ -723,7 +723,7 @@ static void jcr_timeout_check(watchdog_t *self) timer_start = fd->timer_start; if (timer_start && (watchdog_time - timer_start) > fd->timeout) { fd->timer_start = 0; /* turn off timer */ - fd->timed_out = true; + fd->m_timed_out = true; Jmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading Director.\n"), watchdog_time - timer_start); diff --git a/bacula/src/lib/tls.c b/bacula/src/lib/tls.c index d89d767601..df4e78e6c0 100644 --- a/bacula/src/lib/tls.c +++ b/bacula/src/lib/tls.c @@ -443,14 +443,14 @@ static inline bool openssl_bsock_session_start(BSOCK *bsock, bool server) /* Zero the fdset, we'll set our fd prior to each invocation of select() */ FD_ZERO(&fdset); - fdmax = bsock->fd + 1; + fdmax = bsock->m_fd + 1; /* Ensure that socket is non-blocking */ flags = bnet_set_nonblocking(bsock); /* start timer */ bsock->timer_start = watchdog_time; - bsock->timed_out = 0; + bsock->m_timed_out = 0; for (;;) { if (server) { @@ -471,7 +471,7 @@ static inline bool openssl_bsock_session_start(BSOCK *bsock, bool server) goto cleanup; case SSL_ERROR_WANT_READ: /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); + FD_SET((unsigned) bsock->m_fd, &fdset); /* Set our timeout */ tv.tv_sec = 10; tv.tv_usec = 0; @@ -480,7 +480,7 @@ static inline bool openssl_bsock_session_start(BSOCK *bsock, bool server) break; case SSL_ERROR_WANT_WRITE: /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); + FD_SET((unsigned) bsock->m_fd, &fdset); /* Set our timeout */ tv.tv_sec = 10; tv.tv_usec = 0; @@ -494,7 +494,7 @@ static inline bool openssl_bsock_session_start(BSOCK *bsock, bool server) goto cleanup; } - if (bsock->timed_out) { + if (bsock->is_timed_out()) { goto cleanup; } } @@ -557,7 +557,7 @@ void tls_bsock_shutdown (BSOCK *bsock) int flags; /* Set socket blocking for shutdown */ - flags = bnet_set_blocking(bsock); + flags = bsock->set_blocking(); err = SSL_shutdown(bsock->tls->openssl); @@ -575,7 +575,7 @@ void tls_bsock_shutdown (BSOCK *bsock) } /* Restore saved flags */ - bnet_restore_blocking(bsock, flags); + bsock->restore_blocking(flags); } /* Does all the manual labor for tls_bsock_readn() and tls_bsock_writen() */ @@ -590,14 +590,14 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b /* Zero the fdset, we'll set our fd prior to each invocation of select() */ FD_ZERO(&fdset); - fdmax = bsock->fd + 1; + fdmax = bsock->m_fd + 1; /* Ensure that socket is non-blocking */ - flags = bnet_set_nonblocking(bsock); + flags = bsock->set_nonblocking(); /* start timer */ bsock->timer_start = watchdog_time; - bsock->timed_out = 0; + bsock->m_timed_out = 0; nleft = nbytes; @@ -623,7 +623,7 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b goto cleanup; case SSL_ERROR_WANT_READ: /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); + FD_SET((unsigned) bsock->m_fd, &fdset); tv.tv_sec = 10; tv.tv_usec = 0; /* Block until we can read */ @@ -631,7 +631,7 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b break; case SSL_ERROR_WANT_WRITE: /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); + FD_SET((unsigned) bsock->m_fd, &fdset); tv.tv_sec = 10; tv.tv_usec = 0; /* Block until we can write */ @@ -649,14 +649,14 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b } /* Timeout/Termination, let's take what we can get */ - if (bsock->timed_out || bsock->terminated) { + if (bsock->is_timed_out() || bsock->is_terminated()) { goto cleanup; } } cleanup: /* Restore saved flags */ - bnet_restore_blocking(bsock, flags); + bsock->restore_blocking(flags); /* Clear timer */ bsock->timer_start = 0; diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index b29fc54ba8..5f79e5dc10 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -154,7 +154,7 @@ void Console::connect() mainWin->set_status(_("Initializing ...")); /* Set up input notifier */ - m_notifier = new QSocketNotifier(m_sock->fd, QSocketNotifier::Read, 0); + m_notifier = new QSocketNotifier(m_sock->m_fd, QSocketNotifier::Read, 0); QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(read_dir(int))); write(".api 1"); diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index a137788ce2..841a9725c4 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -236,17 +236,17 @@ bool do_append_data(JCR *jcr) crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) { if (!jcr->no_attributes) { if (are_attributes_spooled(jcr)) { - jcr->dir_bsock->spool = true; + jcr->dir_bsock->m_spool = true; } Dmsg0(850, "Send attributes to dir.\n"); if (!dir_update_file_attributes(dcr, &rec)) { - jcr->dir_bsock->spool = false; + jcr->dir_bsock->m_spool = false; Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"), bnet_strerror(jcr->dir_bsock)); ok = false; break; } - jcr->dir_bsock->spool = false; + jcr->dir_bsock->m_spool = false; } } Dmsg0(650, "Enter bnet_get\n"); diff --git a/bacula/src/stored/mac.c b/bacula/src/stored/mac.c index 2edbbefa91..dc4e20f1e6 100644 --- a/bacula/src/stored/mac.c +++ b/bacula/src/stored/mac.c @@ -240,16 +240,16 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) { if (!jcr->no_attributes) { if (are_attributes_spooled(jcr)) { - jcr->dir_bsock->spool = true; + jcr->dir_bsock->m_spool = true; } Dmsg0(850, "Send attributes to dir.\n"); if (!dir_update_file_attributes(jcr->dcr, rec)) { - jcr->dir_bsock->spool = false; + jcr->dir_bsock->m_spool = false; Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"), bnet_strerror(jcr->dir_bsock)); return false; } - jcr->dir_bsock->spool = false; + jcr->dir_bsock->m_spool = false; } } diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index 7e9d57e9cf..ee26ee7a86 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -554,7 +554,7 @@ static bool write_spool_data(DCR *dcr) bool are_attributes_spooled(JCR *jcr) { - return jcr->spool_attributes && jcr->dir_bsock->spool_fd; + return jcr->spool_attributes && jcr->dir_bsock->m_spool_fd; } /* @@ -599,13 +599,13 @@ bool commit_attribute_spool(JCR *jcr) char ec1[30]; if (are_attributes_spooled(jcr)) { - if (fseeko(jcr->dir_bsock->spool_fd, 0, SEEK_END) != 0) { + if (fseeko(jcr->dir_bsock->m_spool_fd, 0, SEEK_END) != 0) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"), be.bstrerror()); goto bail_out; } - size = ftello(jcr->dir_bsock->spool_fd); + size = ftello(jcr->dir_bsock->m_spool_fd); if (size < 0) { berrno be; Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"), @@ -641,9 +641,9 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs) { POOLMEM *name = get_pool_memory(PM_MESSAGE); - make_unique_spool_filename(jcr, &name, bs->fd); - bs->spool_fd = fopen(name, "w+b"); - if (!bs->spool_fd) { + make_unique_spool_filename(jcr, &name, bs->m_fd); + bs->m_spool_fd = fopen(name, "w+b"); + if (!bs->m_spool_fd) { berrno be; Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name, be.bstrerror()); @@ -661,7 +661,7 @@ bool close_attr_spool_file(JCR *jcr, BSOCK *bs) { POOLMEM *name; - if (!bs->spool_fd) { + if (!bs->m_spool_fd) { return true; } name = get_pool_memory(PM_MESSAGE); @@ -669,11 +669,11 @@ bool close_attr_spool_file(JCR *jcr, BSOCK *bs) spool_stats.attr_jobs--; spool_stats.total_attr_jobs++; V(mutex); - make_unique_spool_filename(jcr, &name, bs->fd); - fclose(bs->spool_fd); + make_unique_spool_filename(jcr, &name, bs->m_fd); + fclose(bs->m_spool_fd); unlink(name); free_pool_memory(name); - bs->spool_fd = NULL; - bs->spool = false; + bs->m_spool_fd = NULL; + bs->m_spool = false; return true; } diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index 00ebed2fd7..72de76b37c 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -412,7 +412,7 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), len = Mmsg(msg, _(" FDReadSeqNo=%s in_msg=%u out_msg=%d fd=%d\n"), edit_uint64_with_commas(jcr->file_bsock->read_seqno, b1), jcr->file_bsock->in_msg_no, jcr->file_bsock->out_msg_no, - jcr->file_bsock->fd); + jcr->file_bsock->m_fd); sendit(msg, len, arg); } else { len = Mmsg(msg, _(" FDSocket closed\n")); diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 04dc82620c..0dcd88bd23 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -555,7 +555,7 @@ void terminate_stored(int sig) set_jcr_job_status(jcr, JS_Canceled); fd = jcr->file_bsock; if (fd) { - fd->timed_out = true; + fd->m_timed_out = true; Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId); pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); /* ***FIXME*** wiffle through all dcrs */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 4d6dc1ed60..1f6868101b 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,6 +2,7 @@ General: 20May07 +kes Move more bnet functions into the BSOCK class. kes Fix tray-monitor by not requiring a timer interval in bnet_connect() kes Complete change of berrno strerror() method to bstrerror() Release: 2.1.10 beta -- 2.39.5