mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
CAS expected should not be _Atomic type, #1317
This commit is contained in:
@@ -31,8 +31,7 @@ rwlock_rlock(struct rwlock *lock) {
|
||||
|
||||
static inline void
|
||||
rwlock_wlock(struct rwlock *lock) {
|
||||
ATOM_INT clear;
|
||||
ATOM_INIT(&clear, 0);
|
||||
int clear = 0;
|
||||
while (!ATOM_CAS(&lock->write,clear,1)) {}
|
||||
while(ATOM_LOAD(&lock->read)) {}
|
||||
}
|
||||
|
||||
@@ -595,8 +595,7 @@ cmd_logon(struct skynet_context * context, const char * param) {
|
||||
if (lastf == NULL) {
|
||||
f = skynet_log_open(context, handle);
|
||||
if (f) {
|
||||
ATOM_POINTER exp;
|
||||
ATOM_INIT(&exp, 0);
|
||||
uintptr_t exp = 0;
|
||||
if (!ATOM_CAS_POINTER(&ctx->logfile, exp, f)) {
|
||||
// logfile opens in other thread, close this one.
|
||||
fclose(f);
|
||||
@@ -618,7 +617,8 @@ cmd_logoff(struct skynet_context * context, const char * param) {
|
||||
FILE * f = ATOM_LOAD(&ctx->logfile);
|
||||
if (f) {
|
||||
// logfile may close in other thread
|
||||
if (ATOM_CAS_POINTER(&ctx->logfile, f, NULL)) {
|
||||
uintptr_t fptr = (uintptr_t)f;
|
||||
if (ATOM_CAS_POINTER(&ctx->logfile, fptr, NULL)) {
|
||||
skynet_log_close(context, f, handle);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user