Merge "threadhal: handle socket disconnection gracefully" into main