npgsql/Npgsql — pull request #143 by udoliess (2014-01-09 07:52:34+00:00)
Title: fix deadlock [#1011342]

This PR fixes a deadlock issue with SyncNotification=true, massive notifications and normal queries. See bug , there is a testing source code as well.
The main fix is to replace IsNotificationThreadRunning by ShouldNotificationThreadStop. If ShouldNotificationThreadStop returns True, iteration loop in notification thread breaks and pending query in main thread can proceed. (Before this fix the iteration loop endlessly processed received notifications and hence pending query waited endlessly for Monitor.Enter(_socket)...)
The additional lock statements are necessary, because _notificationThreadStopCount is used in different threads. See for this problematic. (I guess, there are more of these issues in the code.)

Udo