When a websocket (or potentially any stateful connection) is quickly
created then destroyed, it is possible that the qualify thread will
destroy the transaction before the initialzing thread is finished
with it.
Depending on the timing, this can cause an assertion within pjsip.
To prevent this, ast_send_stateful_response will now create the group
lock and add a reference to it before creating the transaction.
While this should resolve the crash, there is still the potential that
the contact will not be cleaned up properly, see:ASTERISK~29286. As a
result, the contact has to 'time out' before it will be removed.
ASTERISK-28689
Change-Id: Id050fded2247a04d8f0fc5b8a2cf3e5482cb8cee