Replace T_SECOND etc. by DDS_ equivalents
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
		
							parent
							
								
									763ed67958
								
							
						
					
					
						commit
						1611adc20a
					
				
					 15 changed files with 59 additions and 65 deletions
				
			
		| 
						 | 
				
			
			@ -55,7 +55,7 @@ extern "C" {
 | 
			
		|||
                        "thread_cputime %d.%09d\n",                      \
 | 
			
		||||
                        (int)(usage.stime / DDS_NSECS_IN_SEC),           \
 | 
			
		||||
                        (int)(usage.stime % DDS_NSECS_IN_SEC));          \
 | 
			
		||||
                    (guard).v = tnowlt.v + T_SECOND;                     \
 | 
			
		||||
                    (guard).v = tnowlt.v + DDS_NSECS_IN_SEC;             \
 | 
			
		||||
                }                                                        \
 | 
			
		||||
            }                                                            \
 | 
			
		||||
        }                                                                \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,10 +20,6 @@
 | 
			
		|||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define T_MILLISECOND 1000000ll
 | 
			
		||||
#define T_SECOND (1000 * T_MILLISECOND)
 | 
			
		||||
#define T_MICROSECOND (T_MILLISECOND/1000)
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  int32_t seconds;
 | 
			
		||||
  uint32_t fraction;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2893,7 +2893,7 @@ void ddsi_xqos_init_default_writer (dds_qos_t *xqos)
 | 
			
		|||
 | 
			
		||||
  xqos->present |= QP_RELIABILITY;
 | 
			
		||||
  xqos->reliability.kind = DDS_RELIABILITY_RELIABLE;
 | 
			
		||||
  xqos->reliability.max_blocking_time = 100 * T_MILLISECOND;
 | 
			
		||||
  xqos->reliability.max_blocking_time = DDS_MSECS (100);
 | 
			
		||||
 | 
			
		||||
  xqos->present |= QP_OWNERSHIP_STRENGTH;
 | 
			
		||||
  xqos->ownership_strength.value = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -2928,7 +2928,7 @@ void ddsi_xqos_init_default_topic (dds_qos_t *xqos)
 | 
			
		|||
 | 
			
		||||
  xqos->present |= QP_RELIABILITY;
 | 
			
		||||
  xqos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT;
 | 
			
		||||
  xqos->reliability.max_blocking_time = 100 * T_MILLISECOND;
 | 
			
		||||
  xqos->reliability.max_blocking_time = DDS_MSECS (100);
 | 
			
		||||
 | 
			
		||||
  xqos->present |= QP_TRANSPORT_PRIORITY;
 | 
			
		||||
  xqos->transport_priority.value = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -860,12 +860,12 @@ static const struct cfgelem root_cfgelem = {
 | 
			
		|||
 | 
			
		||||
static const struct unit unittab_duration[] = {
 | 
			
		||||
  { "ns", 1 },
 | 
			
		||||
  { "us", 1000 },
 | 
			
		||||
  { "ms", T_MILLISECOND },
 | 
			
		||||
  { "s", T_SECOND },
 | 
			
		||||
  { "min", 60 * T_SECOND },
 | 
			
		||||
  { "hr", 3600 * T_SECOND },
 | 
			
		||||
  { "day", 24 * 3600 * T_SECOND },
 | 
			
		||||
  { "us", DDS_USECS (1) },
 | 
			
		||||
  { "ms", DDS_MSECS (1) },
 | 
			
		||||
  { "s", DDS_SECS (1) },
 | 
			
		||||
  { "min", DDS_SECS (60) },
 | 
			
		||||
  { "hr", DDS_SECS (3600) },
 | 
			
		||||
  { "day", DDS_SECS (24 * 3600) },
 | 
			
		||||
  { NULL, 0 }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1919,22 +1919,22 @@ static enum update_result uf_duration_inf (struct cfgst *cfgst, void *parent, st
 | 
			
		|||
 | 
			
		||||
static enum update_result uf_duration_ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
 | 
			
		||||
{
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, T_MILLISECOND, 0, 3600 * T_SECOND);
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (3600));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static enum update_result uf_duration_ms_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
 | 
			
		||||
{
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, T_MILLISECOND, 0, T_SECOND);
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (1));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static enum update_result uf_duration_us_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
 | 
			
		||||
{
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, 1000, 0, T_SECOND);
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_USECS (1), 0, DDS_SECS (1));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static enum update_result uf_duration_100ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
 | 
			
		||||
{
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, 0, 100 * T_MILLISECOND, 3600 * T_SECOND);
 | 
			
		||||
  return uf_duration_gen (cfgst, parent, cfgelem, value, 0, DDS_MSECS (100), DDS_SECS (3600));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void pf_duration (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources)
 | 
			
		||||
