osrf / robocup3ds

Gazebo support for the RoboCup 3D simulation league.
11 stars 2 forks source link

UpdatePerceptor() sends message after client is disconnected in RCPServer #15

Open osrf-migration opened 8 years ago

osrf-migration commented 8 years ago

Original report (archived issue) by jasonzliang NA (Bitbucket: jasonzliang).


Connecting an agent during for example PlayOn outputs something like this:

[Msg] GameState::AddAgent() error: Invalid playmode, PlayOn
[Msg] (34.422) failed to add agent to game state: 2_magmaOffenburg

If the agent is then stopped, the terminal is spammed with the following message, seemingly each frame:

RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
RCPServer::Send() Socket not found.
[...]

This is annoying because it makes it difficult to notice any other output until gazebo-robocup3ds is restarted.

The suspected cause: Agents are removed from gamestate in one thread while cleaning up the sockets corresponding to that agent is done in a separate thread. Since both threads are running in parallel, it is possible for the following order of events to occur:

  1. RCPServer calls OnDisconnection() (thread 1)
  2. RCPServer cleans up socket (thread 1)
  3. UpdatePerceptor is called (calls RCPServer::Send()) (thread 2)
  4. UpdateEffector is called (deletes agent from gamestate) (thread 2)

When this happens, we will receive a warning mesage in the console: "RCPServer::Send() Socket not found". This is due to the fact that for a short period of time, the socket is cleaned up, but the corresponding agent object (with socket id) still exists. This issue does not seem to affect functionality of the server.

A simple solution would be to add a time delay of 0.1 seconds between calling OnDisconnection() in RCPServer and closing the socket, which gives UpdateEffector() (in main thread) enough time to remove the Agent from gamestate.

It seems that unlike SimSpark, the plugin only allows agents to connect while the game is not running.

osrf-migration commented 8 years ago

Original comment by jasonzliang NA (Bitbucket: jasonzliang).


osrf-migration commented 8 years ago

Original comment by jasonzliang NA (Bitbucket: jasonzliang).


osrf-migration commented 8 years ago

Original comment by jasonzliang NA (Bitbucket: jasonzliang).


osrf-migration commented 8 years ago

Original comment by jasonzliang NA (Bitbucket: jasonzliang).


osrf-migration commented 8 years ago

Original comment by jasonzliang NA (Bitbucket: jasonzliang).


Issue #20 was marked as a duplicate of this issue.