Fix multithreading issues.

Added mutexes where necessary to prevent races between
sessions and the acceptor. Don't defer upper_send handler
via a strand as the buffer pointer will become invalid
and we would otherwise need to make a copy.