On 08/03/2014 20:50, Rémy Maucherat wrote: > 2014-03-08 21:16 GMT+01:00 Konstantin Kolinko <knst.koli...@gmail.com>: > >> My question is that these events are fired while holding a >> "synchronized (writeLock) {" lock. >> Is holding the writeLock lock is needed here. >> >> The "on write possible" event is processed by webapp's code. I think >> that in theory the web application can delegate processing to some >> other thread. That other thread will hang trying to obtain the >> writeLock to perform the actual writing. >> > I'm not convinced these write locks are needed, there should be no write > concurrency in the first place.
The explanation for why the lock is required is in the comments in the writeInternal() method. The lock is definitely required. The issue described in that comment was observed when running the Autobahn WebSocket test suite. > If the consensus is to keep the lock to try to avoid the most serious > corruption issues, then in the onWritePossible method only the call to > writeInternal would need to be locked, not the rest. It does look like the lock could be narrowed but I'm not sure it can be quite that narrow. The lock is effectively protecting buffer from concurrent access (some comments to that effect would not hurt). I'll add some more comments to that class and see what can be done to narrow that scope of the writeLock. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org