Hi,

In SocketServer.scala, acceptor is defined as a volatile var:
https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/network/SocketServer.scala#L54

My understanding is that @volatile is used to protect variables that
are accessed and modified by multiple threads. However, it looks like
acceptor variable is only accessed by the main KafkaServer thread.

Am I missing anything? What are we protecting the acceptor from?

The reason I'm asking is that when modifying the code for multi-port
access, I turned a single acceptor var into a ConcurrentHashMap.
However, if there are no threads accessing this variable, it probably
doesn't need to be a ConcurrentHashMap, and it probably doesn't need
to be a volatile either.

Debugging concurrency issues after the fact is tricky, so it will be
nice if someone who worked on this can comment :)

Gwen

Reply via email to