Пример #1
1
        /* ===================================================== */   
        void handle_message( const connection_ptr& con, const message& m )
        { 
          try {
           chan_data& cdat = get_channel_data(con);
 
           ilog( "${msg_type}", ("msg_type", (bitname::message_type)m.msg_type ) );
           
           switch( (bitname::message_type)m.msg_type )
           {
               case name_inv_msg:
                 handle_name_inv( con, cdat, m.as<name_inv_message>() );
                 break;
               case block_inv_msg:
                 handle_block_inv( con, cdat, m.as<block_inv_message>() );
                 break;
               case get_name_inv_msg:
                 handle_get_name_inv( con, cdat, m.as<get_name_inv_message>() );
                 break;
               case get_headers_msg:
                 handle_get_headers( con, cdat, m.as<get_headers_message>() );
                 break;
               case get_block_msg:
                 handle_get_block( con, cdat, m.as<get_block_message>() );
                 break;
               case get_block_index_msg:
                 handle_get_block_index( con, cdat, m.as<get_block_index_message>() );
                 break;
               case get_name_header_msg:
                 handle_get_name( con, cdat, m.as<get_name_header_message>() );
                 break;
               case name_header_msg:
                 handle_name( con, cdat, m.as<name_header_message>() );
                 break;
               case block_index_msg:
                 handle_block_index( con, cdat, m.as<block_index_message>() );
                 break;
               case block_msg:
                 handle_block( con, cdat, m.as<block_message>() );
                 break;
               case headers_msg:
                 handle_headers( con, cdat, m.as<headers_message>() );
                 break;
               default:
                 FC_THROW_EXCEPTION( exception, "unknown bitname message type ${msg_type}", ("msg_type", m.msg_type ) );
           }
          } 
          catch ( fc::exception& e )
          {
            wlog( "${e}  ${from}", ("e",e.to_detail_string())("from",con->remote_endpoint()) );
          }
        }  // handle_message
Пример #2
0
  void tcp_socket::enable_keep_alives(const fc::microseconds& interval)
  {
    if (interval.count())
    {
      boost::asio::socket_base::keep_alive option(true);
      my->_sock.set_option(option);
#if defined _WIN32 || defined WIN32 || defined OS_WIN64 || defined _WIN64 || defined WIN64 || defined WINNT
      struct tcp_keepalive keepalive_settings;
      keepalive_settings.onoff = 1;
      keepalive_settings.keepalivetime = (ULONG)(interval.count() / fc::milliseconds(1).count());
      keepalive_settings.keepaliveinterval = (ULONG)(interval.count() / fc::milliseconds(1).count());

      DWORD dwBytesRet = 0;
      if (WSAIoctl(my->_sock.native(), SIO_KEEPALIVE_VALS, &keepalive_settings, sizeof(keepalive_settings),
                   NULL, 0, &dwBytesRet, NULL, NULL) == SOCKET_ERROR)
        wlog("Error setting TCP keepalive values");
#elif !defined(__clang__) || (__clang_major__ >= 6)
      // This should work for modern Linuxes and for OSX >= Mountain Lion
      int timeout_sec = interval.count() / fc::seconds(1).count();
      if (setsockopt(my->_sock.native(), IPPROTO_TCP, 
      #if defined( __APPLE__ )
                     TCP_KEEPALIVE,
       #else
                     TCP_KEEPIDLE, 
       #endif
                     (char*)&timeout_sec, sizeof(timeout_sec)) < 0)
        wlog("Error setting TCP keepalive idle time");
# if !defined(__APPLE__) || defined(TCP_KEEPINTVL) // TCP_KEEPINTVL not defined before 10.9
      if (setsockopt(my->_sock.native(), IPPROTO_TCP, TCP_KEEPINTVL, 
                     (char*)&timeout_sec, sizeof(timeout_sec)) < 0)
        wlog("Error setting TCP keepalive interval");
# endif // !__APPLE__ || TCP_KEEPINTVL
#endif // !WIN32
    }
    else
    {
      boost::asio::socket_base::keep_alive option(false);
      my->_sock.set_option(option);
    }
  }
                  bool get_next_bid()
                  { try {
                     if( _current_bid && _current_bid->get_quantity().amount > 0 )
                        return _current_bid.valid();

                     _current_bid.reset();
                     if( _bid_itr.valid() )
                     {
                        auto bid = market_order( bid_order, _bid_itr.key(), _bid_itr.value() );
                        if( bid.get_price().quote_asset_id == _quote_id &&
                            bid.get_price().base_asset_id == _base_id )
                        {
                            _current_bid = bid;
                        }
                     }

                     if( _short_itr.valid() )
                     {
                        auto bid = market_order( short_order, _short_itr.key(), _short_itr.value() );
                        wlog( "SHORT ITER VALID: ${o}", ("o",bid) );
                        if( bid.get_price().quote_asset_id == _quote_id &&
                            bid.get_price().base_asset_id == _base_id )
                        {
                            if( !_current_bid || _current_bid->get_price() < bid.get_price() )
                            {
                               --_short_itr;
                               _current_bid = bid;
                               ilog( "returning ${v}", ("v",_current_bid.valid() ) );
                               return _current_bid.valid();
                            }
                        }
                     }
                     else
                     {
                        wlog( "           No Shorts         ****   " );
                     }
                     if( _bid_itr.valid() ) --_bid_itr;
                     return _current_bid.valid();
                  } FC_CAPTURE_AND_RETHROW() }
