Reputation: 265
I am writing a client-server application using Java-RMI. Some server-side ressources have to be accessed in mutual exclusion (I am using locks for that purpose).
Now I was wondering what happens when:
Will any locks acquired by the remote method call associated to that client be released? Or will it just be impossible for other clients to acquire the lock afterwards?
Thanks for your answers
Upvotes: 2
Views: 230
Reputation: 719259
What happens is that the remote method keeps executing until it is done, and releases the locks when it exits the critical section. Then it attempts to return the results (if any) to the client, and fails because the connection has been broken.
There is no particular hazard here ...
Of course, if the server is using Lock
objects rather than primitive locks / mutexes, then it needs to do the lock releases in a finally block to deal with the case where it fails due to some unexpected exception. But this is a different issue. The client crashing won't trigger that scenario.
Upvotes: 4