sock: Fix a deadlock because i did not release the lock in a specific context.
+ minor code formating changes.