<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<div style="">
<p dir="auto">As you already said, on all supported platform the read and write to/from int already is atomic. Making the variable atomic just helps unsupported platforms (e.g. 16 bit data bus).</p>
<p dir="auto">What I think of is code like</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">if (session->internals.recv_state != RECV_STATE_FALSE_START &&</span>
<span id="LC2" class="line" lang="plaintext">    session->internals.recv_state != RECV_STATE_FALSE_START_HANDLING &&</span>
<span id="LC3" class="line" lang="plaintext">    session->internals.recv_state != RECV_STATE_EARLY_START &&</span>
<span id="LC4" class="line" lang="plaintext">    session->internals.recv_state != RECV_STATE_EARLY_START_HANDLING &&</span>
<span id="LC5" class="line" lang="plaintext">    !(session->internals.hsk_flags & HSK_EARLY_DATA_IN_FLIGHT))</span>
<span id="LC6" class="line" lang="plaintext">...</span></code></pre>
<p dir="auto">If a non-optimizing compiler reads the variable 4x, this allows a second thread to change the value between two comparisons. It might be unlikely, but to be sure you would save <code>session->internals.recv_state</code> into a temp variable and use that for comparison.</p>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777777;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/merge_requests/935#note_144663146">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/sent_notifications/9acfb2c6aa8c3004627cdf10dd56ac6a/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.com/gnutls/gnutls/merge_requests/935#note_144663146"}}</script>
</p>
</div>
</body>
</html>