Skip to content
This repository has been archived by the owner on Jan 9, 2018. It is now read-only.

DefaultRPCSender - Possible race condition between sending and registering the listener #41

Open
chuckmarcotte opened this issue Aug 4, 2014 · 6 comments

Comments

@chuckmarcotte
Copy link

In the class DefaultRPCSender, in method call():

public String call(String procId, ResultListener listener, long timeout, Object... args)

the line for:

    conn.sendMessage(msg);

Is invoked before the listener is registered

    if(listener != null)
        if(timeout >= 0)
            resultListeners.put(callId, listener, timeout);
        else//weird listener will never be called
            if(log.isWarnEnabled())
                log.warn("ResultListener not null but timeout < 0. ResultListener will never be called.");
@trumpetinc
Copy link
Collaborator

Can you do me a favor and take a look at the code in the messageoverhaul branch? I've got a complete rework of jWAMP underway that resolves a lot of these sorts of issues.

Thanks,

  • K

@chuckmarcotte
Copy link
Author

Will do.  Must be a drop down for branch selection here somewhere ....   :-)

Chuck Marcotte

On Monday, August 4, 2014 12:59 PM, trumpetinc notifications@github.com wrote:

Can you do me a favor and take a look at the code in the messageoverhaul branch? I've got a complete rework of jWAMP underway that resolves a lot of these sorts of issues.
Thanks,

  • K

    Reply to this email directly or view it on GitHub.

@ghetolay
Copy link
Owner

ghetolay commented Aug 4, 2014

On the home page, just above the last commit label on the left, there is a green button next to it.

Thks for your interest in JWamp.

@chuckmarcotte
Copy link
Author

FYI.  The Call ERROR json parser does not match the spec and a parsing error is occurring.
My server is based on the Version 1 WAMP Authbahn release code for Python.

Note, the spec says that the 4th argument is a dictionary, but the examples show a list of strings.
Changing the "WampCallErrorMessage.errorDetails" will have some cascading code changes.

Call ERROR
The Dealer will then send a ERROR message to the original Caller:
[ERROR, CALL, CALL.Request|id, Details|dict, Error|uri]
or
[ERROR, CALL, CALL.Request|id, Details|dict, Error|uri, Arguments|list]
or
[ERROR, CALL, CALL.Request|id, Details|dict, Error|uri, Arguments|list, ArgumentsKw|dict]
where
* CALL.Request is the ID from the original call request.
* Details is a dictionary with additional error details.
* Error is an URI identifying the type of error as returned by the Callee to the Dealer.
* Arguments is a list containing the original error payload list as returned by the Callee to the Dealer.
* ArgumentsKw is a dictionary containing the original error payload dictionary as returned by the Callee to the Dealer
Example
[8, 48, 7814135, {}, "com.myapp.error.object_write_protected", ["Sorry, but the object is write protected."]]
If the original call already failed at the Dealer before the call would have been forwarded to any Callee, the Dealer also (and immediately) sends a ERROR message to the Caller:
[ERROR, CALL, CALL.Request|id, Details|dict, Error|uri]
Example
[8, 48, 7814135, {}, "wamp.error.no_such_procedure"]

On , Charles Marcotte chuckmarcotte@yahoo.com wrote:

Will do.  Must be a drop down for branch selection here somewhere ....   :-)

Chuck Marcotte

On Monday, August 4, 2014 12:59 PM, trumpetinc notifications@github.com wrote:

Can you do me a favor and take a look at the code in the messageoverhaul branch? I've got a complete rework of jWAMP underway that resolves a lot of these sorts of issues.
Thanks,

  • K

    Reply to this email directly or view it on GitHub.

@chuckmarcotte
Copy link
Author

Hmm...

The Promise class needs the get() method to check to see if the value has already been set BEFORE calling wait().
If no thread is waiting when the other thread calls calls notifyAll(), then it's a NOP and the wait()ing thread will wait forever.
Classic race condition.

I sometimes see an RPC call that waits forever because the response comes back faster than the client thread can call enter get() and call wait().

ghetolay/jwamp

 
           
ghetolay/jwamp
jwamp - Java client and server implementation of WebSocket subprotocol WAMP
View on github.com Preview by Yahoo
 
 

Chuck Marcotte

On Monday, August 4, 2014 2:38 PM, ghetolay notifications@github.com wrote:

On the home page, just above the last commit label on the left, there is a green button next to it.
Thks for your interest in JWamp.

Reply to this email directly or view it on GitHub.

@trumpetinc
Copy link
Collaborator

Chuck - I have created a separate Issue for the Promise race condition you identified ( #42 ). I have it fixed and will push that in a second. Can you please do me a favor and open a new Issue for the ERROR call parameters?

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

No branches or pull requests

3 participants