| 
						 | 
				
			
			@ -2578,7 +2578,7 @@ static int set_default_channel (struct config *cfg)
 | 
			
		|||
    c->next = NULL;
 | 
			
		||||
    c->name = ddsrt_strdup ("user");
 | 
			
		||||
    c->priority = 0;
 | 
			
		||||
    c->resolution = 1 * T_MILLISECOND;
 | 
			
		||||
    c->resolution = DDS_MSECS (1);
 | 
			
		||||
#ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING
 | 
			
		||||
    c->data_bandwidth_limit = 0;
 | 
			
		||||
    c->auxiliary_bandwidth_limit = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -628,7 +628,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_
 | 
			
		|||
  else
 | 
			
		||||
  {
 | 
			
		||||
    GVLOGDISC (" (PARTICIPANT_LEASE_DURATION defaulting to 100s)");
 | 
			
		||||
    lease_duration = 100 * T_SECOND;
 | 
			
		||||
    lease_duration = DDS_SECS (100);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (datap->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -806,7 +806,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
 | 
			
		|||
       fire before the calls return.  If the initial sample wasn't
 | 
			
		||||
       accepted, all is lost, but we continue nonetheless, even though
 | 
			
		||||
       the participant won't be able to discover or be discovered.  */
 | 
			
		||||
    pp->spdp_xevent = qxev_spdp (gv->xevents, add_duration_to_mtime (now_mt (), 100 * T_MILLISECOND), &pp->e.guid, NULL);
 | 
			
		||||
    pp->spdp_xevent = qxev_spdp (gv->xevents, add_duration_to_mtime (now_mt (), DDS_MSECS (100)), &pp->e.guid, NULL);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -1908,7 +1908,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
 | 
			
		|||
       ensure a heartbeat is scheduled soon. */
 | 
			
		||||
    if (wr->heartbeat_xevent)
 | 
			
		||||
    {
 | 
			
		||||
      const int64_t delta = 1 * T_MILLISECOND;
 | 
			
		||||
      const int64_t delta = DDS_MSECS (1);
 | 
			
		||||
      const nn_mtime_t tnext = add_duration_to_mtime (now_mt (), delta);
 | 
			
		||||
      ddsrt_mutex_lock (&wr->e.lock);
 | 
			
		||||
      /* To make sure that we keep sending heartbeats at a higher rate
 | 
			
		||||
| 
						 | 
				
			
			@ -2185,11 +2185,10 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader
 | 
			
		|||
  }
 | 
			
		||||
  m->count = init_count;
 | 
			
		||||
  /* Spec says we may send a pre-emptive AckNack (8.4.2.3.4), hence we
 | 
			
		||||
     schedule it for the configured delay * T_MILLISECOND. From then
 | 
			
		||||
     on it it'll keep sending pre-emptive ones until the proxy writer
 | 
			
		||||
     receives a heartbeat.  (We really only need a pre-emptive AckNack
 | 
			
		||||
     per proxy writer, but hopefully it won't make that much of a
 | 
			
		||||
     difference in practice.) */
 | 
			
		||||
     schedule it for the configured delay. From then on it it'll keep
 | 
			
		||||
     sending pre-emptive ones until the proxy writer receives a heartbeat.
 | 
			
		||||
     (We really only need a pre-emptive AckNack per proxy writer, but
 | 
			
		||||
     hopefully it won't make that much of a difference in practice.) */
 | 
			
		||||
  if (rd->reliable)
 | 
			
		||||
  {
 | 
			
		||||
    m->acknack_xevent = qxev_acknack (pwr->evq, add_duration_to_mtime (tnow, pwr->e.gv->config.preemptive_ack_delay), &pwr->e.guid, &rd->e.guid);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -91,8 +91,8 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
 | 
			
		|||
  struct thread_state1 * const ts1 = lookup_thread_state ();
 | 
			
		||||
  nn_mtime_t next_thread_cputime = { 0 };
 | 
			
		||||
  nn_mtime_t t_trigger_recv_threads = { 0 };
 | 
			
		||||
  int64_t shortsleep = 1 * T_MILLISECOND;
 | 
			
		||||
  int64_t delay = T_MILLISECOND; /* force evaluation after startup */
 | 
			
		||||
  int64_t shortsleep = DDS_MSECS (1);
 | 
			
		||||
  int64_t delay = DDS_MSECS (1); /* force evaluation after startup */
 | 
			
		||||
  struct gcreq *gcreq = NULL;
 | 
			
		||||
  int trace_shortsleep = 1;
 | 
			
		||||
  ddsrt_mutex_lock (&q->lock);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -130,7 +130,7 @@ static void make_builtin_endpoint_xqos (dds_qos_t *q, const dds_qos_t *template)
 | 
			
		|||
{
 | 
			
		||||
  ddsi_xqos_copy (q, template);
 | 
			
		||||
  q->reliability.kind = DDS_RELIABILITY_RELIABLE;
 | 
			
		||||
  q->reliability.max_blocking_time = 100 * T_MILLISECOND;
 | 
			
		||||
  q->reliability.max_blocking_time = DDS_MSECS (100);
 | 
			
		||||
  q->durability.kind = DDS_DURABILITY_TRANSIENT_LOCAL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -734,7 +734,7 @@ static void wait_for_receive_threads_helper (struct xevent *xev, void *varg, nn_
 | 
			
		|||
  if (arg->count++ == arg->gv->config.recv_thread_stop_maxretries)
 | 
			
		||||
    abort ();
 | 
			
		||||
  trigger_recv_threads (arg->gv);
 | 
			
		||||
  (void) resched_xevent_if_earlier (xev, add_duration_to_mtime (tnow, T_SECOND));
 | 
			
		||||
  (void) resched_xevent_if_earlier (xev, add_duration_to_mtime (tnow, DDS_SECS (1)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void wait_for_receive_threads (struct ddsi_domaingv *gv)
 | 
			
		||||
| 
						 | 
				
			
			@ -743,7 +743,7 @@ static void wait_for_receive_threads (struct ddsi_domaingv *gv)
 | 
			
		|||
  struct wait_for_receive_threads_helper_arg cbarg;
 | 
			
		||||
  cbarg.gv = gv;
 | 
			
		||||
  cbarg.count = 0;
 | 
			
		||||
  if ((trigev = qxev_callback (gv->xevents, add_duration_to_mtime (now_mt (), T_SECOND), wait_for_receive_threads_helper, &cbarg)) == NULL)
 | 
			
		||||
  if ((trigev = qxev_callback (gv->xevents, add_duration_to_mtime (now_mt (), DDS_SECS (1)), wait_for_receive_threads_helper, &cbarg)) == NULL)
 | 
			
		||||
  {
 | 
			
		||||
    /* retrying is to deal a packet geting lost because the socket buffer is full or because the
 | 
			
		||||
       macOS firewall (and perhaps others) likes to ask if the process is allowed to receive data,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -273,7 +273,7 @@ int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t
 | 
			
		|||
          entidx_lookup_proxy_participant_guid (gv->entity_index, &proxypp->privileged_pp_guid) != NULL)
 | 
			
		||||
      {
 | 
			
		||||
        GVLOGDISC ("but postponing because privileged pp "PGUIDFMT" is still live\n", PGUID (proxypp->privileged_pp_guid));
 | 
			
		||||
        l->tsched = add_duration_to_etime (tnowE, 200 * T_MILLISECOND);
 | 
			
		||||
        l->tsched = add_duration_to_etime (tnowE, DDS_MSECS (200));
 | 
			
		||||
        ddsrt_fibheap_insert (&lease_fhdef, &gv->leaseheap, l);
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -603,7 +603,7 @@ static int accept_ack_or_hb_w_timeout (nn_count_t new_count, nn_count_t *exp_cou
 | 
			
		|||
 | 
			
		||||
     This combined procedure should give the best of all worlds, and
 | 
			
		||||
     is not more expensive in the common case. */
 | 
			
		||||
  const int64_t timeout = 2 * T_SECOND;
 | 
			
		||||
  const int64_t timeout = DDS_SECS (2);
 | 
			
		||||
 | 
			
		||||
  if (new_count < *exp_count && tnow.v - t_last_accepted->v < timeout && !force_accept)
 | 
			
		||||
    return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -714,7 +714,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
 | 
			
		|||
  {
 | 
			
		||||
    nn_wctime_t tstamp_now = now ();
 | 
			
		||||
    nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - timestamp.v);
 | 
			
		||||
    if ((rst->gv->logconfig.c.mask & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + 10 * T_SECOND)
 | 
			
		||||
    if ((rst->gv->logconfig.c.mask & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + DDS_SECS (10))
 | 
			
		||||
    {
 | 
			
		||||
      nn_lat_estim_log (DDS_LC_TRACE, &rst->gv->logconfig, NULL, &rn->hb_to_ack_latency);
 | 
			
		||||
      rn->hb_to_ack_latency_tlastlog = tstamp_now;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,8 +49,8 @@ nn_etime_t now_et (void)
 | 
			
		|||
 | 
			
		||||
static void time_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, int64_t t)
 | 
			
		||||
{
 | 
			
		||||
  *sec = (int32_t) (t / T_SECOND);
 | 
			
		||||
  *usec = (int32_t) (t % T_SECOND) / 1000;
 | 
			
		||||
  *sec = (int32_t) (t / DDS_NSECS_IN_SEC);
 | 
			
		||||
  *usec = (int32_t) (t % DDS_NSECS_IN_SEC) / 1000;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_mtime_t t)
 | 
			
		||||
| 
						 | 
				
			
			@ -142,9 +142,9 @@ static ddsi_time_t nn_to_ddsi_time (int64_t t)
 | 
			
		|||
       because that would break backwards compatibility, but round-to-nearest
 | 
			
		||||
       of the inverse is correctly rounded anyway, so it shouldn't ever matter. */
 | 
			
		||||
    ddsi_time_t x;
 | 
			
		||||
    int ns = (int) (t % T_SECOND);
 | 
			
		||||
    x.seconds = (int) (t / T_SECOND);
 | 
			
		||||
    x.fraction = (unsigned) (((T_SECOND-1) + ((int64_t) ns << 32)) / T_SECOND);
 | 
			
		||||
    int ns = (int) (t % DDS_NSECS_IN_SEC);
 | 
			
		||||
    x.seconds = (int) (t / DDS_NSECS_IN_SEC);
 | 
			
		||||
    x.fraction = (unsigned) (((DDS_NSECS_IN_SEC-1) + ((int64_t) ns << 32)) / DDS_NSECS_IN_SEC);
 | 
			
		||||
    return x;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -161,8 +161,8 @@ static int64_t nn_from_ddsi_time (ddsi_time_t x)
 | 
			
		|||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Round-to-nearest conversion of DDSI time fraction to nanoseconds */
 | 
			
		||||
    int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * T_SECOND) >> 32);
 | 
			
		||||
    return x.seconds * (int64_t) T_SECOND + ns;
 | 
			
		||||
    int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * DDS_NSECS_IN_SEC) >> 32);
 | 
			
		||||
    return x.seconds * DDS_NSECS_IN_SEC + ns;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1072,7 +1072,7 @@ static int maybe_grow_whc (struct writer *wr)
 | 
			
		|||
  if (!wr->retransmitting && gv->config.whc_adaptive && wr->whc_high < gv->config.whc_highwater_mark)
 | 
			
		||||
  {
 | 
			
		||||
    nn_etime_t tnow = now_et();
 | 
			
		||||
    nn_etime_t tgrow = add_duration_to_etime (wr->t_whc_high_upd, 10 * T_MILLISECOND);
 | 
			
		||||
    nn_etime_t tgrow = add_duration_to_etime (wr->t_whc_high_upd, DDS_MSECS (10));
 | 
			
		||||
    if (tnow.v >= tgrow.v)
 | 
			
		||||
    {
 | 
			
		||||
      uint32_t m = (gv->config.whc_highwater_mark - wr->whc_high) / 32;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -913,12 +913,12 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
 | 
			
		|||
    msg = NULL;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!pwr->have_seen_heartbeat && tnow.v - rwn->tcreate.v <= 300 * T_SECOND)
 | 
			
		||||
  if (!pwr->have_seen_heartbeat && tnow.v - rwn->tcreate.v <= DDS_SECS (300))
 | 
			
		||||
  {
 | 
			
		||||
     /* Force pre-emptive AckNacks out until we receive a heartbeat,
 | 
			
		||||
        but let the frequency drop over time and stop after a couple
 | 
			
		||||
        of minutes. */
 | 
			
		||||
    int intv, age = (int) ((tnow.v - rwn->tcreate.v) / T_SECOND + 1);
 | 
			
		||||
    int intv, age = (int) ((tnow.v - rwn->tcreate.v) / DDS_NSECS_IN_SEC + 1);
 | 
			
		||||
    if (age <= 10)
 | 
			
		||||
      intv = 1;
 | 
			
		||||
    else if (age <= 60)
 | 
			
		||||
| 
						 | 
				
			
			@ -927,7 +927,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
 | 
			
		|||
      intv = 5;
 | 
			
		||||
    else
 | 
			
		||||
      intv = 10;
 | 
			
		||||
    (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, intv * T_SECOND));
 | 
			
		||||
    (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, intv * DDS_NSECS_IN_SEC));
 | 
			
		||||
  }
 | 
			
		||||
  ddsrt_mutex_unlock (&pwr->e.lock);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -940,7 +940,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
 | 
			
		|||
 outofmem:
 | 
			
		||||
  /* What to do if out of memory?  Crash or burn? */
 | 
			
		||||
  ddsrt_mutex_unlock (&pwr->e.lock);
 | 
			
		||||
  (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, 100 * T_MILLISECOND));
 | 
			
		||||
  (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, DDS_MSECS (100)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool resend_spdp_sample_by_guid_key (struct writer *wr, const ddsi_guid_t *guid, struct proxy_reader *prd)
 | 
			
		||||
| 
						 | 
				
			
			@ -1056,11 +1056,11 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
 | 
			
		|||
  {
 | 
			
		||||
    /* Directed events are used to send SPDP packets to newly
 | 
			
		||||
       discovered peers, and used just once. */
 | 
			
		||||
    if (--ev->u.spdp.directed == 0 || gv->config.spdp_interval < T_SECOND || pp->lease_duration < T_SECOND)
 | 
			
		||||
    if (--ev->u.spdp.directed == 0 || gv->config.spdp_interval < DDS_SECS (1) || pp->lease_duration < DDS_SECS (1))
 | 
			
		||||
      delete_xevent (ev);
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      nn_mtime_t tnext = add_duration_to_mtime (tnow, T_SECOND);
 | 
			
		||||
      nn_mtime_t tnext = add_duration_to_mtime (tnow, DDS_SECS (1));
 | 
			
		||||
      GVTRACE ("xmit spdp "PGUIDFMT" to %"PRIx32":%"PRIx32":%"PRIx32":%x (resched %gs)\n",
 | 
			
		||||
               PGUID (pp->e.guid),
 | 
			
		||||
               PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER,
 | 
			
		||||
| 
						 | 
				
			
			@ -1073,17 +1073,17 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
 | 
			
		|||
    /* schedule next when 80% of the interval has elapsed, or 2s
 | 
			
		||||
       before the lease ends, whichever comes first (similar to PMD),
 | 
			
		||||
       but never wait longer than spdp_interval */
 | 
			
		||||
    const dds_duration_t mindelta = 10 * T_MILLISECOND;
 | 
			
		||||
    const dds_duration_t mindelta = DDS_MSECS (10);
 | 
			
		||||
    const dds_duration_t ldur = pp->lease_duration;
 | 
			
		||||
    nn_mtime_t tnext;
 | 
			
		||||
    int64_t intv;
 | 
			
		||||
 | 
			
		||||
    if (ldur < 5 * mindelta / 4)
 | 
			
		||||
      intv = mindelta;
 | 
			
		||||
    else if (ldur < 10 * T_SECOND)
 | 
			
		||||
    else if (ldur < DDS_SECS (10))
 | 
			
		||||
      intv = 4 * ldur / 5;
 | 
			
		||||
    else
 | 
			
		||||
      intv = ldur - 2 * T_SECOND;
 | 
			
		||||
      intv = ldur - DDS_SECS (2);
 | 
			
		||||
    if (intv > gv->config.spdp_interval)
 | 
			
		||||
      intv = gv->config.spdp_interval;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1120,8 +1120,8 @@ static void handle_xevk_pmd_update (struct thread_state1 * const ts1, struct nn_
 | 
			
		|||
  {
 | 
			
		||||
    /* schedule next when 80% of the interval has elapsed, or 2s
 | 
			
		||||
       before the lease ends, whichever comes first */
 | 
			
		||||
    if (intv >= 10 * T_SECOND)
 | 
			
		||||
      tnext.v = tnow.v + intv - 2 * T_SECOND;
 | 
			
		||||
    if (intv >= DDS_SECS (10))
 | 
			
		||||
      tnext.v = tnow.v + intv - DDS_SECS (2);
 | 
			
		||||
    else
 | 
			
		||||
      tnext.v = tnow.v + 4 * intv / 5;
 | 
			
		||||
    GVTRACE ("resched pmd("PGUIDFMT"): %gs\n", PGUID (pp->e.guid), (double)(tnext.v - tnow.v) / 1e9);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -885,8 +885,8 @@ static void nn_xmsg_chain_add (struct nn_xmsg_chain *chain, struct nn_xmsg *m)
 | 
			
		|||
 * If data is send too fast, a sleep is inserted to get the used bandwidth at the configured rate.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define NN_BW_LIMIT_MAX_BUFFER (-30 * T_MILLISECOND)
 | 
			
		||||
#define NN_BW_LIMIT_MIN_SLEEP (2 * T_MILLISECOND)
 | 
			
		||||
#define NN_BW_LIMIT_MAX_BUFFER (DDS_MSECS (-30))
 | 
			
		||||
#define NN_BW_LIMIT_MIN_SLEEP (DDS_MSECS (2))
 | 
			
		||||
static void nn_bw_limit_sleep_if_needed (struct ddsi_domaingv const * const gv, struct nn_bw_limiter *this, ssize_t size)
 | 
			
		||||
{
 | 
			
		||||
  if ( this->bandwidth > 0 ) {
 | 
			
		||||
| 
						 | 
				
			
			@ -898,7 +898,7 @@ static void nn_bw_limit_sleep_if_needed (struct ddsi_domaingv const * const gv,
 | 
			
		|||
    actual_interval = tnow.v - this->last_update.v;
 | 
			
		||||
    this->last_update = tnow;
 | 
			
		||||
 | 
			
		||||
    target_interval = T_SECOND*size/this->bandwidth;
 | 
			
		||||
    target_interval = DDS_NSECS_IN_SEC*size/this->bandwidth;
 | 
			
		||||
 | 
			
		||||
    this->balance += (target_interval - actual_interval);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue