Make send_raw thread-safe