src/stored/read.c
static bool mac_record_cb(DCR *dcr, DEV_RECORD *rec)
{
   JCR *jcr = dcr->jcr;
   BSOCK *fd = jcr->file_bsock;
   char buf1[100], buf2[100];
   bool new_header = false;
   POOLMEM *save_msg;
   char ec1[50], ec2[50];
   bool ok = true;
   POOLMEM *wbuf = rec->data;;                 /* send buffer */
   uint32_t wsize = rec->data_len;             /* send size */

#ifdef xxx
   Pmsg5(000, "on entry     JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
      jcr->JobId,
      FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
#endif

   /* If label and not for us, discard it */
   if (rec->FileIndex < 0) {
      Dmsg1(100, "FileIndex=%d\n", rec->FileIndex);
      return true;
   }

   /*
    * For normal migration jobs, FileIndex values are sequential because
    *  we are dealing with one job.  However, for Vbackup (consolidation),
    *  we will be getting records from multiple jobs and writing them back
    *  out, so we need to ensure that the output FileIndex is sequential.
    *  We do so by detecting a FileIndex change and incrementing the
    *  JobFiles, which we then use as the output FileIndex.
    */
   if (rec->FileIndex >= 0) {
      /* If something changed, increment FileIndex */
      if (rec->VolSessionId != rec->last_VolSessionId ||
          rec->VolSessionTime != rec->last_VolSessionTime ||
          rec->FileIndex != rec->last_FileIndex ||
          rec->Stream != rec->last_Stream) {

         /* Something changed */
         if (rec->last_VolSessionId != 0) {        /* Not first record */
            Dmsg1(200, "Send EOD jobfiles=%d\n", jcr->JobFiles);
            if (!fd->signal(BNET_EOD)) {  /* End of previous stream */
               Jmsg(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
                        fd->bstrerror());
               return false;
            }
         }
         new_header = true;
         if (rec->FileIndex != rec->last_FileIndex) {
            jcr->JobFiles++;
         }
         rec->last_VolSessionId = rec->VolSessionId;
         rec->last_VolSessionTime = rec->VolSessionTime;
         rec->last_FileIndex = rec->FileIndex;
         rec->last_Stream = rec->Stream;
      }
      rec->FileIndex = jcr->JobFiles;     /* set sequential output FileIndex */
   }

   if (new_header) {
      new_header = false;
      Dmsg5(400, "Send header to FD: SessId=%u SessTim=%u FI=%s Strm=%s, len=%ld\n",
         rec->VolSessionId, rec->VolSessionTime,
         FI_to_ascii(ec1, rec->FileIndex),
         stream_to_ascii(ec2, rec->Stream, rec->FileIndex),
         wsize);

      /* Send data header to File daemon */
      if (!fd->fsend("%ld %ld %ld", rec->FileIndex, rec->Stream, wsize)) {
         Pmsg1(000, _(">filed: Error Hdr=%s\n"), fd->msg);
         Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
            fd->bstrerror());
         return false;
      }
   }

   Dmsg1(400, "FI=%d\n", rec->FileIndex);
   /* Send data record to File daemon */
   save_msg = fd->msg;          /* save fd message pointer */
   fd->msg = wbuf;         /* pass data directly to the FD */
   fd->msglen = wsize;
   jcr->JobBytes += wsize;   /* increment bytes this job */
   Dmsg1(400, ">filed: send %d bytes data.\n", fd->msglen);
   if (!fd->send()) {
      Pmsg1(000, _("Error sending to FD. ERR=%s\n"), fd->bstrerror());
      Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
         fd->bstrerror());
      ok = false;
   }
   fd->msg = save_msg;                /* restore fd message pointer */

   Dmsg5(500, "wrote_record JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
      jcr->JobId,
      FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);

   return ok;
}
/*
 * New routine after to SD->SD implementation
 * Called here for each record from read_records()
 *  Returns: true if OK
 *           false if error
 */
New routine after to SD->SD implementation
Called here for each record from read_records()
Returns: true if OK
false if error
New routine after to SD - > SD implementation Called here for each record from read_records () Returns : true if OK false if error
static bool mac_record_cb(DCR *dcr, DEV_RECORD *rec)
{
   JCR *jcr = dcr->jcr;
   BSOCK *fd = jcr->file_bsock;
   char buf1[100], buf2[100];
   bool new_header = false;
   POOLMEM *save_msg;
   char ec1[50], ec2[50];
   bool ok = true;
   POOLMEM *wbuf = rec->data;;                 
   uint32_t wsize = rec->data_len;             
#ifdef xxx
   Pmsg5(000, "on entry     JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
      jcr->JobId,
      FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
#endif
   if (rec->FileIndex < 0) {
      Dmsg1(100, "FileIndex=%d\n", rec->FileIndex);
      return true;
   }
   if (rec->FileIndex >= 0) {
      if (rec->VolSessionId != rec->last_VolSessionId ||
          rec->VolSessionTime != rec->last_VolSessionTime ||
          rec->FileIndex != rec->last_FileIndex ||
          rec->Stream != rec->last_Stream) {
         if (rec->last_VolSessionId != 0) {        
            Dmsg1(200, "Send EOD jobfiles=%d\n", jcr->JobFiles);
            if (!fd->signal(BNET_EOD)) {  
               Jmsg(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
                        fd->bstrerror());
               return false;
            }
         }
         new_header = true;
         if (rec->FileIndex != rec->last_FileIndex) {
            jcr->JobFiles++;
         }
         rec->last_VolSessionId = rec->VolSessionId;
         rec->last_VolSessionTime = rec->VolSessionTime;
         rec->last_FileIndex = rec->FileIndex;
         rec->last_Stream = rec->Stream;
      }
      rec->FileIndex = jcr->JobFiles;     
   }
   if (new_header) {
      new_header = false;
      Dmsg5(400, "Send header to FD: SessId=%u SessTim=%u FI=%s Strm=%s, len=%ld\n",
         rec->VolSessionId, rec->VolSessionTime,
         FI_to_ascii(ec1, rec->FileIndex),
         stream_to_ascii(ec2, rec->Stream, rec->FileIndex),
         wsize);
      if (!fd->fsend("%ld %ld %ld", rec->FileIndex, rec->Stream, wsize)) {
         Pmsg1(000, _(">filed: Error Hdr=%s\n"), fd->msg);
         Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
            fd->bstrerror());
         return false;
      }
   }
   Dmsg1(400, "FI=%d\n", rec->FileIndex);
   save_msg = fd->msg;          
   fd->msg = wbuf;         
   fd->msglen = wsize;
   jcr->JobBytes += wsize;   
   Dmsg1(400, ">filed: send %d bytes data.\n", fd->msglen);
   if (!fd->send()) {
      Pmsg1(000, _("Error sending to FD. ERR=%s\n"), fd->bstrerror());
      Jmsg1(jcr, M_FATAL, 0, _("Error sending to File daemon. ERR=%s\n"),
         fd->bstrerror());
      ok = false;
   }
   fd->msg = save_msg;                
   Dmsg5(500, "wrote_record JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
      jcr->JobId,
      FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
   return ok;
}
static bool mac_record_cb ( DCR * dcr , DEV_RECORD * rec ) { JCR * jcr = dcr -> jcr ; BSOCK * fd = jcr -> file_bsock ; char buf1 [ 100 ] , buf2 [ 100 ] ; bool new_header = false ; POOLMEM * save_msg ; char ec1 [ 50 ] , ec2 [ 50 ] ; bool ok = true ; POOLMEM * wbuf = rec -> data ; ; uint32_t wsize = rec -> data_len ; #ifdef xxx Pmsg5 ( 000 , " \n " , jcr -> JobId , FI_to_ascii ( buf1 , rec -> FileIndex ) , rec -> VolSessionId , stream_to_ascii ( buf2 , rec -> Stream , rec -> FileIndex ) , rec -> data_len ) ; #endif if ( rec -> FileIndex < 0 ) { Dmsg1 ( 100 , " \n " , rec -> FileIndex ) ; return true ; } if ( rec -> FileIndex >= 0 ) { if ( rec -> VolSessionId != rec -> last_VolSessionId || rec -> VolSessionTime != rec -> last_VolSessionTime || rec -> FileIndex != rec -> last_FileIndex || rec -> Stream != rec -> last_Stream ) { if ( rec -> last_VolSessionId != 0 ) { Dmsg1 ( 200 , " \n " , jcr -> JobFiles ) ; if ( ! fd -> signal ( BNET_EOD ) ) { Jmsg ( jcr , M_FATAL , 0 , _ ( " \n " ) , fd -> bstrerror ( ) ) ; return false ; } } new_header = true ; if ( rec -> FileIndex != rec -> last_FileIndex ) { jcr -> JobFiles ++ ; } rec -> last_VolSessionId = rec -> VolSessionId ; rec -> last_VolSessionTime = rec -> VolSessionTime ; rec -> last_FileIndex = rec -> FileIndex ; rec -> last_Stream = rec -> Stream ; } rec -> FileIndex = jcr -> JobFiles ; } if ( new_header ) { new_header = false ; Dmsg5 ( 400 , " \n " , rec -> VolSessionId , rec -> VolSessionTime , FI_to_ascii ( ec1 , rec -> FileIndex ) , stream_to_ascii ( ec2 , rec -> Stream , rec -> FileIndex ) , wsize ) ; if ( ! fd -> fsend ( " " , rec -> FileIndex , rec -> Stream , wsize ) ) { Pmsg1 ( 000 , _ ( " \n " ) , fd -> msg ) ; Jmsg1 ( jcr , M_FATAL , 0 , _ ( " \n " ) , fd -> bstrerror ( ) ) ; return false ; } } Dmsg1 ( 400 , " \n " , rec -> FileIndex ) ; save_msg = fd -> msg ; fd -> msg = wbuf ; fd -> msglen = wsize ; jcr -> JobBytes += wsize ; Dmsg1 ( 400 , " \n " , fd -> msglen ) ; if ( ! fd -> send ( ) ) { Pmsg1 ( 000 , _ ( " \n " ) , fd -> bstrerror ( ) ) ; Jmsg1 ( jcr , M_FATAL , 0 , _ ( " \n " ) , fd -> bstrerror ( ) ) ; ok = false ; } fd -> msg = save_msg ; Dmsg5 ( 500 , " \n " , jcr -> JobId , FI_to_ascii ( buf1 , rec -> FileIndex ) , rec -> VolSessionId , stream_to_ascii ( buf2 , rec -> Stream , rec -> FileIndex ) , rec -> data_len ) ; return ok ; }
New routine after to SD->SD implementation
 Called here for each record from read_records()
  Returns: true if OK
           false if error
New routine after to SD - > SD implementation Called here for each record from read_records () Returns : true if OK false if error
/* send buffer */ /* send size */ /* If label and not for us, discard it */ /*
    * For normal migration jobs, FileIndex values are sequential because
    *  we are dealing with one job.  However, for Vbackup (consolidation),
    *  we will be getting records from multiple jobs and writing them back
    *  out, so we need to ensure that the output FileIndex is sequential.
    *  We do so by detecting a FileIndex change and incrementing the
    *  JobFiles, which we then use as the output FileIndex.
    */ /* If something changed, increment FileIndex */ /* Something changed */ /* Not first record */ /* End of previous stream */ /* set sequential output FileIndex */ /* Send data header to File daemon */ /* Send data record to File daemon */ /* save fd message pointer */ /* pass data directly to the FD */ /* increment bytes this job */ /* restore fd message pointer */