src/worker.cc
// Receive a page. Return false if a page was not received.
Receive a page. Return false if a page was not received.
Receive a page . Return false if a page was not received .
bool NetworkThread::ReceivePage(int sock, struct page_entry *dst) {
  int page_length = sat_->page_length();
  char *address = static_cast<char*>(dst->addr);
  int size = page_length;
  while (size) {
    int transferred = recv(sock, address + (page_length - size), size, 0);
    if ((transferred == 0) || (transferred == -1)) {
      if (IsNetworkStopSet()) {
        int err = errno;
        if (transferred == 0 && err == 0) {
          logprintf(0, "Log: Net thread did not receive any data, exiting.\n");
        } else {
          char buf[256] = "";
          sat_strerror(err, buf, sizeof(buf));
          logprintf(0, "Process Error: Thread %d, "
                       "Network read failed, bailing (%s).\n",
                    thread_num_, buf);
          status_ = false;
          logprintf(0, "Log: recv(%d, address %x, size %x, 0) == %x, err %d\n",
                    sock, address + (page_length - size),
                    size, transferred, err);
          if ((transferred == 0) &&
              (page_length - size < 512) &&
              (page_length - size > 0)) {
            address[page_length - size] = 0;
            logprintf(0, "Log: received  %d bytes: '%s'\n",
                      page_length - size, address);
          }
        }
      }
      return false;
    }
    size = size - transferred;
  }
  return true;
}
bool NetworkThread :: ReceivePage ( int sock , struct page_entry * dst ) { int page_length = sat_ -> page_length ( ) ; char * address = static_cast < char * > ( dst -> addr ) ; int size = page_length ; while ( size ) { int transferred = recv ( sock , address + ( page_length - size ) , size , 0 ) ; if ( ( transferred == 0 ) || ( transferred == -1 ) ) { if ( IsNetworkStopSet ( ) ) { int err = errno ; if ( transferred == 0 && err == 0 ) { logprintf ( 0 , " \n " ) ; } else { char buf [ 256 ] = " " ; sat_strerror ( err , buf , sizeof ( buf ) ) ; logprintf ( 0 , " " " \n " , thread_num_ , buf ) ; status_ = false ; logprintf ( 0 , " \n " , sock , address + ( page_length - size ) , size , transferred , err ) ; if ( ( transferred == 0 ) && ( page_length - size < 512 ) && ( page_length - size > 0 ) ) { address [ page_length - size ] = 0 ; logprintf ( 0 , " \n " , page_length - size , address ) ; } } } return false ; } size = size - transferred ; } return true ; }
Receive a page.
Receive a page .
// Maybe we will get our data back again, maybe not. // Typically network slave thread should exit as network master // thread stops sending data. // Two system setups will not sync exactly, // allow early exit, but log it. // Print why we failed. // Print arguments and results. // Print null terminated data received, to see who's been // sending us supicious unwanted data.