Added locking to critical parts of riemann plugin

Added recursive pthread mutexes to riemann plugin where global socket is
utilized. plugin_configuration is expected to be called from only one
thread by collectd. Other parts of the code are thread safe.