[nanomsg] Re: Lock in nn_sock_send

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 16 Sep 2013 16:32:15 +0200

Hi Steven,

Oh,  so my understanding is that the nn sockets at a send function have
two stages happened which are connections selection by the load balancer
or fair-queuer, and the data sending or queued on the selected connections.
I think it may be a good idea but of cause it will require more work if
we can separate the single shared lock to be a shared lock for the
connection selection and locks of connection-wise for the data
sending/queued, which can reduce the blocking by overlapping lock on the
shared lock when the socket is used by multiple threads.

How would you avoid deadlocks between the two critical sections?

Thread A: User calls API, big lock, small lock, hang
Thread B: Network event happens, small lock, big lock, hang

Martin


Other related posts: