You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ServiceResponseHandler uses a queue to handler ros service requests between nodes. Since the response to a service call is simply a poll from the queue, service responses can become mismatched if a node contains multi-threaded components making the same service call. If the first request does not complete before the second request, the responses will be flipped. A mapping is needed to ensure only the correct responses are returned.
Relevant variable: Line 41 private final Queue<ServiceResponseListener<ResponseType>> responseListeners;
Relevant method: Line 52
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
final ServiceResponseListener<ResponseType> listener = responseListeners.poll();
Preconditions.checkNotNull(listener, "No listener for incoming service response.");
final ServiceServerResponse response = (ServiceServerResponse) e.getMessage();
final ChannelBuffer buffer = response.getMessage();
executorService.execute(new Runnable() {
@Override
public void run() {
if (response.getErrorCode() == 1) {
listener.onSuccess(deserializer.deserialize(buffer));
} else {
String message = Charset.forName("US-ASCII").decode(buffer.toByteBuffer()).toString();
listener.onFailure(new RemoteException(StatusCode.ERROR, message));
}
}
});
}
The ServiceResponseHandler uses a queue to handler ros service requests between nodes. Since the response to a service call is simply a poll from the queue, service responses can become mismatched if a node contains multi-threaded components making the same service call. If the first request does not complete before the second request, the responses will be flipped. A mapping is needed to ensure only the correct responses are returned.
Relevant variable: Line 41
private final Queue<ServiceResponseListener<ResponseType>> responseListeners;Relevant method: Line 52