Пример #4
0
struct MangleMask* mangle_new()
{
    struct MangleMask* self=NULL;

    self = calloc(1, sizeof(struct MangleMask));
    if (self == NULL) {
        wlog("Failed to allocate MangleMask\n");
        return NULL;
    }

    mangle_clear(self);
    return self;
}
Пример #5
0
bts::blockchain::chain_database_ptr load_and_configure_chain_database(const fc::path& datadir,
                                                                      const boost::program_options::variables_map& option_variables)
{
  auto dns_chain = std::make_shared<bts::dns::dns_db>();
  dns_chain->set_transaction_validator(std::make_shared<bts::dns::p2p::p2p_transaction_validator>(dns_chain.get()));
  bts::blockchain::chain_database_ptr chain = dns_chain;
  chain->open( datadir / "chain", true );
  if (option_variables.count("trustee-address"))
    chain->set_trustee(bts::blockchain::address(option_variables["trustee-address"].as<std::string>()));

  if (option_variables.count("genesis-json"))
  {
    if (chain->head_block_num() == trx_num::invalid_block_num)
    {
      fc::path genesis_json_file(option_variables["genesis-json"].as<std::string>());
      bts::blockchain::trx_block genesis_block;
      try
      {
        genesis_block = bts::net::create_test_genesis_block(genesis_json_file);
      }
      catch (fc::exception& e)
      {
        wlog("Error creating genesis block from file ${filename}: ${e}", ("filename", genesis_json_file)("e", e.to_string()));
        return chain;
      }
      try
      {
        chain->push_block(genesis_block);
      }
      catch ( const fc::exception& e )
      {
        wlog( "error pushing genesis block to blockchain database: ${e}", ("e", e.to_detail_string() ) );
      }
    }
    else
      wlog("Ignoring genesis-json command-line argument because our blockchain already has a genesis block");
  }
  return chain;
}
Пример #6
0
 database_api::~database_api()
 {
    try {
       if(_broadcast_changes_complete.valid())
       {
          _broadcast_changes_complete.cancel();
          _broadcast_changes_complete.wait();
       }
    } catch (const fc::exception& e)
    {
       wlog("${e}", ("e",e.to_detail_string()));
    }
 }
Пример #7
0
 server::~server()
 {
    ilog( "waiting for block generation loop to exit" );
    try {
       my->_block_gen_loop_complete.cancel();
       my->_block_gen_loop_complete.wait();
    } 
    catch ( const fc::canceled_exception& e ){}
    catch ( const fc::exception& e )
    {
       wlog( "${e}", ("e",e.to_detail_string()) );
    }
 }
