Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incoming sockets must be completely emptied if the destination is disconnected. #409

Open
erlingrj opened this issue Apr 8, 2024 · 2 comments

Comments

@erlingrj
Copy link
Collaborator

erlingrj commented Apr 8, 2024

If the RTI receives TAGGED_MSG from a federate and its destination is disconnected. The RTI must read out the complete message from the socket before returning. Currently, only the first chunk is read. What happens is that the RTI will search through the remaining chunks for the beginning of a new message. It is likely that it will, at some point, find one of the magic bytes and then decode a completely rubbish signal.

I am working on a fix and will submit soon. Posting it here just-in-case.

@Jakio815
Copy link
Collaborator

Jakio815 commented Jun 19, 2024

@erlingrj Could you explain why the RTI should read out the message of a disconnected federate?
I don't see the reason why we need to read it, if it is not used. Is is for normal termination or abnormal termination?

I also find it here, in handle_federate_resign()

handle_federate_resign
  // Wait for the federate to send an EOF or a socket error to occur.
  // Discard any incoming bytes. Normally, this read should return 0 because
  // the federate is resigning and should itself invoke shutdown.
  unsigned char buffer[10];
  while (read(my_fed->socket, buffer, 10) > 0)
    ;

@edwardalee
Copy link
Contributor

The message that needs to be read out is not from a disconnected federate, but to a disconnected federate. The sender is still connected. The problem is that if the RTI does not read the entire message, then that still connected federate cannot, for example, send a message to another still connected federate. The bytes for that new message will just pile up behind the unread original message. And as @erlingrj says, the RTI will be reading the socket for further signals or messages from the federate, but will read payload information instead of real messages or signals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants