Raise an error on syscall failure in tls_retry_write_records