Fix a crash: unlock twice.
Fix a socket leak.