Пример #8
0
 void read_loop() {
    while( !m_done ) {
      tornet::rpc::message msg;
      tornet::rpc::raw::unpack(udt_chan,msg);
      switch( msg.type ) {
        case message::notice: self.handle_notice(msg); break;
        case message::call:   self.handle_call(msg);   break;
        case message::result: self.handle_result(msg); break;
        case message::error:  self.handle_error(msg);  break;
        default: 
          wlog( "invalid message type %1%", int( msg.type ) );
      };
    }
 }
Пример #9
0
static void files_attr(xmpp_stanza_t *stanza) {
  int rc; /* Return code */

  rc = pthread_mutex_lock(&mutex);
  wsyserr(rc != 0, "pthread_mutex_lock");

  char *error_attr = xmpp_stanza_get_attribute(stanza, "error"); /* error attribute */
  wfatal(error_attr == NULL, "no error attribute in files stanza");

  if (strcmp(error_attr, "0") != 0) {
    wlog("Error in attributes: %s", error_attr);
    attributes.is_valid = -1;
  } else {
    char *type_attr = xmpp_stanza_get_attribute(stanza, "type"); /* type attribute */
    wfatal(type_attr == NULL, "no type attribute in files stanza");

    if (strcmp(type_attr, "directory") == 0) {
      attributes.is_valid = 1;
      attributes.type = DIR;
    } else if (strcmp(type_attr, "file") == 0) {
      attributes.is_valid = 1;
      attributes.type = REG;
    } else {
      werr("Unknown type: %s", type_attr);
      attributes.is_valid = -1;
    }

    char *size_attr = xmpp_stanza_get_attribute(stanza, "size"); /* size */
    if (size_attr == NULL) {
      werr("xmpp_stanza_get_attribute attribute = size (%s)", xmpp_stanza_get_attribute(stanza, "path"));
      attributes.size = 0;
    } else {
      char *endptr; /* strtol endptr */
      long int size = strtol(size_attr, &endptr, 10);
      if (*endptr != '\0') {
        werr("strtol error: str = %s, val = %ld", size_attr, size);
        attributes.size = 0;
      }
      attributes.size = size;
    }
  }

  signal_attr = true;

  rc = pthread_cond_signal(&cond);
  wsyserr(rc != 0, "pthread_cond_signal");

  rc = pthread_mutex_unlock(&mutex);
  wsyserr(rc != 0, "pthread_mutex_unlock");
}
Пример #10
0
upnp_service::~upnp_service()
{
  try {
      my->done = true;
      my->upnp_thread.quit();
      my->map_port_complete.wait();
  } 
  catch ( const fc::canceled_exception& e )
  {} // expected
  catch ( const fc::exception& e )
  {
      wlog( "unexpected exception\n ${e}", ("e", e.to_detail_string() ) );
  }
}
Пример #11
0
  void profile::open( const fc::path& profile_dir, const std::string& password )
  { try {
      ilog("opening profile: ${profile_dir}",("profile_dir",profile_dir));
      my->_profile_name = profile_dir.filename().generic_wstring();

      fc::create_directories( profile_dir );
      fc::create_directories( profile_dir / "addressbook" );
      fc::create_directories( profile_dir / "idents" );
      fc::create_directories( profile_dir / "mail" );
      fc::create_directories( profile_dir / "mail" / "inbox" );
      fc::create_directories( profile_dir / "mail" / "draft" );
      fc::create_directories( profile_dir / "mail" / "pending" );
      fc::create_directories( profile_dir / "mail" / "sent" );
      fc::create_directories( profile_dir / "chat" );
      fc::create_directories( profile_dir / "request" );
      fc::create_directories( profile_dir / "authorization" );

      ilog("loading master key file:" KEYHOTEE_MASTER_KEY_FILE);
      auto profile_cfg_key         = fc::sha512::hash( password.c_str(), password.size() );
      std::vector<char> stretched_seed_data;
      try {
        stretched_seed_data     = fc::aes_load( profile_dir / KEYHOTEE_MASTER_KEY_FILE, profile_cfg_key );
      }
      catch (fc::exception& /* e */)
      { //try to open legacy name for key file
        wlog("Could not open " KEYHOTEE_MASTER_KEY_FILE ", trying to open legacy key file (.strecthed_seed).");
        stretched_seed_data     = fc::aes_load( profile_dir / ".stretched_seed", profile_cfg_key );
      }

      ilog("opening profile databases");
      my->_keychain.set_seed( fc::raw::unpack<fc::sha512>(stretched_seed_data) );
      my->_addressbook->open( profile_dir / "addressbook", profile_cfg_key );
      my->_idents.open( profile_dir / "idents" );
      my->_inbox_db->open( profile_dir / "mail" / "inbox", profile_cfg_key );
      my->_draft_db->open( profile_dir / "mail" / "draft", profile_cfg_key );
      my->_pending_db->open( profile_dir / "mail" / "pending", profile_cfg_key );
      my->_sent_db->open( profile_dir / "mail" / "sent", profile_cfg_key );
      my->_chat_db->open( profile_dir / "chat", profile_cfg_key );
      my->_request_db->open( profile_dir / "request", profile_cfg_key );
      my->_auth_db->open( profile_dir / "authorization", profile_cfg_key );
      my->_last_sync_time.open( profile_dir / "mail" / "last_recv", true );
      if( *my->_last_sync_time == fc::time_point())
      {
          *my->_last_sync_time = fc::time_point::now() - fc::days(5);
          ilog("set last_sync_time to ${t}",("t",*my->_last_sync_time));
      }
      else
          ilog("loaded last_sync_time = ${t}",("t",*my->_last_sync_time));
    ilog("finished opening profile");
  } FC_RETHROW_EXCEPTIONS( warn, "", ("profile_dir",profile_dir) ) }
