eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
799 stars 349 forks source link

Why does the GC thread need to keep activating the RECV thread in the deaf scene #1961

Closed caojiebao closed 3 months ago

caojiebao commented 3 months ago

In the deaf scene, the recv thread kept receiving the message, but did not process the message, and did not need gc to trigger.

IN do_packet function

  {
    /* Get next packet */
    sz = ddsi_conn_read (conn, buff, buff_len, true, &srcloc);
  }

  if (sz > 0 && !gv->deaf)
  {
    nn_rmsg_setsize (rmsg, (uint32_t) sz);
    handle_rtps_message(ts1, gv, conn, guidprefix, rbpool, rmsg, (size_t) sz, buff, &srcloc);
  }
  else if (gv->deaf) {
    DDS_CLOG (DDS_LC_CA_ERROR, &gv->logconfig, "configure with deaf\n");
  }
  nn_rmsg_commit (rmsg);
  return (sz > 0);
}
caojiebao commented 3 months ago

In gcreq_queue_thread function

    if (q->gv->deaf)
    {
      ddsrt_mtime_t tnow_mt = ddsrt_time_monotonic ();
      if (tnow_mt.v > t_trigger_recv_threads.v)
      {
        trigger_recv_threads (q->gv);
        t_trigger_recv_threads.v = tnow_mt.v + DDS_MSECS (100);
      }
    }
eboasson commented 3 months ago

It is there because of:

>     /* While deaf, we need to make sure the receive thread wakes up
>       every now and then to try recreating sockets & rejoining multicast
>       groups.  Do rate-limit it a bit. */

But ... that relates to what was removed in 0845337f4749a0c1390b71ebf368718bffa56f4a (PR #420 )

At some point I thought it might be useful to implement deafness by deleting the sockets and recreating them, but that really adds a lot of complication for a rarely used testing hack. The complications were deleted, but I forgot to remove the now-useless triggering of the receive thread.