src/stored/fd_cmds.c
void do_client_commands(JCR *jcr)
{
   int i;
   bool found, quit;
   BSOCK *fd = jcr->file_bsock;

   if (!fd) {
      return;
   }
   fd->set_jcr(jcr);
   for (quit=false; !quit;) {
      int stat;

      /* Read command coming from the File daemon */
      stat = fd->recv();
      if (fd->is_stop()) {            /* hard eof or error */
         break;                       /* connection terminated */
      }
      if (stat <= 0) {
         continue;                    /* ignore signals and zero length msgs */
      }
      Dmsg1(110, "<filed: %s", fd->msg);
      found = false;
      for (i=0; fd_cmds[i].cmd; i++) {
         if (strncmp(fd_cmds[i].cmd, fd->msg, strlen(fd_cmds[i].cmd)) == 0) {
            found = true;               /* indicate command found */
            jcr->errmsg[0] = 0;
            if (!fd_cmds[i].func(jcr)) {    /* do command */
               /* Note fd->msg command may be destroyed by comm activity */
               if (!job_canceled(jcr)) {
                  strip_trailing_junk(fd->msg);
                  if (jcr->errmsg[0]) {
                     strip_trailing_junk(jcr->errmsg);
                     Jmsg2(jcr, M_FATAL, 0, _("Command error with FD msg=\"%s\", SD hanging up. ERR=%s\n"),
                           fd->msg, jcr->errmsg);
                  } else {
                     Jmsg1(jcr, M_FATAL, 0, _("Command error with FD msg=\"%s\", SD hanging up.\n"),
                        fd->msg);
                  }
                  jcr->setJobStatus(JS_ErrorTerminated);
               }
               quit = true;
            }
            break;
         }
      }
      if (!found) {                   /* command not found */
         if (!job_canceled(jcr)) {
            Jmsg1(jcr, M_FATAL, 0, _("FD command not found: %s\n"), fd->msg);
            Dmsg1(110, "<filed: Command not found: %s\n", fd->msg);
         }
         fd->fsend(ferrmsg);
         break;
      }
   }
   fd->signal(BNET_TERMINATE);        /* signal to FD job is done */
}
/*
 * Now talk to the Client (FD/SD) and do what he says
 */
Now talk to the Client (FD/SD) and do what he says
Now talk to the Client ( FD / SD ) and do what he says
void do_client_commands(JCR *jcr)
{
   int i;
   bool found, quit;
   BSOCK *fd = jcr->file_bsock;
   if (!fd) {
      return;
   }
   fd->set_jcr(jcr);
   for (quit=false; !quit;) {
      int stat;
      stat = fd->recv();
      if (fd->is_stop()) {            
         break;                       
      }
      if (stat <= 0) {
         continue;                    
      }
      Dmsg1(110, "<filed: %s", fd->msg);
      found = false;
      for (i=0; fd_cmds[i].cmd; i++) {
         if (strncmp(fd_cmds[i].cmd, fd->msg, strlen(fd_cmds[i].cmd)) == 0) {
            found = true;               
            jcr->errmsg[0] = 0;
            if (!fd_cmds[i].func(jcr)) {    
               if (!job_canceled(jcr)) {
                  strip_trailing_junk(fd->msg);
                  if (jcr->errmsg[0]) {
                     strip_trailing_junk(jcr->errmsg);
                     Jmsg2(jcr, M_FATAL, 0, _("Command error with FD msg=\"%s\", SD hanging up. ERR=%s\n"),
                           fd->msg, jcr->errmsg);
                  } else {
                     Jmsg1(jcr, M_FATAL, 0, _("Command error with FD msg=\"%s\", SD hanging up.\n"),
                        fd->msg);
                  }
                  jcr->setJobStatus(JS_ErrorTerminated);
               }
               quit = true;
            }
            break;
         }
      }
      if (!found) {                   
         if (!job_canceled(jcr)) {
            Jmsg1(jcr, M_FATAL, 0, _("FD command not found: %s\n"), fd->msg);
            Dmsg1(110, "<filed: Command not found: %s\n", fd->msg);
         }
         fd->fsend(ferrmsg);
         break;
      }
   }
   fd->signal(BNET_TERMINATE);        
}
void do_client_commands ( JCR * jcr ) { int i ; bool found , quit ; BSOCK * fd = jcr -> file_bsock ; if ( ! fd ) { return ; } fd -> set_jcr ( jcr ) ; for ( quit = false ; ! quit ; ) { int stat ; stat = fd -> recv ( ) ; if ( fd -> is_stop ( ) ) { break ; } if ( stat <= 0 ) { continue ; } Dmsg1 ( 110 , " " , fd -> msg ) ; found = false ; for ( i = 0 ; fd_cmds [ i ] . cmd ; i ++ ) { if ( strncmp ( fd_cmds [ i ] . cmd , fd -> msg , strlen ( fd_cmds [ i ] . cmd ) ) == 0 ) { found = true ; jcr -> errmsg [ 0 ] = 0 ; if ( ! fd_cmds [ i ] . func ( jcr ) ) { if ( ! job_canceled ( jcr ) ) { strip_trailing_junk ( fd -> msg ) ; if ( jcr -> errmsg [ 0 ] ) { strip_trailing_junk ( jcr -> errmsg ) ; Jmsg2 ( jcr , M_FATAL , 0 , _ ( " \" \" \n " ) , fd -> msg , jcr -> errmsg ) ; } else { Jmsg1 ( jcr , M_FATAL , 0 , _ ( " \" \" \n " ) , fd -> msg ) ; } jcr -> setJobStatus ( JS_ErrorTerminated ) ; } quit = true ; } break ; } } if ( ! found ) { if ( ! job_canceled ( jcr ) ) { Jmsg1 ( jcr , M_FATAL , 0 , _ ( " \n " ) , fd -> msg ) ; Dmsg1 ( 110 , " \n " , fd -> msg ) ; } fd -> fsend ( ferrmsg ) ; break ; } } fd -> signal ( BNET_TERMINATE ) ; }
Now talk to the Client (FD/SD) and do what he says
Now talk to the Client ( FD / SD ) and do what he says
/* Read command coming from the File daemon */ /* hard eof or error */ /* connection terminated */ /* ignore signals and zero length msgs */ /* indicate command found */ /* do command */ /* Note fd->msg command may be destroyed by comm activity */ /* command not found */ /* signal to FD job is done */