bool
  Eager_Transport_Queueing_Strategy::timer_check (
    const TAO::BufferingConstraint &buffering_constraint,
    const ACE_Time_Value &current_deadline,
    bool &set_timer,
    ACE_Time_Value &new_deadline) const
  {
    set_timer = false;

    if (!ACE_BIT_ENABLED (buffering_constraint.mode,
                          TAO::BUFFER_TIMEOUT))
      {
        return false;
      }

    // Compute the next deadline...
    ACE_Time_Value const now = ACE_OS::gettimeofday ();
    ACE_Time_Value timeout =
      this->time_conversion (buffering_constraint.timeout);
    new_deadline = now + timeout;

    // Check if the new deadline is more stringent, or if the deadline
    // has expired and thus must be reset anyway.
    if (current_deadline > new_deadline
        || current_deadline < now)
      {
        set_timer = true;
      }

    // ... if there is no deadline we don't want to schedule output (the
    // deadline will be set because set_timer is set to 1 in that case).
    // If there is a deadline but but it has not been reached, we
    // don't want to schedule any output either...
    if (current_deadline == ACE_Time_Value::zero
        || current_deadline >= now)
      {
        return false;
      }

    if (TAO_debug_level > 6)
      {
        TAOLIB_DEBUG ((LM_DEBUG,
                    "TAO (%P|%t) - TAO_Eager_Buffering_Sync_Strategy::timer_check, "
                    "Now = %u, Current = %u, New = %u\n",
                    now.msec (), current_deadline.msec (),
                    new_deadline.msec ()));
      }

    return true;
  }
예제 #2
0
파일: main.cpp 프로젝트: AbuMussabRaja/yarp
int main()
{
    ACE::init();
    fprintf(stderr, "Starting timing test\n");

    ACE_Time_Value now1,now2;

    ACE_High_Res_Timer timer;
    ACE_Profile_Timer profiler;
    ACE_Time_Value sleep;
    ACE_Time_Value elapsed;
    double avErrors[wTimes];
    
    int i,k;

    for(i=0;i<wTimes;i++)
        avErrors[i]=0;

    for(i=0;i<iterations;i++)
        {
            double req;
            double time;
            for(k=0;k<wTimes;k++)
                {
                    req=sleepT[k];
                    sleep.msec(sleepT[k]);
                    
                    now1 = ACE_OS::gettimeofday ();
                    
                    //ACE_OS::sleep(sleep);
                    usleep(sleep.sec()*1000000+sleep.usec()-1000);

                    now2 = ACE_OS::gettimeofday ();

                    time=(now2.sec()-now1.sec())*1000;
                    time+=(now2.usec()-now1.usec())/1000;
                    avErrors[k]+=fabs(req-time)/iterations;
                    fprintf(stderr, "*");
                }
            fprintf(stderr, "Completed %d out of %d\n", i+1, iterations);
        }

    for(i=0;i<wTimes;i++)
        {
            sleep.msec(sleepT[i]);
            fprintf(stderr, "Req %us and %u[ms], average error %.3lf\n", (unsigned int)sleep.sec(), (unsigned int) sleep.usec()/1000, avErrors[i]);
        }

    ACE::fini();
}
예제 #3
0
int KSG_Reactor_Work_Thr::do_task2(KSG_Reactor_Scheduler::SERVER_HANDLER *handle)
{
	int ret;
	ACE_Time_Value estimated = ACE_OS::gettimeofday() - handle->request_time_;
	long t = estimated.msec();
	if(t > handle->request_->default_timeout())
	{
		// 更新业务处理完成时间
		ACE_DEBUG((LM_ERROR,"对方请求已经等待超时...[%d]ms",handle->request_->default_timeout()));
		// 通知句柄以处理完成
		ret = -1;
	}
	else
	{
		ret = handle->request_->process_request(handle);
	}
	handle->mblk_->release();
	handle->mblk_ = NULL;
	if(ret == -1)
	{
		// 请求有问题,需要关闭
		ACE_DEBUG((LM_TRACE,"发送应答失败,关闭请求[%08X]",handle->handle_));
		//ACE_OS::closesocket(handle->handle_);
		//this->schd_->reactor()->remove_handler(handle->handle_,ACE_Event_Handler::ALL_EVENTS_MASK);

		this->schd_->close_error_socket(handle->handle_);
	}
	// 释放 handle
	schd_->free_handle(handle);
	
	// 更新业务处理完成时间
	return ret;
}
예제 #4
0
/*\brief Receive single datagram
  \note The function employes dgram_port and dgram_recv_timeout variables
  \retval -1 if not received,
  \retval 0  received a datagrams
*/
int run_receiver ()
{
  ACE_DEBUG
    ((LM_INFO,
      ACE_TEXT ("Receiving datagrams from port %d with timeout %d ms\n"),
      dgram_port, dgram_recv_timeout.msec ()));

  ACE_SOCK_Dgram socket;
  ACE_INET_Addr  remote ;
  static char    dgram_buffer[BUFSIZ];

  if (socket.open (ACE_INET_Addr (dgram_port)) != -1)
    if (socket.recv (dgram_buffer, sizeof (dgram_buffer),
                     remote, 0, &dgram_recv_timeout) > 0)
      {
        ACE_DEBUG ((LM_INFO, ACE_TEXT ("%C received\n"), dgram_buffer));
        return 0;
      }
    else
      {
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
                           ACE_TEXT ("Cannot receive datagrams")), -1);
      }
  else
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("%p: %d\n"),
                         ACE_TEXT ("Cannot open broadcast socket on port"), dgram_port), -1);
    }
}
예제 #5
0
 int handle_timeout (const ACE_Time_Value &tv, const void *)
 {
     ACE_DEBUG ((LM_DEBUG,
                 "Timeout! %f\n",
                 (double) (tv.msec () / 1000.)));
     return 0;
 }
