src/worker.cc
// Network reflector IO work loop. Execute until marked done.
// Return false on fatal software error.
Network reflector IO work loop. Execute until marked done.
Return false on fatal software error.
Network reflector IO work loop . Execute until marked done . Return false on fatal software error .
bool NetworkSlaveThread::Work() {
  logprintf(9, "Log: Starting network slave thread %d\n",
            thread_num_);
  int sock = sock_;
  if (!sock) {
    status_ = false;
    return false;
  }
  int64 loops = 0;
  void *local_page = NULL;
#ifdef HAVE_POSIX_MEMALIGN
  int result = posix_memalign(&local_page, 512, sat_->page_length());
#else
  local_page = memalign(512, sat_->page_length());
  int result = (local_page == 0);
#endif
  if (result) {
    logprintf(0, "Process Error: net slave posix_memalign "
                 "returned %d (fail)\n",
              result);
    status_ = false;
    return false;
  }
  struct page_entry page;
  page.addr = local_page;
  while (1) {
    if (!ReceivePage(sock, &page))
      break;
    if (!SendPage(sock, &page))
      break;
    loops++;
  }
  pages_copied_ = loops;
  status_ = true;
  CloseSocket(sock);
  logprintf(9,
            "Log: Completed %d: network slave thread status %d, "
            "%d pages copied\n",
            thread_num_, status_, pages_copied_);
  return true;
}
bool NetworkSlaveThread :: Work ( ) { logprintf ( 9 , " \n " , thread_num_ ) ; int sock = sock_ ; if ( ! sock ) { status_ = false ; return false ; } int64 loops = 0 ; void * local_page = NULL ; #ifdef HAVE_POSIX_MEMALIGN int result = posix_memalign ( & local_page , 512 , sat_ -> page_length ( ) ) ; #else local_page = memalign ( 512 , sat_ -> page_length ( ) ) ; int result = ( local_page == 0 ) ; #endif if ( result ) { logprintf ( 0 , " " " \n " , result ) ; status_ = false ; return false ; } struct page_entry page ; page . addr = local_page ; while ( 1 ) { if ( ! ReceivePage ( sock , & page ) ) break ; if ( ! SendPage ( sock , & page ) ) break ; loops ++ ; } pages_copied_ = loops ; status_ = true ; CloseSocket ( sock ) ; logprintf ( 9 , " " " \n " , thread_num_ , status_ , pages_copied_ ) ; return true ; }
Network reflector IO work loop.
Network reflector IO work loop .
// Verify that we have a socket. // Loop until done. // Init a local buffer for storing data. // This thread will continue to run as long as the thread on the other end of // the socket is still sending and receiving data. // Do the network read. // Do the network write. // No results provided from this type of thread. // Clean up.