compare_exchange in connSocketRead, explicitly enforce memory order (even if redundant)
Former-commit-id: 3c4cadc020c5aa9c39a066679255b8d2520c8e22
This commit is contained in:
parent
9d62e397bd
commit
3d2a59d7ae
@ -173,7 +173,7 @@ static int connSocketWrite(connection *conn, const void *data, size_t data_len)
|
|||||||
* connected, not to mess with handler callbacks.
|
* connected, not to mess with handler callbacks.
|
||||||
*/
|
*/
|
||||||
ConnectionState expected = CONN_STATE_CONNECTED;
|
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;
|
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
|
/* Don't overwrite the state of a connection that is not already
|
||||||
* connected, not to mess with handler callbacks.
|
* connected, not to mess with handler callbacks.
|
||||||
*/
|
*/
|
||||||
if (conn->state == CONN_STATE_CONNECTED)
|
ConnectionState expected = CONN_STATE_CONNECTED;
|
||||||
conn->state.store(CONN_STATE_ERROR, std::memory_order_release);
|
conn->state.compare_exchange_strong(expected, CONN_STATE_ERROR, std::memory_order_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user