net: make Socket destroy() re-entrance safe

So that we are free to call socket.destroy() in error event handler.

fix #6769
Merge remote-tracking branch 'upstream/v0.10' into v0.10