예제 #6
0
int
ACE_WIN32_Proactor::handle_events (ACE_Time_Value &wait_time)
{
  // Decrement <wait_time> with the amount of time spent in the method
  ACE_Countdown_Time countdown (&wait_time);
  return this->handle_events (wait_time.msec ());
}
예제 #7
0
파일: ThreadPool.cpp 프로젝트: asdlei00/ACE
int ACE_TMAIN (int, ACE_TCHAR *[])
{
  Manager tp;
  tp.activate ();

  // Wait for a moment every time you send a message.
  ACE_Time_Value tv;
  tv.msec (100);

  ACE_Message_Block *mb = 0;
  for (int i = 0; i < 30; i++)
    {
      ACE_NEW_RETURN
        (mb, ACE_Message_Block(sizeof(int)), -1);

      ACE_OS::memcpy (mb->wr_ptr (), &i, sizeof(int));

      ACE_OS::sleep (tv);

      // Add a new work item.
      tp.putq (mb);
    }

  ACE_Thread_Manager::instance ()->wait ();
  return 0;
}
예제 #8
0
/* \brief Just runs automatic tests

Function sends a number of datagrams, spawns child thread or process and
tries to receive at least one datagram.
\retval 0 datagram was received
\retval -1 datagram was not received
*/
int run_auto_test (const ACE_TCHAR *prog_name)
{
#if defined (ACE_HAS_PROCESS_SPAWN)
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("Running auto_tests in process mode\n")));

  ACE_Process_Options opts;
  pid_t child_pid;
  opts.command_line (ACE_TEXT ("%s -p %d -t %d -a -r"),
                     prog_name, dgram_port, dgram_recv_timeout.msec ());
  if ((child_pid = ACE_Process_Manager::instance ()->spawn (opts)) == -1)
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n()")), -1);

#elif defined (ACE_HAS_THREADS)
  ACE_UNUSED_ARG (prog_name);
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("Running auto_tests in thread mode\n")));
  if (ACE_Thread_Manager::instance ()->spawn (run_thread_receiver) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("spawn_n ()")), -1);
#else
  ACE_ERROR_RETURN ((LM_ERROR,
                     ACE_TEXT ("Cannot run in auto_test mode without fork or threads.\n")),
                      -1);
#endif /* defined (ACE_HAS_PROCESS_SPAWN) */

  ACE_DEBUG ((LM_INFO,
              ACE_TEXT ("Sending datagrams on port %d in auto_test mode\n"),
              dgram_port));

  ACE_SOCK_Dgram_Bcast socket;

  if (socket.open (ACE_Addr::sap_any) != -1)
    {
      // send datagrams until child finishes
      while (1)
        {
          send_datagram (socket, dgrams_no--);
          ACE_Time_Value child_timeout (1);
#if defined (ACE_HAS_PROCESS_SPAWN)

          if (ACE_Process_Manager::instance ()->wait (child_pid,
                                                      child_timeout,
                                                      &receiver_exit_code) == child_pid)
            break;
#else /* ACE_HAS_THREADS */
          // sleep 1 second or wait for child thread
          child_timeout += ACE_OS::gettimeofday () ;
          if (ACE_Thread_Manager::instance ()->wait (&child_timeout) == 0)
            break;
#endif
        }
      socket.close ();
      ACE_DEBUG ((LM_INFO, ACE_TEXT ("Child finished with %d exit code\n"),
                  receiver_exit_code));
    }
  else
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
                       ACE_TEXT ("Cannot open broadcast socket")), -1);
  return (receiver_exit_code);
}
예제 #9
0
int
ACE_TMAIN (int, ACE_TCHAR*[])
{
  // Manage memory automagically.
  ACE_Reactor_Impl *impl = new ACE_Msg_WFMO_Reactor;
  auto_ptr<ACE_Reactor> reactor (new ACE_Reactor (impl, 1));
  ACE_Reactor::instance (reactor.get ());

  Event_Handler event_handler;
  global_event_handler = &event_handler;

  event_handler.iterations_ = 5;
  int result =
    ACE_Reactor::instance ()->register_handler (&event_handler,
                                                event_handler.handle_.handle ());
  ACE_ASSERT (result == 0);

  ACE_Time_Value timeout (1);
  result =
    ACE_Utils::truncate_cast<int> (
      ::SetTimer (0,                         // handle of window for timer messages
                  0,                             // timer identifier
                  timeout.msec (),               // time-out value
                  (TIMERPROC) &timer_callback)); // address of timer procedure

  ACE_ASSERT (result != 0);

  ACE_Reactor::run_event_loop ();

  return 0;
}
예제 #10
0
bool LeafClientHandler::joinSiblingPeer(
        int type,
        UUIDPtr& uuid,
        CellIDPtr& cellID,
        CellIDPtr& parentCellID,
        EndpointPtr& endpoint,
        SAPInfoPtr& discoverySAP,
        SAPInfoPtr& meshSAP,
        SAPInfoPtr& ftSAP
        ) {
    ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock, false);
    JoinMeshPacket *packet = 0;
    UUIDPtr runtimeUUID;
    m_mesh->getUUID(runtimeUUID);
    if (m_debugLeafClientHandler) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)LeafClientHandler:joinSiblingPeer(): PEER(%s,%s)\n"),
                runtimeUUID->toString().c_str(),
                cellID->toString().c_str()));
    }

    UUIDPtr srcCellID(new CellID(*(m_cellID.get())));
    UUIDPtr dstCellID(new CellID(*(m_cellID.get())));
    packet = new JoinMeshPacket(m_uuid,
            srcCellID,
            runtimeUUID,
            dstCellID,
            0,
            type,
            uuid,
            cellID,
            parentCellID,
            endpoint,
            discoverySAP,
            meshSAP,
            ftSAP
            );
    RequestEngine<SthenoPacket*>::RequestPtr* request = sendRequest(packet, 0);
    if (request == 0) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler:joinSiblingPeer() - Request failed\n")));
        return 0;
    }
    //ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)Before wait future\n");
    ACE_Time_Value timeout = ACE_OS::gettimeofday();
    ACE_Time_Value delta;
    delta.msec(JOIN_CELL_TIMEOUT_MS);
    timeout += delta;
    list<SthenoPacket*>* results = request->get()->waitFuture(0);
    ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T) LeafClientHandler:joinSiblingPeer() After future\n")));
    if (results != 0 && results->size() > 0) {
        JoinMeshReplyPacket* replyPacket = static_cast<JoinMeshReplyPacket*> (results->front());
        bool status = replyPacket->getJoinResult();
        ListHelper<SthenoPacket*>::deleteList(results);
        return status;
    } else {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler::joinSiblingPeer() - No response\n")));
    }

    return false;
}
예제 #11
0
void yarp::os::impl::fromDouble(ACE_Time_Value &v, double x,int unit) {
#ifdef YARP_HAS_ACE
        v.msec(static_cast<int>(x*1000/unit+0.5));
#else
        v.tv_usec = static_cast<int>(x*1000000/unit+0.5) % 1000000;
        v.tv_sec = static_cast<int>(x/unit);
#endif
}
  Miro::PanPositionIDL
  PanTiltImpl::currentPosition()
  {
    Miro::PanPositionIDL position;
    position.angle = actPosition;
    position.accuracy = Miro::deg2Rad(3.);

    if (prvPanning()) {
      position.accuracy += max( Miro::deg2Rad(7.), accuracy );

#ifdef WEGOTIT
      ACE_Time_Value delta = ACE_OS::gettimeofday() - timeLastSet;

      position.angle = lastPosition;
      position.accuracy = Miro::deg2Rad(10.);

      double blur = Miro::deg2Rad(0.04 * delta.msec());

      int t_msec = (int)fabs((nextPosition - lastPosition) * 300);

      // sind wir noch in der Bewegung?
      if (delta < ACE_Time_Value(t_msec / 1000 , (t_msec % 1000) * 1000)) {
	position.angle += (nextPosition - lastPosition) * (double)delta.msec() / (double)t_msec;
      }
      else {
	position.angle = nextPosition;
	blur *= 1 - (delta.msec() - t_msec) / 400;
      }
      position.accuracy += blur;
#endif

    }

#ifdef LETSTILTAGAIN
    if (!prvTilting())
      position.ti(!prvTilting())
      position.tiltvalue = nextPosition.tiltvalue;
    else
      position.tiltvalue = (lastPosition.panvalue <= nextPosition.panvalue)?
	lastPosition.panvalue + (now - timeLastSet).msec() * params_.tiltRadPerMSec :
	lastPosition.panvalue - (now - timeLastSet).msec() * params_.tiltRadPerMSec;
#endif

    return position;
  }
