Improve thread safety

* Use mutex locks for IO and authorization operations  inside
RDIWDeamonMaster;
* Turn the mutex lock from rd_inject_library() into a global variable;
Merge branch 'fix-thread-safety' into develop