Пример #12
0
 void connection::exec_sync_loop()
 {
     ilog( "exec sync loop" );
     my->exec_sync_loop_complete = fc::async( [=]() 
     {
       try {
        // ilog( "in exec sync loop" );
         while( !my->exec_sync_loop_complete.canceled() )
         {
            //ilog( "sync time ${t}", ("t",my->_sync_time) );
            auto itr = my->_mail_db->lower_bound( my->_sync_time );
            if( !itr.valid() )
            {
             ilog( "no valid message found" );
            }
            while( itr.valid() && !my->exec_sync_loop_complete.canceled() )
            {
               if( itr.key() > my->_sync_time )
               {
                  send( message( itr.value() ) );
                  my->_sync_time = itr.key();
               }
               ++itr;
            }
            fc::usleep( fc::seconds(15) );
         }
       } 
       catch ( const fc::exception& e )
       {
          wlog( "${e}", ("e", e.to_detail_string() ) );
       }
       catch ( ... )
       {
          wlog("other exeception" );
       }
     });
 }
Пример #13
0
upnp_service::~upnp_service()
{
  try 
  {
      my->done = true;
      if( my->map_port_complete.valid() )
         my->map_port_complete.cancel_and_wait();
  } 
  catch ( const fc::canceled_exception& )
  {} // expected
  catch ( const fc::exception& e )
  {
      wlog( "unexpected exception\n ${e}", ("e", e.to_detail_string() ) );
  }
}
Пример #14
0
/*********************************************************************
 return RET_NOK on error
 *********************************************************************/
