| 2144 | } |
| 2145 | |
| 2146 | void Socket::SetAuthentication(int error_code) { |
| 2147 | uint64_t expected = 0; |
| 2148 | // `bthread_id_destroy' has release fence to prevent this CAS being |
| 2149 | // reordered after it. |
| 2150 | if (_auth_flag_error.compare_exchange_strong( |
| 2151 | expected, (AUTH_FLAG | error_code), |
| 2152 | butil::memory_order_relaxed)) { |
| 2153 | // As expected |
| 2154 | if (error_code != 0) { |
| 2155 | SetFailed(error_code, "Fail to authenticate %s", description().c_str()); |
| 2156 | } |
| 2157 | CHECK_EQ(0, bthread_id_unlock_and_destroy(_auth_id)); |
| 2158 | } |
| 2159 | } |
| 2160 | |
| 2161 | AuthContext* Socket::mutable_auth_context() { |
| 2162 | if (_auth_context != NULL) { |