예제 #13
0
파일: test_i.cpp 프로젝트: asdlei00/ACE
void
test_i::shutdown (CORBA::Long start_time)
{
  ACE_Time_Value start (0);
  start.msec (static_cast<long> (start_time)); // HPUX seems to require this cast
  ACE_DEBUG ((LM_DEBUG, "server: Shutting down... (%dms)\n",
              (ACE_OS::gettimeofday() - start).msec ()));
  this->orb_->shutdown (0);
}
static void *
worker (void *)
{
  for (int iterations = 1;
       iterations <= n_iterations;
       iterations++)
    {
#if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM)
      ACE_Time_Value wait (0,
                           iterations * 1000 * 100);  // Wait 'iter' msec
      ACE_Time_Value tv = ACE_OS::gettimeofday () + wait;

      if (s.acquire (tv))
        ++timeouts;
      else
        {
          ACE_Time_Value diff = ACE_OS::gettimeofday ();
          diff = diff - tv;       // tv should have been reset to time acquired
          if (diff.msec () > ACE_ALLOWED_SLACK)
            {
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("Acquire fails time reset test\n")));
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("Diff btw now and returned time: %d ms\n"),
                          diff.msec ()));
              test_result = 1;
            }
          // Hold the lock for a while.
          ACE_OS::sleep (ACE_Time_Value (0,
                                         (ACE_OS::rand () % 1000) * 1000));
          s.release ();
        }
#else
      s.acquire ();
      // Hold the lock for a while.
      ACE_OS::sleep (ACE_Time_Value (0,
                                     (ACE_OS::rand () % 1000) * 1000));
      s.release ();
#endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */
      ACE_Thread::yield ();
    }

  return 0;
}
예제 #15
0
파일: Client.cpp 프로젝트: OspreyHub/ATCD
bool
Client::flood_connection (ACE_Time_Value& tv)
{
  // Block flushing currently blocks even on SYNC_DELAYED_BUFFERING
  //  so we can't use it to flood connections.

  // Set the policy value.
  // SYNC_DELAYED_BUFFERING is used to ensure that the tcp buffer gets filled before
  //  buffering starts.
  Messaging::SyncScope sync_scope = TAO::SYNC_DELAYED_BUFFERING;
  //Messaging::SyncScope sync_scope = Messaging::SYNC_NONE;
  CORBA::Any sync_scope_any;
  sync_scope_any <<= sync_scope;

  CORBA::PolicyList policy_list (1);
  policy_list.length (1);
  policy_list[0] = orb_->create_policy
    (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_scope_any);
  // Apply the policy at the object level
  CORBA::Object_var obj = test_obj_->_set_policy_overrides
    (policy_list, CORBA::SET_OVERRIDE);
  Test_var mod_test_obj = Test::_narrow (obj.in ());

  policy_list[0]->destroy ();
  policy_list.length(0);

  ACE_Auto_Array_Ptr<char> tmp (new char [2000000]);
  char* msg = tmp.get();

  ACE_OS::memset (msg,'A',1999999);
  msg[1999999] = 0;

  test_obj_->sleep (static_cast<CORBA::Long>(tv.sec())
                    , static_cast<CORBA::Long>(tv.msec()));

  /* BLOCK flush startegy always has SYNC_WITH_TRANSPORT semantics.
      Trying to flood a BLOCKed flushing connection can lead to a TIMEOUT
      exception being thrown. This will close out the connection and
      the whole flooding attempt fails. Therefore in BLOCK flushing case
      don't attempt to flood (unless BLOCK flush accepts SYNC_WITH_TRANSPORT
      semantics).
   */
  if (flush_strategy_ != BLOCKING)
    {
      mod_test_obj->dummy_one_way (msg);

      // attempt again to flood connection.
      ACE_Time_Value tv_tmp (2);
      orb_->perform_work (tv_tmp);
    }

  return true;
}
예제 #16
0
static void *
worker (void *)
{
  for (int iterations = 1;
       iterations <= n_iterations;
       iterations++)
    {
      //FUZZ: disable check_for_lack_ACE_OS
      ACE_Time_Value wait (0,
                           iterations * 1000 * 100);  // Wait 'iter' msec
      //FUZZ: enable check_for_lack_ACE_OS

      ACE_Time_Value tv = ACE_OS::gettimeofday () + wait;
      if (evt.wait (&tv) == -1)
      {
          // verify that we have ETIME
          if (ACE_OS::last_error() != ETIME)
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("%p\n"),
                          ACE_TEXT ("Worker should be ETIME but is")));
            }
          else
            ++timeouts;
          ACE_Time_Value diff = ACE_OS::gettimeofday ();
          diff = diff - tv;       // tv should have been reset to time acquired
          long diff_msec = diff.msec ();

          if (diff_msec > ACE_ALLOWED_SLACK)
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("Acquire fails time reset test\n")));
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("Diff btw now and returned time: %d ms; ")
                          ACE_TEXT ("%d allowed\n"),
                          (int)diff_msec,
                          (int)ACE_ALLOWED_SLACK));
              test_result = 1;
            }
          // Hold the lock for a while.
          ACE_OS::sleep (ACE_Time_Value (0,
                                         (ACE_OS::rand () % 1000) * 1000));
          evt.signal ();
      }

      ACE_Thread::yield ();
    }

  return 0;
}
예제 #17
0
파일: Consumer.cpp 프로젝트: CCJY/ATCD
/// @todo: rather than is_error, use pacing interval so it will be configurable
/// @todo: find some way to use batch buffering stratgy for sequence consumers.
void
TAO_Notify_Consumer::schedule_timer (bool is_error)
{
  if (this->timer_id_ != -1)
    {
      return; // We only want a single timeout scheduled.
    }
  // don't schedule timer if there's nothing that can be done
  if (this->is_suspended ())
    {
      return;
    }

  ACE_ASSERT (this->timer_.get() != 0);

  // If we're scheduling the timer due to an error then we want to
  // use the retry timeout, otherwise we'll assume that the pacing
  // interval is sufficient for now.
  ACE_Time_Value tv (DEFAULT_RETRY_TIMEOUT);

  if (! is_error)
    {
      if (this->pacing_.is_valid ())
        {
          tv = ORBSVCS_Time::to_Time_Value (this->pacing_.value ());
        }
    }

  if (DEBUG_LEVEL  > 5)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("Consumer %d: scheduling pacing/retry for %dms.\n"),
                  static_cast<int> (this->proxy ()->id ()), tv.msec ()));
    }

  this->timer_id_ =
    this->timer_->schedule_timer (this, tv, ACE_Time_Value::zero);
  if (this->timer_id_ == -1)
    {
      ORBSVCS_ERROR ((LM_ERROR,
                  ACE_TEXT ("TAO_Notify_Consumer %d::schedule_timer () ")
                  ACE_TEXT ("Error scheduling timer.\n"),
                  static_cast<int> (this->proxy ()->id ())
                  ));
    }
  if (this->is_suspended()) // double check to avoid race
  {
    this->cancel_timer();
  }
}
예제 #18
0
int run_main (int argc, ACE_TCHAR *argv[])
{
  // parse options and run in appropriate mode
  int opt             = 0;
  int auto_test_recv  = 0;
  int result          = 0;
  ACE_Get_Opt opts (argc, argv, ACE_TEXT ("p:t:n:sra"));
  while ((opt = opts ()) != -1)
    switch (opt)
      {
      case 'a':
        auto_test_recv = 1;
        break;
      case 's':
        return (run_sender());
      case 'r':
        {
          if (auto_test_recv)
            {
              ACE_START_TEST (ACE_TEXT ("SOCK_Dgram_Bcast_Test_Child"));
              result = run_receiver ();
              ACE_END_TEST;
              return result;
            }
          return (run_receiver ());
        }
      case 'n':
        dgrams_no = ACE_OS::atoi (opts.opt_arg ());
        break;
      case 't':
        dgram_recv_timeout.msec (ACE_OS::atoi (opts.opt_arg ()));
        break;
      case 'p':
        dgram_port = ACE_OS::atoi (opts.opt_arg ());
        break;
      default:
        print_usage ();
        return -1;
      }
  ACE_START_TEST (ACE_TEXT ("SOCK_Dgram_Bcast_Test"));

#ifndef ACE_LACKS_IOCTL
  result = run_auto_test (argc > 0 ? argv[0] : ACE_TEXT ("SOCK_Dgram_Bcast_Test"));
#endif

  ACE_END_TEST;
  return result;
}
예제 #19
0
// this routine makes up the brains of the agent
// it knows only the MIB II system group set of variables for a get operation
int agent_impl::get_response(Vb& vb)
{
  // these objects represent the MIB II system group per RFC 1213
   static Oid sysDescr("1.3.6.1.2.1.1.1.0"),
   sysObjectID("1.3.6.1.2.1.1.2.0"), sysUpTime("1.3.6.1.2.1.1.3.0"),
   sysContact("1.3.6.1.2.1.1.4.0"), sysName("1.3.6.1.2.1.1.5.0"),
   sysLocation("1.3.6.1.2.1.1.6.0"), sysServices("1.3.6.1.2.1.1.7.0");

  Oid oid;
  vb.get_oid(oid);
  if (oid == sysDescr) {
    OctetStr desc("ASNMP Prototype Agent 1.0");
    vb.set_value(desc);
  }
  else if (oid == sysObjectID) { // the IANA gives assigns Enterprise Numbers
    // see ftp://ftp.isi.edu/in-notes/iana/assignments/enterprise-numbers
    // for the official list of enterprise numbers. Then under this tree
    // assign a unique subtree to identify this agent
    Oid id("1.3.6.1.4.1.2533.9.1");
    vb.set_value(id);
  }
  else if (oid == sysUpTime) {
    ACE_Time_Value tv;
    agent_clock_.elapsed_time (tv);
    TimeTicks tt(tv.msec());
    vb.set_value(tt);
  }
  else if (oid == sysContact) {
    OctetStr contact("*****@*****.**");
    vb.set_value(contact);
  }
  else if (oid == sysName) {
    OctetStr fqdn("foo.org"); // extract this from the gethostbyname() TODO
    vb.set_value(fqdn);
  }
  else if (oid == sysLocation) {
    OctetStr loc("");
    vb.set_value(loc);
  }
  else if (oid == sysServices) {
    SnmpInt32 svcs(72);
    vb.set_value(svcs);
  }
  else
    return 1; // noSuchName

  return 0;
}
예제 #20
0
bool LeafClientHandler::leftSiblingPeer(UUIDPtr& uuid, CellIDPtr& cellID) {
    ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock, false);
    SthenoPacket *packet = 0;
    if (m_debugLeafClientHandler) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: LeafClientHandler:leftSiblingPeer(): PEER(%s,%s)\n"),
                uuid->toString().c_str(),
                cellID->toString().c_str()));
    }

    UUIDPtr srcCellID(new CellID(m_cellID.get()));
    UUIDPtr dstCellID(new CellID(m_cellID.get()));
    UUIDPtr runtimeUUID;
    m_mesh->getUUID(runtimeUUID);
    packet = new LeaveMeshPacket(runtimeUUID,
            srcCellID,
            m_uuid,
            dstCellID,
            0,
            uuid,
            cellID);
    RequestEngine<SthenoPacket*>::RequestPtr* request = sendRequest(packet, 0);
    delete packet;
    if (request == 0) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler:leftSiblingPeer() - Request failed\n")));
        return 0;
    }
    //ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)Before wait future\n");
    ACE_Time_Value timeout = ACE_OS::gettimeofday();
    ACE_Time_Value delta;
    delta.msec(LEAVE_CELL_TIMEOUT_MS);
    timeout += delta;
    list<SthenoPacket*>* results = request->get()->waitFuture(0);
    ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T) LeafClientHandler:leftSiblingPeer() After future\n")));
    //ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)After future\n");
    if (results != 0 && results->size() > 0) {
        LeaveMeshReplyPacket* replyPacket = static_cast<LeaveMeshReplyPacket*> (results->front());
        bool status = replyPacket->getLeaveResult();
        ListHelper<SthenoPacket*>::deleteList(results);
        return status;
    } else {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler::leftSiblingPeer() - No response\n")));
    }

    return false;
}
예제 #21
0
bool LeafClientHandler::updateInfo(InfoUpdatePtr& updateInfoPtr) {
    ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, m_lock, false);
    SthenoPacket *packet = 0;
    UUIDPtr srcCellID(new CellID(m_cellID.get()));
    UUIDPtr dstCellID(new CellID(m_cellID.get()));
    StreamSize ss;
    updateInfoPtr->serialize(ss);
    ByteOutputStream os(ss.total_length());
    updateInfoPtr->serialize(os);
    ACE_Message_Block* mb = new ACE_Message_Block(RDR::total_length(&os.start_, 0));
    RDR::consolidate(mb, &os.start_);
    UUIDPtr runtimeUUID;
    m_mesh->getUUID(runtimeUUID);
    UUIDPtr fid;
    m_mesh->getFID(fid);
    packet = new UpdateInfoPacket(runtimeUUID,
            srcCellID,
            m_uuid,
            dstCellID,
            0,
            mb);
    RequestEngine<SthenoPacket*>::RequestPtr* request = sendRequest(packet, 0);
    delete packet;
    if (request == 0) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler:updateInfo() - Request failed\n")));
        return 0;
    }
    //ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)Before wait future\n");
    ACE_Time_Value timeout = ACE_OS::gettimeofday();
    ACE_Time_Value delta;
    delta.msec(JOIN_CELL_TIMEOUT_MS);
    timeout += delta;
    list<SthenoPacket*>* results = request->get()->waitFuture(0);
    //ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)After future\n");
    if (results != 0 && results->size() > 0) {
        UpdateInfoReplyPacket* replyPacket = static_cast<UpdateInfoReplyPacket*> (results->front());
        bool status = replyPacket->getUpdateResult();
        ListHelper<SthenoPacket*>::deleteList(results);
        return status;
    } else {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: LeafClientHandler::updateInfo() - No response\n")));
    }

    return false;
}
int main(int argc, char *argv[])
{
  int rc = 1;

  // Initialize system log output.
  Miro::Log::init(argc, argv);
  // Initialize server daemon.
  Miro::Client client(argc, argv);

  try {
     // Reference to the server object
    Miro::Kicker_var kicker = client.resolveName<Miro::Kicker>("Kicker");

    std::cout << "Kicker test!" << std::endl
	      << "Kick duration in msec (0 to quit): " << std::endl;

    unsigned int duration;
    while(std::cin >> duration &&
	  duration > 0) {
      std::cout << "Kicker test!" << std::endl
		<< "Kick duration in msec (0 to quit): " << std::endl;
      
      ACE_Time_Value aT;
      aT.msec(duration);
      Miro::TimeIDL cT;
      Miro::timeA2C(aT, cT);
      MIRO_LOG_OSTR(LL_NOTICE, 
		    "Entered kick duration: " << 
		    cT.sec << "sec " << cT.usec << "usec");
      kicker->kick(cT);
      duration = 0;
    }
    rc = 0;
  }
  catch (const Miro::EOutOfBounds & e) {
    MIRO_LOG_OSTR(LL_CRITICAL, "Out of bounds exception on serve:" << std::endl << e);
  }
  catch (const Miro::EDevIO & e) {
    MIRO_LOG_OSTR(LL_CRITICAL, "Device IO exception on server:" << std::endl << e);
 }
  catch (const CORBA::Exception & e) {
    MIRO_LOG_OSTR(LL_CRITICAL, "Uncaught CORBA exception:" << std::endl << e);
  }
  return rc;
}
예제 #23
0
int LibVidCap::video_capture_callback(vidcap_src* vc_src, void* user_data, 
                                      struct vidcap_capture_info* cap_info)
{
    LibVidCap* lsn = static_cast<LibVidCap*>(user_data);