ret_code_t network_connect(context_t * context, const char * hostname)
{
	IPaddress ip;
	TCPsocket socket;

	wlog(LOGUSER, "Trying to connect to %s:%d", hostname, PORT);

	if (SDLNet_Init() < 0)
	{
		werr(LOGUSER, "Can't init SDLNet: %s\n", SDLNet_GetError());
		return RET_NOK;
	}

	if (SDLNet_ResolveHost(&ip, hostname, PORT) < 0)
	{
		werr(LOGUSER, "Can't resolve %s:%d : %s\n", hostname, PORT,
				SDLNet_GetError());
		return RET_NOK;
	}

	if (!(socket = SDLNet_TCP_Open(&ip)))
	{
		werr(LOGUSER, "Can't connect to %s:%d : %s\n", hostname, PORT,
				SDLNet_GetError());
		return RET_NOK;
	}

	wlog(LOGUSER, "Connected to %s:%d", hostname, PORT);

	context_set_hostname(context, hostname);
	context_set_socket(context, socket);

	SDL_CreateThread(async_recv, "async_recv", (void*) context);

	return RET_OK;
}
Пример #15
0
std::string clean_name( const std::string& name )
{
   std::string result;
   const static std::string prefix = "graphene::chain::";
   const static std::string suffix = "_operation";
   // graphene::chain::.*_operation
   if(    (name.size() >= prefix.size() + suffix.size())
       && (name.substr( 0, prefix.size() ) == prefix)
       && (name.substr( name.size()-suffix.size(), suffix.size() ) == suffix )
     )
        return name.substr( prefix.size(), name.size() - prefix.size() - suffix.size() );

   wlog( "don't know how to clean name: ${name}", ("name", name) );
   return name;
}
Пример #16
0
      void process_connection( connection con )
      {
          try 
          {
             con.send( message(version_message(1)) );

             while( true )
             {
                 auto msg = con.recv();
                 switch( msg.msg_type.value )
                 {
                    case version_msg:
                       FC_ASSERT( msg.as<version_message>().version == 1 );
                       break;
                    case get_block_msg:
                       break;
                    case get_transaction_msg:
                       break;
                    case block_msg:
                       wlog( "No one sends me blocks!" );
                       break;
                    case trx_block_msg:
                       wlog( "No one sends me blocks!" );
                       break;
                    case transaction_msg:
                       break;
                    default:
                       FC_ASSERT( !"Unknown Message Type", "Unknown message type ${msg}", ("msg",msg) );
                 }
             }
          } 
          catch ( const fc::exception& e )
          {
               connections.erase( con.sock->remote_endpoint() );
          }
      }
Пример #17
0
    void peer_connection::destroy()
    {
      try 
      {
        close_connection();
      } 
      catch ( ... ) 
      {
      }

      try 
      { 
        _send_queued_messages_done.cancel_and_wait(); 
      } 
      catch( const fc::exception& e )
      {
        wlog("Unexpected exception from peer_connection's send_queued_messages_task : ${e}", ("e", e));
      }
      catch( ... )
      {
        wlog("Unexpected exception from peer_connection's send_queued_messages_task");
      }
      
      try 
      { 
        accept_or_connect_task_done.cancel_and_wait(); 
      } 
      catch( const fc::exception& e )
      {
        wlog("Unexpected exception from peer_connection's accept_or_connect_task : ${e}", ("e", e));
      }
      catch( ... )
      {
        wlog("Unexpected exception from peer_connection's accept_or_connect_task");
      }
    }
Пример #18
0
int mangle_read(struct MangleMask* self, const char* filename)
{
    int status=1;

    mangle_clear(self);
    self->filename=strdup(filename);
    self->fptr = fopen(filename,"r");
    if (self->fptr == NULL) {
        wlog("Failed to open file for reading: %s\n",filename);
        status=0;
        goto _mangle_read_bail;
    }

    if (!mangle_read_header(self)) {
        status=0;
        goto _mangle_read_bail;
    }

    if (self->verbose)
        wlog("reading %ld polygons\n", self->npoly);
    self->poly_vec = read_polygons(self->fptr, self->npoly);
    if (!self->poly_vec) {
        status=0;
        goto _mangle_read_bail;
    }

    mangle_calc_area_and_maxpix(self);

    if (!set_pixel_map(self)) {
        status=0;
        goto _mangle_read_bail;
    }

_mangle_read_bail:
    return status;
}
Пример #19
0
struct gmix *get_gmix(size_t ngauss)
{
    if (ngauss != 2) {
        wlog("only ngauss==2 for now\n");
        exit(EXIT_FAILURE);
    }
    struct gmix *gmix = gmix_new(ngauss);
    struct gauss *gptr = gmix->data;

