Closed sashafrey closed 10 years ago
@sashafrey Could you explain, why std::string error_message is defined as static, while std::string message is not?
This is a mistake. Both variables should be defined as static to prevent their usage outside of the c_interface.cc. The following link explains the difference between "global" and "static global" variables. http://bytes.com/topic/c/answers/860211-global-variable-static-global-variable
At the moment there are several thread-safety issues in c_interface.
Current behavior of this functions is undefined if the user issues several request from concurrent threads. I suggest the following fix:
Interleaving requests are not valid, e.g. RequestXXX -> RequestYYY -> CopyRequestResult(XXX) -> CopyRequestResult(YYY) is not supported. Indeed, there is no reason for user to do this!
Again, use boost::thread_local_storage to keep the last error message.