Add registry lock API and connection's refcount

Signed-off-by: David Goulet <dgoulet@ev0ke.net>