Metaswitch/sprout — pull request #632 by plfrancis (2014-06-30 14:55:14+00:00)
Title: Fix grp_lock crash due to error path clean-up.

During load testing, the call to ```pjsip_tsx_create_uas2()``` from ```create_pjsip_transaction()``` will sometimes fail. This results in the ```_lock``` cleanup code following the call to be executed. This code invokes ```pj_grp_lock_dec_ref()``` which at this point will take the reference count to 0. ```grp_lock_dec_ref()``` will call ```grp_lock_destroy()``` in this case which will clean-up the lock and release its' resources. At some later point when the UASTsx destructor runs it will invoke ```pj_grp_lock_release()``` on ```_lock``` since it is not NULL. This causes a crash since the resources have already been released due to the previous 0 reference count clean-up. Since there are a number of safety checks for ```(_lock != NULL)``` already, it seems like this should be a reasonable fix for the error path.