comments below.
Trustin Lee wrote:
private volatile Selector selector;
What do you think? From a visibility/safe publication stand point, do
you see a problem here?
Right, there's a visibility problem, but it won't hurt MINA because
Selector is called with timeout (1 second).
I see, you're right.
At worst case, wakeup will be delayed for 1 second.
true
And the callers of wakeup() calls
wakeup() mostly after some synchronized block (e.g.
IoSession.write()), so the possibility that something goes wrong is
very close to zero.
I don't understand this very well. There are 2 problematic methods:
- SocketIoProcessor.flush() is called by SocketFilterChain.doWrite() and
synchronizes around the Queue<WriteRequest>. This has nothing to do with
the selector reference I'm talking about. I don't see the relation.
- SocketIoProcessor.updateTrafficMask() is called by
SocketSessionImpl.updateTrafficMask() and I don't see any
synchronization there.
I don't know if somewhere you imply that, after one second, the
visibility problem will go away.
so the possibility that something goes wrong is very close to zero.
If I tell you the truth, I don't like this sentence for the following
reason. I read your sentence like that: as the probability of a bug is
very low, the code is good enough, let's not fix it. With concurrency
you cannot play tricks. It is not enough that that the program works in
practice most of the time. As you cannot reproduce many concurrency
bugs, the code must be right. Concurrency is hard, and a program is
either safe or not. It is either black or white, even if it is hard
sometimes to see which color it is. That said, I agree that the risk is
low...
So for the case that we're talking about, I think that we agree that
we've found a potential problem. The question is not then IF it will be
a problem in practice or not, but rather HOW do we fix it. I believe
that making the selector volatile could fix the problem. IF I am correct
it should be done, unless another way to fix the problem is proposed.
I hope I have not offended you or anyone here.
_________________________________________________________________
Find dine dokumenter lettere med MSN Toolbar med Windows-pc-søgning:
http://toolbar.msn.dk