Add semaphore so the Agent waits for the registration to end

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