I don't think it's something worth fixing. It works, doesn't create any problems, really. I'd rather keep it.
And it has that interesting property that plugin_lock() returns a pointer, and that pointer must be used when unlocking a plugin. This is very different from mutex locks, where you always lock and unlock the same (mutex) pointer.
as usual, feel free to comment or reopen, if you disagree
Sergei Golubchik, please review patch for this task.