    media::VideoFormat vidfmt = lsn->GetVideoCaptureFormat();
    if(vidfmt.IsValid() && cap_info->video_data && cap_info->video_data_size)
    {
        ACE_Time_Value tm(cap_info->capture_time_sec, cap_info->capture_time_usec);
        ACE_Time_Value diff = ACE_OS::gettimeofday() - tm;
        ACE_UINT32 tm_msec = GETTIMESTAMP() - (ACE_UINT32)diff.msec();
        media::VideoFrame vid_frm(const_cast<char*>(cap_info->video_data), cap_info->video_data_size,
                                  vidfmt.width, vidfmt.height, vidfmt.fourcc, true);
        vid_frm.timestamp = tm_msec;
        lsn->DoVideoCaptureCallback(vid_frm);
    }
    return 0;
}
예제 #24
0
int KSG_Reactor_Work_Thr::do_task(KSG_Service_Handler *handle)
{
	int ret;
	ACE_Time_Value estimated = ACE_OS::gettimeofday() - handle->request_time_;
	long t = estimated.msec();
	if(t > handle->default_timeout())
	{
		// 更新业务处理完成时间
		ACE_DEBUG((LM_ERROR,"对方请求已经等待超时...[%d]ms",handle->default_timeout()));
		// 通知句柄以处理完成
		handle->process_end();
		if(!handle->closed())
			handle->handle_close();
		return -1;
	}
	ret = handle->process_request();
	// 更新业务处理完成时间
	handle->process_end();
	return ret;
}
예제 #25
0
파일: test_i.cpp 프로젝트: asdlei00/ACE
void
test_i::method (CORBA::ULong request_number,
                CORBA::Long start_time,
                const test::data &,
                CORBA::ULong work)
{
  ACE_Time_Value start (0);
  // HPUX seems to require this cast
  start.msec (static_cast<long> (start_time));
  ACE_DEBUG ((LM_DEBUG,
              "server:\t%d took\t%dms\n",
              request_number,
              (ACE_OS::gettimeofday () - start).msec ()));

  // Time required to process this request. <work> is time units in
  // milli seconds.
  ACE_Time_Value work_time (0, work * 1000);

  ACE_OS::sleep (work_time);
}
예제 #26
0
int ActuatorSvcHandler::open(void *arg) {
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T)INFO: ActuatorSvcHandler::open\n")));
    int ret = PacketChannel<SthenoStreamPacket, SthenoStreamHeader, //DiscoveryPacketFactory,
            ACE_SOCK_Stream, ACE_MT_SYNCH>::open(arg);
    if (ret == -1) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T)INFO: ActuatorSvcHandler::open failed\n")));
        return -1;
    }
    //ACE_Time_Value receiveTimeout(0, MAX_OPEN_TIMEOUT_MS * 1000);
    ACE_Time_Value receiveTimeout;
    receiveTimeout.msec(MAX_OPEN_TIMEOUT_MS);

    SthenoStreamPacket* recvPacket = 0;
    receivePacket(recvPacket, &receiveTimeout);
    if (recvPacket == 0) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: ActuatorSvcHandler::open - no init packet\n")));
        return -1;
    }
    switch (recvPacket->getPacketHeader()->getType()) {
        case InitSessionPacket::INIT_SESSION_PACKET_OP:
        {
            InitSessionPacket* initSessionPacket = static_cast<InitSessionPacket*> (recvPacket);
            m_pid = initSessionPacket->getUUID();
            ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: ActuatorSvcHandler::open - PID=%s\n"), m_pid->toString().c_str()));
            m_fid = initSessionPacket->getFID();
            ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: ActuatorSvcHandler::open - OK PID=%s\n"), m_pid->toString().c_str()));
            return 0;
        }

        default:
        {
            ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: ActuatorSvcHandler::open() - processJoinCell packet not known, calling close()\n")));
            close();
            return -1;
        }
    }
}
예제 #27
0
void Player_Qos::write_ready( size_t len)
{
	if( !start_qos_)
		return;

	//累计发送字节数
	write_bytes_ += len;

	//累计发送时间
	ACE_Time_Value now =ACE_OS::gettimeofday();
	now -= start_time_;
	use_time_ += now.msec();

	//满足统计要求
	if( write_bytes_ >= CALCUATE_BYTES_WRITE)
	{
		ACE_UINT64 tv =use_time_*1024 / write_bytes_;
		if( tv > ACE_Numeric_Limits<signed int>::max())
			qos_quality_ =ACE_Numeric_Limits<signed int>::max();
		else
			qos_quality_ =(int)tv;

		use_time_ =0;
		write_bytes_ =0;
	}
	else if( use_time_ > 10000 && write_bytes_)
	{
		//如果超过10s还没有完成1k数据的发送也要进行计算
		ACE_UINT64 tv =use_time_*1024 / write_bytes_;
		if( tv > ACE_Numeric_Limits<signed int>::max())
			qos_quality_ =ACE_Numeric_Limits<signed int>::max();
		else
			qos_quality_ =(int)tv;
	}

	start_qos_ =false;
}
예제 #28
0
pid_t
ACE_Process::wait (const ACE_Time_Value &tv,
                   ACE_exitcode *status)
{
#if defined (ACE_WIN32)
  // Don't try to get the process exit status if wait failed so we can
  // keep the original error code intact.
  switch (::WaitForSingleObject (process_info_.hProcess,
                                 tv.msec ()))
    {
    case WAIT_OBJECT_0:
        // The error status of <GetExitCodeProcess> is nonetheless not
        // tested because we don't know how to return the value.
        ::GetExitCodeProcess (process_info_.hProcess,
                              &this->exit_code_);
      if (status != 0)
        *status = this->exit_code_;
      return this->getpid ();
    case WAIT_TIMEOUT:
      errno = ETIME;
      return 0;
    default:
      ACE_OS::set_errno_to_last_error ();
      return -1;
    }
#elif defined(ACE_LACKS_UNIX_SIGNALS)
  if (tv == ACE_Time_Value::zero)
    {
      pid_t retv =
        ACE_OS::waitpid (this->child_id_,
                         &this->exit_code_,
                         WNOHANG);
      if (status != 0)
        *status = this->exit_code_;

      return retv;
    }

  if (tv == ACE_Time_Value::max_time)
# if defined (ACE_VXWORKS)
    {
      pid_t retv;
      while ((retv = this->wait (status)) == ACE_INVALID_PID && errno == EINTR);
      return retv;
    }
# else
     return this->wait (status);
# endif

  pid_t pid = 0;
  ACE_Time_Value sleeptm (1);    // 1 msec
  if (sleeptm > tv)              // if sleeptime > waittime
      sleeptm = tv;
  ACE_Time_Value tmo (tv);       // Need one we can change
  for (ACE_Countdown_Time time_left (&tmo); tmo > ACE_Time_Value::zero ; time_left.update ())
    {
      pid = ACE_OS::waitpid (this->getpid (),
                             &this->exit_code_,
                             WNOHANG);
      if (status != 0)
        *status = this->exit_code_;

      if (pid > 0 || pid == ACE_INVALID_PID)
        break;          // Got a child or an error - all done

      // pid 0, nothing is ready yet, so wait.
      // Do a (very) short sleep (only this thread sleeps).
      ACE_OS::sleep (sleeptm);
    }

  return pid;
#else /* !ACE_WIN32 && !ACE_LACKS_UNIX_SIGNALS */
  if (tv == ACE_Time_Value::zero)
    {
      pid_t retv =
        ACE_OS::waitpid (this->child_id_,
                         &this->exit_code_,
                         WNOHANG);
      if (status != 0)
        *status = this->exit_code_;

      return retv;
    }

  if (tv == ACE_Time_Value::max_time)
    return this->wait (status);

  // Need to wait but limited to specified time.
  // Force generation of SIGCHLD, even though we don't want to
  // catch it - just need it to interrupt the sleep below.
  // If this object has a reactor set, assume it was given at
  // open(), and there's already a SIGCHLD action set, so no
  // action is needed here.
  ACE_Sig_Action old_action;
  ACE_Sig_Action do_sigchld ((ACE_SignalHandler)sigchld_nop);
  do_sigchld.register_action (SIGCHLD, &old_action);

  pid_t pid;
  ACE_Time_Value tmo (tv);       // Need one we can change
  for (ACE_Countdown_Time time_left (&tmo); ; time_left.update ())
    {
      pid = ACE_OS::waitpid (this->getpid (),
                             &this->exit_code_,
                             WNOHANG);
      if (status != 0)
        *status = this->exit_code_;

      if (pid > 0 || pid == ACE_INVALID_PID)
        break;          // Got a child or an error - all done

      // pid 0, nothing is ready yet, so wait.
      // Do a sleep (only this thread sleeps) til something
      // happens. This relies on SIGCHLD interrupting the sleep.
      // If SIGCHLD isn't delivered, we'll need to do something
      // with sigaction to force it.
      if (-1 == ACE_OS::sleep (tmo) && errno == EINTR)
        continue;
      // Timed out
      pid = 0;
      break;
    }

  // Restore the previous SIGCHLD action if it was changed.
  old_action.register_action (SIGCHLD);

  return pid;
#endif /* ACE_WIN32 */
}
예제 #29
0
void EthReceiver::run()
{
//attention: don't insert too prints because this function is called every 1 millisec

    ACE_TCHAR     address[64];
    ethResources  *ethRes;
    ssize_t       recv_size;
    ACE_INET_Addr sender_addr;
    char          incoming_msg[RECV_BUFFER_SIZE];
    int flags = 0;
    static int countstat =0;
    int num_pkt;
    int myerr;




    ACE_Time_Value recvTimeOut;
    fromDouble(recvTimeOut, 0.01);
    double myTestTimeout = recvTimeOut.sec() + (double)recvTimeOut.msec()/1000.0f;


    countstat++;
    if(countstat== MAX_COUNT_STAT)
    {
        double av, std, avUsed, stdUsed;
        getEstPeriod (av, std);
        getEstUsed (avUsed, stdUsed);
        yDebug()<< "=== estPeriod: av=" <<av<<" std=" <<std;
        yDebug()<< "===UsedPeriod: av=" <<avUsed<<" std=" <<stdUsed;
        countstat = 0;
    }



#ifdef _STATS_DEBUG_FOR_CYCLE_TIME_
    for(int i=1; i<=9; i++)
    {
        stats[i].resetStat();
    }
#endif


    flags |= MSG_DONTWAIT;

    while(num_pkt<MAX_NUM_PKT)
    {

        // per ogni msg ricevuto  -1 visto come 65535!!
        recv_size = recv_socket->recv((void *) incoming_msg, RECV_BUFFER_SIZE, sender_addr, flags);
        if(recv_size < 1)
        {
            //if i'm here socket input queue is empty
            return;
        }

        ethManager->managerMutex.wait();
        // new, reverse iterator
        ethResRIt    riterator, _rBegin, _rEnd;
        _rBegin = ethResList->rbegin();
        _rEnd = ethResList->rend();
        ethManager->managerMutex.post();

        if( recv_size > 60000)
        {
            yWarning() << "Huge message received " << recv_size;
        }


#ifdef _STATS_DEBUG_FOR_CYCLE_TIME_
        int board = getBoardNum(sender_addr);
        // For statistic purpose
        stats[board].tickStart();
#endif




        //if i rec a pkt, then looking for the sender ems and parse the pkt
        sender_addr.addr_to_string(address, 64);
        riterator = _rBegin;

        while(riterator != _rEnd)
        {
            ethRes = (*riterator);
            if(ethRes->getRemoteAddress() == sender_addr)
            {
                if(recv_size > ethRes->getBufferSize())
                {
                    yError() << "EthReceiver got a message of wrong size ( received" << recv_size << " bytes while buffer is" << ethRes->getBufferSize() << " bytes long)";
                }
                else
                {
                    memcpy(ethRes->recv_msg, incoming_msg, recv_size);
                    ethRes->onMsgReception(ethRes->recv_msg, recv_size);
                }
                break;
            }
            riterator++;
        }



#ifdef _STATS_DEBUG_FOR_CYCLE_TIME_
        stats[board].tickEnd();

        //compute statistics
        if (stats[board].getIterations() == 2000)
        {
            double avEst=0;
            double stdEst=0;
            double avUsed=0;
            double stdUsed=0;
            stats[board].getEstPeriod(avEst, stdEst);
            stats[board].getEstUsed(avUsed, stdUsed);
            printf("EthReceiver Thread [%d] run %d times, est period: %.3lf, +-%.4lf[ms], est used: %.3lf, +-%.4lf[ms]\n", board, stats[board].getIterations(), avEst, stdEst, avUsed, stdUsed);
            stats[board].resetStat();
        }

        double totUsed = 0;
        if(board == 9)
        {
            for(int i=1; i<=9; i++)
            {
                totUsed += stats[i].getElapsed();
            }
            if(totUsed >= 0.95)
                printf("**EthReceiver Thread: total used time to precess 9 ropframe is %f**\n", totUsed);
        }
#endif
        num_pkt++;
    }
//    yError() << "Exiting recv thread";
    return;
}
예제 #30
0
void EthReceiver::run()
{
    yTrace();

    ACE_TCHAR     address[64];
    ethResources  *ethRes;
    ssize_t       recv_size;
    ACE_INET_Addr sender_addr;
    char          incoming_msg[RECV_BUFFER_SIZE];
    bool recError = false;
    bool allEmsInConfigstate = true; //if true means all ems are in config state


    //yDebug() << "Starting udp RECV thread with prio "<< getPriority() << "\n";
    ACE_Time_Value recvTimeOut;
    fromDouble(recvTimeOut, 0.01);

#ifdef ETHRECEIVER_STATISTICS_ON
    bool isFirst =true;
    double last_time, curr_time, diff;
    double before_rec, after_rec, diff_onRec;
    double before_mutex, after_mutex, diff_onMutex;
    int count;
    #define count_max 5000
#endif
    while(!isStopping())
    {

#ifdef ETHRECEIVER_STATISTICS_ON
        before_rec = yarp::os::Time::now();
#endif
        //get pkt from socket: blocking call with timeout
        recv_size = recv_socket->recv((void *) incoming_msg, RECV_BUFFER_SIZE, sender_addr, 0, &recvTimeOut);
#ifdef ETHRECEIVER_STATISTICS_ON
        after_rec =  yarp::os::Time::now();
        diff_onRec = after_rec - before_rec;
        stat_onRecFunc->add((diff_onRec*1000));
#endif
        if(!isRunning())
        {
            continue; //i go to recv a new pkt and wait someone to stop me
        }

#ifdef ETHRECEIVER_STATISTICS_ON
        before_mutex = yarp::os::Time::now();
#endif
        //take pointers to ems board list
         ethManager->managerMutex.wait();
         // new, reverse iterator
         ethResRIt    riterator, _rBegin, _rEnd;
         _rBegin = ethResList->rbegin();
         _rEnd = ethResList->rend();
         ethManager->managerMutex.post();


#ifdef ETHRECEIVER_STATISTICS_ON
         after_mutex = yarp::os::Time::now();
         diff_onMutex = after_mutex - before_mutex;
         stat_onMutex->add((diff_onMutex*1000));
#endif

         //i get here because of timeout ot i received a pkt;in both cases i check if all boards are alive.In the meanwhile i check if all ems are in config state.
         riterator = _rBegin;
         bool allEmsInConfigstate = true;
         double curr_time = yarp::os::Time::now();
         while(riterator != _rEnd)
         {
             ethRes = (*riterator);
             if(ethRes->isRunning())
             {
                 ethRes->checkIsAlive(curr_time);
                 allEmsInConfigstate = true;
             }
             riterator++;
         }



        if(recv_size < 1)
        {
            //print error if have not already done  and if one or more ems boards are in running state , so thy should sent pkt every 1 msec
            if((!recError) &&(!allEmsInConfigstate))
            {
                //if i'm here, i exited from recv because of timeout
                yError() << "EthReceiver: passed " <<recvTimeOut.msec() << " ms without receive a pkt!!";
                recError = true;
            }continue; //try to receive again
        }
        else
        {
            recError=false;
        }

#ifdef ETHRECEIVER_STATISTICS_ON
        if(isFirst)
        {
            last_time = yarp::os::Time::now();
            isFirst = false;
        }
        else
        {
            curr_time = yarp::os::Time::now();
            diff = curr_time - last_time;
            stat->add((diff*1000));
            if (diff> 0.006)
                yError() <<"ethReceiver pass more 6 mill without activity!!! diff= "<< diff;

            count++;
            last_time = curr_time;
        }

        if(count == count_max)
        {
            yDebug()<< "ETHRECEIVER stat: avg=" << stat->mean()<< "ms std=" << stat->deviation()<< "ms min=" << stat->getMin() << "ms max=" << stat->getMax()<< "ms  " ;
            yDebug()<< "ETHRECEIVER stat_onRecFunc: avg=" << stat_onRecFunc->mean()<< "ms std=" << stat_onRecFunc->deviation()<< "ms min=" << stat_onRecFunc->getMin() << "ms max=" << stat_onRecFunc->getMax()<< "ms  " ;
            yDebug()<< "ETHRECEIVER stat_onMutex: avg=" << stat_onMutex->mean()<< "ms std=" << stat_onMutex->deviation()<< "ms min=" << stat_onMutex->getMin() << "ms max=" << stat_onMutex->getMax()<< "ms  " ;
            count = 0;
            stat->clear();
            stat_onRecFunc->clear();
            stat_onMutex->clear();
        }
#endif





        //if i rec a pkt, then looking for the sender ems and parse the pkt
        sender_addr.addr_to_string(address, 64);
        riterator = _rBegin;

        while(riterator != _rEnd)
        {
            ethRes = (*riterator);
            if(ethRes->getRemoteAddress() == sender_addr)
            {
                if(recv_size > ethRes->getBufferSize())
                {
                    yError() << "EthReceiver got a message of wrong size ( received" << recv_size << " bytes while buffer is" << ethRes->getBufferSize() << " bytes long)";
                }
                else
                {
                    memcpy(ethRes->recv_msg, incoming_msg, recv_size);
                    ethRes->onMsgReception(ethRes->recv_msg, recv_size);
                }
                break;
            }
            riterator++;
        }

    }//while(!isStopping)

//    yError() << "Exiting recv thread";
    return;
}