Take a lock before using zhandle_t

Signed-off-by: Raul Gutierrez S <rgs@itevenworks.net>