ctx->used must be set while holding the mutex

With the current code a ctx can be used for 2 messages at the same time, resulting in a duplicate message.


Signed-off-by: Simon Derr <simon.derr@bull.net>