Use proper locking function (via the generic locking API)
Reported by Max E. Reyes Vera Juarez.
Fixed restoring SOCKET info from AVP during failover
(cherry picked from commit cc657ffc81e13e66dfba9ffba3e5e9f380e22c1d)