src/dird/msgchan.c
bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
                              int max_retry_time, int verbose)
{
   BSOCK *sd = jcr->store_bsock;
   STORE *store;
   utime_t heart_beat;

   if (is_bsock_open(sd)) {
      return true;                    /* already connected */
   }
   if (!sd) {
      sd = new_bsock();
   }

   /* If there is a write storage use it */
   if (jcr->wstore) {
      store = jcr->wstore;
   } else {
      store = jcr->rstore;
   }

   if (store->heartbeat_interval) {
      heart_beat = store->heartbeat_interval;
   } else {
      heart_beat = director->heartbeat_interval;
   }

   /*
    *  Open message channel with the Storage daemon
    */
   Dmsg2(100, "Connect to Storage daemon %s:%d\n", store->address,
      store->SDport);
   sd->set_source_address(director->DIRsrc_addr);
   if (!sd->connect(jcr, retry_interval, max_retry_time, heart_beat, _("Storage daemon"),
         store->address, NULL, store->SDport, verbose)) {

      if (!jcr->store_bsock) {  /* The bsock was locally created, so we free it here */
         free_bsock(sd);
      }
      sd = NULL;
   }

   if (sd == NULL) {
      return false;
   }
   sd->res = (RES *)store;        /* save pointer to other end */
   jcr->store_bsock = sd;

   if (!authenticate_storage_daemon(jcr, store)) {
      sd->close();
      return false;
   }
   return true;
}
/*
 * Establish a message channel connection with the Storage daemon
 * and perform authentication.
 */
Establish a message channel connection with the Storage daemon
and perform authentication.
Establish a message channel connection with the Storage daemon and perform authentication .
bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
                              int max_retry_time, int verbose)
{
   BSOCK *sd = jcr->store_bsock;
   STORE *store;
   utime_t heart_beat;
   if (is_bsock_open(sd)) {
      return true;                    
   }
   if (!sd) {
      sd = new_bsock();
   }
   if (jcr->wstore) {
      store = jcr->wstore;
   } else {
      store = jcr->rstore;
   }
   if (store->heartbeat_interval) {
      heart_beat = store->heartbeat_interval;
   } else {
      heart_beat = director->heartbeat_interval;
   }
   Dmsg2(100, "Connect to Storage daemon %s:%d\n", store->address,
      store->SDport);
   sd->set_source_address(director->DIRsrc_addr);
   if (!sd->connect(jcr, retry_interval, max_retry_time, heart_beat, _("Storage daemon"),
         store->address, NULL, store->SDport, verbose)) {
      if (!jcr->store_bsock) {  
         free_bsock(sd);
      }
      sd = NULL;
   }
   if (sd == NULL) {
      return false;
   }
   sd->res = (RES *)store;        
   jcr->store_bsock = sd;
   if (!authenticate_storage_daemon(jcr, store)) {
      sd->close();
      return false;
   }
   return true;
}
bool connect_to_storage_daemon ( JCR * jcr , int retry_interval , int max_retry_time , int verbose ) { BSOCK * sd = jcr -> store_bsock ; STORE * store ; utime_t heart_beat ; if ( is_bsock_open ( sd ) ) { return true ; } if ( ! sd ) { sd = new_bsock ( ) ; } if ( jcr -> wstore ) { store = jcr -> wstore ; } else { store = jcr -> rstore ; } if ( store -> heartbeat_interval ) { heart_beat = store -> heartbeat_interval ; } else { heart_beat = director -> heartbeat_interval ; } Dmsg2 ( 100 , " \n " , store -> address , store -> SDport ) ; sd -> set_source_address ( director -> DIRsrc_addr ) ; if ( ! sd -> connect ( jcr , retry_interval , max_retry_time , heart_beat , _ ( " " ) , store -> address , NULL , store -> SDport , verbose ) ) { if ( ! jcr -> store_bsock ) { free_bsock ( sd ) ; } sd = NULL ; } if ( sd == NULL ) { return false ; } sd -> res = ( RES * ) store ; jcr -> store_bsock = sd ; if ( ! authenticate_storage_daemon ( jcr , store ) ) { sd -> close ( ) ; return false ; } return true ; }
Establish a message channel connection with the Storage daemon
 and perform authentication.
Establish a message channel connection with the Storage daemon and perform authentication .
/* already connected */ /* If there is a write storage use it */ /*
    *  Open message channel with the Storage daemon
    */ /* The bsock was locally created, so we free it here */ /* save pointer to other end */