示例#1
0
static void boot_resume_all(Restore& thing)
{
  timestamps = thing.as_vector<uint64_t>(); thing.go_next();
  // calculate time spent
  auto t1 = timestamps.back();
  auto t2 = OS::nanos_since_boot();
  // set final time
  timestamps.back() = t2 - t1;
  // retrieve binary blob
#ifdef DRIFTING_BINARY
  blob_location = thing.as_type<char*>(); thing.go_next();
  size_t len = thing.as_type<size_t> (); thing.go_next();

  bloberino = buffer_t{blob_location, blob_location + len};
#else
  bloberino = thing.as_buffer(); thing.go_next();
#endif
  thing.pop_marker();
}
示例#2
0
int main( int argc , char ** argv ) {
    Restore restore;
    return restore.main( argc , argv );
}
示例#3
0
void IrcServer::deserialize(Restore& thing)
{
  // we are re-entering this function, so store the counters statically
  chindex_t current_chan = 0;
  clindex_t current_client = 0;
  while (thing.is_end() == false)
  {
    switch (thing.get_id()) {
    case 1: {
      /// server
      size_t count;
      count = thing.as_type<size_t> (); thing.go_next();

      for (size_t i = 0; i < count; i++) {
        auto fir = thing.as_string();           thing.go_next();
        auto sec = thing.as_type<clindex_t> (); thing.go_next();
        clients.hash(fir, sec);
      }

      count = thing.as_type<size_t> (); thing.go_next();

      for (size_t i = 0; i < count; i++) {
        auto fir = thing.as_string();           thing.go_next();
        auto sec = thing.as_type<chindex_t> (); thing.go_next();
        channels.emplace_hash(fir, sec);
      }

      created_string = thing.as_string();       thing.go_next();
      created_ts     = thing.as_type<long> ();  thing.go_next();

      auto buf = thing.as_buffer();  thing.go_next();
      if (buf.size() >= sizeof(statcounters)) {
          memcpy(statcounters, buf.data(), buf.size());
      }
      //printf("* Resumed server, next id: %u\n", thing.get_id());
      break;
    }
    case 20: /// channels
      // create free channel indices
      while (channels.size() < thing.as_type<chindex_t> ())
      {
        channels.create_empty(*this);
      }
      thing.go_next();
      {
        // create empty channel
        auto& ch = channels.create_empty(*this);
        // deserialize rest of channel
        ch.deserialize(thing);
        // go to next channel id
        current_chan++;
      }
      break;
    case 50: /// clients
      // create free client indices
      while (clients.size() < thing.as_type<clindex_t> ())
      {
        clients.create_empty(*this);
      }
      thing.go_next();
      {
        // create empty client
        auto& cl = clients.create_empty(*this);
        // deserialize rest of client
        cl.deserialize(thing);
        // assign event handlers for client
        cl.assign_socket_dg();
        // go to next client id
        current_client++;
      }
      break;
    default:
      printf("Unknown ID: %u\n", thing.get_id());
      thing.go_next();
      break;
    }
  } // while (is_end() == false)
}
示例#4
0
void Channel::deserialize(Restore& thing)
{
  /// NOTE: index already consumed
  cmodes    = thing.as_type<uint16_t> (); thing.go_next();
  create_ts = thing.as_type<long> (); thing.go_next();
  cname     = thing.as_string();      thing.go_next();
  ctopic    = thing.as_string();      thing.go_next();
  ctopic_by = thing.as_string();      thing.go_next();
  ctopic_ts = thing.as_type<long> (); thing.go_next();
  ckey      = thing.as_string();      thing.go_next();
  climit    = thing.as_type<uint16_t> (); thing.go_next();

  // clients
  auto cli = thing.as_vector<clindex_t> (); thing.go_next();
  for (auto& cl : cli) clients_.push_back(cl);

  // chanops
  cli = thing.as_vector<clindex_t> (); thing.go_next();
  for (auto& cl : cli) chanops.insert(cl);

  // voices
  cli = thing.as_vector<clindex_t> (); thing.go_next();
  for (auto& cl : cli) voices.insert(cl);
  ///
}
示例#5
0
void Client::deserialize(Restore& thing)
{
  //printf("Deserializing client %u ...", get_id());
  /// NOTE: index already consumed
  // R, B, U
  regis     = thing.as_int(); thing.go_next();
  server_id = thing.as_int(); thing.go_next();
  umodes_   = thing.as_int(); thing.go_next();
  // TCP connection
  conn = thing.as_tcp_connection(server.client_stack().tcp());
  thing.go_next();
  // N U H
  nick_ = thing.as_string(); thing.go_next();
  user_ = thing.as_string(); thing.go_next();
  host_ = thing.as_string(); thing.go_next();
  // channels
  auto chans = thing.as_vector<chindex_t> ();
  for (auto& ch : chans) channels_.push_back(ch);
  thing.go_next();
  // readq
  readq.set(thing.as_string()); thing.go_next();
  // restart timeout timer
  this->restart_timeout();
}
示例#6
0
文件: restore.cpp 项目: xbsura/tokumx
int main( int argc , char ** argv, char ** envp ) {
    mongo::runGlobalInitializersOrDie(argc, argv, envp);
    Restore restore;
    return restore.main( argc , argv );
}