    gauss_set(&gptr[0],
            0.6, 15., 15., 2.0, 0.0, 1.7);
    gauss_set(&gptr[1],
            0.4, 10., 8., 1.5, .3, 4.);
    return gmix;
}
Пример #20
0
void mutex::lock() {
    cmt::context* n  = 0;
    cmt::context* cc = cmt::thread::current().current_context();
    {
        boost::unique_lock<cmt::spin_yield_lock> lock(m_blist_lock);
        if( !m_blist ) {
            m_blist = cc;
            return;
        }

        // allow recusive locks
        if ( get_tail( m_blist, n ) == cc ) {
            return;
        }
        cc->next_blocked = m_blist;
        m_blist = cc;

        int cnt = 0;
        auto i = m_blist;
        while( i ) {
            i = i->next_blocked;
            ++cnt;
        }
        wlog( "wait queue len %1%", cnt );

    }

    try {
        cmt::thread::current().yield(false);
        BOOST_ASSERT( cc->next_blocked == 0 );
    } catch ( ... ) {
        wlog( "lock with throw %1% %2%",this, boost::current_exception_diagnostic_information() );
        cleanup( *this, m_blist_lock, m_blist, cc);
        throw;
    }
}
void TConnectionProcessor::received_text(const bts::bitchat::decrypted_message& msg)
{
  try
  {
    auto aBook = Profile->get_addressbook();
    fc::optional<bts::addressbook::wallet_contact> optContact;

    if(msg.from_key)
      optContact = aBook->get_contact_by_public_key(*msg.from_key);

    if(optContact)
    {
      wlog("Received text from known contact!");
      if(!_chat_allow_flag ||
        (*optContact).auth_status == bts::addressbook::authorization_status::accepted ||
        (*optContact).auth_status == bts::addressbook::authorization_status::accepted_chat)
      {
        Profile->get_chat_db()->store_message(msg, nullptr);
        auto chatMsg = msg.as<bts::bitchat::private_text_message>();
        Sink->OnReceivedChatMessage(*optContact, chatMsg, msg.sig_time);
      }
      else
      {
        wlog("Chat message from known contact rejected!");
      }
    }
    else
    {
      elog("Received chat message from unknown contact/missing sender - ignoring");
    }
  }
  catch(const fc::exception& e)
  {
    elog("${e}", ("e", e.to_detail_string()));
  }
}
Пример #22
0
Файл: iosyn.c Проект: dhaley/dcp
/*	iotest - do various io syscalls */
int
iotest()
{
	char	*fname = "/usr/tmp/foobar";
	int	fd;	/* file descriptor for raw IO */
	int	fd2;	/* file descriptor for raw IO */
	int	k;	/* temp value for loop */
	char	buf[BUFSIZE];
	unsigned long	size = 0;

	/* Log the regular read */
	wlog("start of iotest", NULL);

	/* create an empty file */
	fd = creat(fname, 0666);

	/* dup the file descriptor */
	fd2 = dup(fd);
	close(fd2);
	close(fd);

	/* now open the empty file */
	fd = open(fname, O_RDONLY);

	/* loop, reading into the buffer */
	size = 0;
	for(;;) {
		k = read(fd, buf, BUFSIZE);
		if (k < 0) {
			fprintf(stderr, "++ERROR reading %s, error %d\n",
				fname, errno );
		} else {
			size = size + k;
		}
		if (k != BUFSIZE) {
			/* close the file */
			close(fd);

			/* short eread = EOF */
			break;
		}
	}

	/* remove the file */
	unlink(fname);

	return 0;
}
Пример #23
0
/****************************************************
Remove an entry from the DB
******************************************************/
void entry_remove(char * filename)
{
	config_t * old_config;

	wlog(LOGDEBUG,"Removing entry : %s",filename);
	/* Clean-up old anim if any */
	SDL_LockMutex(entry_mutex);
	old_config = (config_t*)list_find(entry_list,filename);
	if( old_config ) {
		free_config(old_config);
	}

	list_update(&entry_list,filename,NULL);

	SDL_UnlockMutex(entry_mutex);
}
Пример #24
0
 client::~client()
 {
    try {
       if( my->_trustee_loop_complete.valid() )
       {
          my->_trustee_loop_complete.cancel();
          ilog( "waiting for trustee loop to complete" );
          my->_trustee_loop_complete.wait();
       } 
    }
    catch ( const fc::canceled_exception& ) {}
    catch ( const fc::exception& e )
    {
       wlog( "${e}", ("e",e.to_detail_string() ) );
    }
 }
