xoft, do you think if all plugins would share the same critical section a deadlock can still happen when one plugin calls a function on another plugin?
Take these two plugins
PluginChat: Hooks into the player chat
PluginPermissions: Can be used to check player permissions and does weird stuff
Handle packet thread
1. OnChat -- Lock plugin criticalsection
2. PluginChat:OnChat
3. Call PluginPermissions:CanChat()
4. PluginPermissions:CanChat() decides to loop over all entities/players to find out whether the player is allowed to chat ( ??? )
5. Waiting for Entity list lock (Tick thread owns this lock)
Tick thread
1. cPlayer:Tick() (player takes damage from hunger) -- Entity list/critical section is locked
2. OnTakeDamage
3. Waiting for critical section on plugins (Handle packet thread owns this)
And voila, deadlock.
EDIT: Man, this could even happen if it was a single plugin... which means this deadlock is in MCServer RIGHT NOW
Take these two plugins
PluginChat: Hooks into the player chat
PluginPermissions: Can be used to check player permissions and does weird stuff
Handle packet thread
1. OnChat -- Lock plugin criticalsection
2. PluginChat:OnChat
3. Call PluginPermissions:CanChat()
4. PluginPermissions:CanChat() decides to loop over all entities/players to find out whether the player is allowed to chat ( ??? )
5. Waiting for Entity list lock (Tick thread owns this lock)
Tick thread
1. cPlayer:Tick() (player takes damage from hunger) -- Entity list/critical section is locked
2. OnTakeDamage
3. Waiting for critical section on plugins (Handle packet thread owns this)
And voila, deadlock.
EDIT: Man, this could even happen if it was a single plugin... which means this deadlock is in MCServer RIGHT NOW