Add message processor hooks.

The dump urls is now done as a message processor hook, running in a
separate thread. Since, we have functions doing stuff to files on
threads, we also need a lock, now!