Skip to content

Use __atomic_store_n() instead of __sync_test_and_set() for lsapi #9976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions sapi/litespeed/lsapilib.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ static void lsapi_close_connection(LSAPI_Request *pReq)
if (s_busy_workers)
__sync_fetch_and_sub(s_busy_workers, 1);
if (s_worker_status)
__sync_lock_test_and_set(&s_worker_status->m_state, LSAPI_STATE_IDLE);
__atomic_store_n(&s_worker_status->m_state, LSAPI_STATE_IDLE, __ATOMIC_SEQ_CST);
}


Expand Down Expand Up @@ -1587,8 +1587,8 @@ int LSAPI_Accept_r( LSAPI_Request * pReq )
else
{
if (s_worker_status)
__sync_lock_test_and_set(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED);
__atomic_store_n(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED, __ATOMIC_SEQ_CST);
if (s_busy_workers)
__sync_fetch_and_add(s_busy_workers, 1);
lsapi_set_nblock( pReq->m_fd , 0 );
Expand Down Expand Up @@ -3315,8 +3315,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
if (pthread_atfork_func)
(*pthread_atfork_func)(NULL, NULL, set_skip_write);

__sync_lock_test_and_set(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED);
__atomic_store_n(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED, __ATOMIC_SEQ_CST);
if (s_busy_workers)
__sync_add_and_fetch(s_busy_workers, 1);
lsapi_set_nblock( pReq->m_fd, 0 );
Expand Down Expand Up @@ -3390,7 +3390,7 @@ int LSAPI_Postfork_Child(LSAPI_Request * pReq)
{
int max_children = g_prefork_server->m_iMaxChildren;
s_pid = getpid();
__sync_lock_test_and_set(&pReq->child_status->m_pid, s_pid);
__atomic_store_n(&pReq->child_status->m_pid, s_pid, __ATOMIC_SEQ_CST);
s_worker_status = pReq->child_status;

setsid();
Expand All @@ -3402,8 +3402,8 @@ int LSAPI_Postfork_Child(LSAPI_Request * pReq)
if (pthread_atfork_func)
(*pthread_atfork_func)(NULL, NULL, set_skip_write);

__sync_lock_test_and_set(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED);
__atomic_store_n(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED, __ATOMIC_SEQ_CST);
if (s_busy_workers)
__sync_add_and_fetch(s_busy_workers, 1);
lsapi_set_nblock( pReq->m_fd, 0 );
Expand Down Expand Up @@ -3651,8 +3651,8 @@ int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
if (fd == pReq->m_fdListen)
{
if (s_worker_status)
__sync_lock_test_and_set(&s_worker_status->m_state,
LSAPI_STATE_ACCEPTING);
__atomic_store_n(&s_worker_status->m_state,
LSAPI_STATE_ACCEPTING, __ATOMIC_SEQ_CST);
if (s_accepting_workers)
__sync_fetch_and_add(s_accepting_workers, 1);
}
Expand All @@ -3662,8 +3662,8 @@ int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
if (s_accepting_workers)
__sync_fetch_and_sub(s_accepting_workers, 1);
if (s_worker_status)
__sync_lock_test_and_set(&s_worker_status->m_state,
LSAPI_STATE_IDLE);
__atomic_store_n(&s_worker_status->m_state,
LSAPI_STATE_IDLE, __ATOMIC_SEQ_CST);
}

if ( ret == 0 )
Expand Down Expand Up @@ -3711,8 +3711,8 @@ int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
if ( pReq->m_fd != -1 )
{
if (s_worker_status)
__sync_lock_test_and_set(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED);
__atomic_store_n(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED, __ATOMIC_SEQ_CST);
if (s_busy_workers)
__sync_fetch_and_add(s_busy_workers, 1);

Expand Down