Пример #25
0
static void kill_job(child_process *cp, int reason)
{
	int ret;
	struct rusage ru;

	/* brutal but efficient */
	ret = kill(cp->pid, SIGKILL);
	if (ret < 0) {
		if (errno == ESRCH) {
			finish_job(cp, reason);
			return;
		}
		wlog("kill(%d, SIGKILL) failed: %s\n", cp->pid, strerror(errno));
	}

	ret = wait4(cp->pid, &cp->ret, 0, &ru);
	finish_job(cp, reason);

#ifdef PLAY_NICE_IN_kill_job
	int i, sig = SIGTERM;

	pid = cp->pid;

	for (i = 0; i < 2; i++) {
		/* check one last time if the job is done */
		ret = check_completion(cp, WNOHANG);
		if (!ret || ret == -ECHILD) {
			/* check_completion ran finish_job() */
			return;
		}

		/* not done, so signal it. SIGTERM first and check again */
		errno = 0;
		ret = kill(pid, sig);
		if (ret < 0) {
			finish_job(cp, -errno);
		}
		sig = SIGKILL;
		check_completion(cp, WNOHANG);
		if (ret < 0) {
			finish_job(cp, errno);
		}
		usleep(50000);
	}
#endif /* PLAY_NICE_IN_kill_job */
}
Пример #26
0
LRESULT WINAPI KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
	char info[100] = { 0 };
	sprintf_s(info, 100, "code:%d,wp:%d,lp:%d\n", code, wParam, lParam);
	if (HSHELL_WINDOWACTIVATED == code ){
		HWND hwnd = (HWND)wParam;
		wchar_t title[100];
		GetWindowText(hwnd, title, 100);
		wlog(title);
	}
	else{
		log(info);

	}

	return CallNextHookEx(hHook, code, wParam, lParam);
}
Пример #27
0
int dup2(int fd, int fd2)
{
    // Call the close stub to avoid duplicating action logic.  This produces
    // different behavior in the case where fd is not active.
    close(fd2);
    fd_map_dump();

    wlog("dup2(%d, %d)", fd, fd2);
    int ret = real_dup2(fd, fd2);

    if (ret >= 0)
        fd_map_dup2(fd, fd2);

    fd_map_dump();

    return ret;
}
Пример #28
0
 void derivekeys( const std::string &passphrase )
 {
    if( seed_version == "4" )
    {
       try {
          derivekeys_v4( passphrase );
       }
       catch ( const fc::exception& e )
       {
          wlog( "${e}", ("e",e.to_detail_string()) );
       }
    }
    else
    {
       FC_THROW_EXCEPTION( exception, "failed to parse electrum wallet - unsupported seed_version" );
    }
 }
Пример #29
0
static void analyze_layout_in_grammar ()
	{ int nrpasses = 0;
	  warning ("analyzing layout...");
	  initial_analyze_layout_in_rules ();
	  do
	     { change = 0;
	       nrpasses++;
	       analyze_layout_for_rules ();
	     }
	  while (change);
	  hint ("needed %d pass%s for layout analysis", nrpasses,
		(nrpasses == 1)?"":"es");
	  if (full_verbose)
	     { wlog ("dumping layout analysis");
	       report_on_layout ();
	     };
	};
Пример #30
0
inline void pack( Stream& s, const steem::protocol::legacy_steem_asset_symbol_type& sym )
{
   switch( sym.ser )
   {
      case STEEM_SYMBOL_LEGACY_SER_1:
      case STEEM_SYMBOL_LEGACY_SER_2:
      case STEEM_SYMBOL_LEGACY_SER_3:
      case STEEM_SYMBOL_LEGACY_SER_4:
      case STEEM_SYMBOL_LEGACY_SER_5:
         wlog( "pack legacy serialization ${s}", ("s", sym.ser) );
      case STEEM_SYMBOL_SER:
         pack( s, sym.ser );
         break;
      default:
         FC_ASSERT( false, "Cannot serialize legacy symbol ${s}", ("s", sym.ser) );
   }
}