compare_exchange in connSocketRead, explicitly enforce memory order (even if redundant)

Former-commit-id: 3c4cadc020c5aa9c39a066679255b8d2520c8e22
This commit is contained in:
christianEQ 2021-01-28 23:17:48 +00:00
parent 9d62e397bd
commit 3d2a59d7ae

View File

@ -173,7 +173,7 @@ static int connSocketWrite(connection *conn, const void *data, size_t data_len)
* connected, not to mess with handler callbacks.
*/
ConnectionState expected = CONN_STATE_CONNECTED;
conn->state.compare_exchange_strong(expected, CONN_STATE_ERROR);
conn->state.compare_exchange_strong(expected, CONN_STATE_ERROR, std::memory_order_relaxed);
}
return ret;
@ -189,8 +189,8 @@ static int connSocketRead(connection *conn, void *buf, size_t buf_len) {
/* Don't overwrite the state of a connection that is not already
* connected, not to mess with handler callbacks.
*/
if (conn->state == CONN_STATE_CONNECTED)
conn->state.store(CONN_STATE_ERROR, std::memory_order_release);
ConnectionState expected = CONN_STATE_CONNECTED;
conn->state.compare_exchange_strong(expected, CONN_STATE_ERROR, std::memory_order_release);
}
return ret;