RTS API Documentation  1.10.11
Functions
switch_core_rwlock.c File Reference
#include <switch.h>
#include "private/switch_core_pvt.h"
+ Include dependency graph for switch_core_rwlock.c:

Go to the source code of this file.

Functions

switch_status_t switch_core_session_io_read_lock (switch_core_session_t *session)
 
switch_status_t switch_core_session_io_write_lock (switch_core_session_t *session)
 
switch_status_t switch_core_session_io_rwunlock (switch_core_session_t *session)
 
switch_status_t switch_core_session_read_lock (switch_core_session_t *session)
 
switch_status_t switch_core_session_read_lock_hangup (switch_core_session_t *session)
 
void switch_core_session_write_lock (switch_core_session_t *session)
 
void switch_core_session_rwunlock (switch_core_session_t *session)
 

Function Documentation

◆ switch_core_session_read_lock()

switch_status_t switch_core_session_read_lock ( switch_core_session_t session)

Definition at line 82 of file switch_core_rwlock.c.

References CF_THREAD_SLEEPING, switch_core_session::channel, switch_core_session::rwlock, SSF_DESTROYED, switch_channel_down_nosig, switch_channel_get_name(), SWITCH_CHANNEL_ID_LOG, switch_channel_test_flag(), switch_core_session_get_uuid(), switch_core_session_wake_session_thread(), SWITCH_DECLARE, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_test_flag, switch_thread_rwlock_tryrdlock(), and switch_thread_rwlock_unlock().

84 {
86 
87  if (session->rwlock) {
88  if ((status = switch_thread_rwlock_tryrdlock(session->rwlock)) == SWITCH_STATUS_SUCCESS) {
90  status = SWITCH_STATUS_FALSE;
92 #ifdef SWITCH_DEBUG_RWLOCKS
93  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_ERROR, "%s %s Ping thread\n",
95 #endif
97  }
98 
99 #ifdef SWITCH_DEBUG_RWLOCKS
100  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_ERROR, "%s %s Read lock FAIL\n",
102 #endif
104  } else {
105 #ifdef SWITCH_DEBUG_RWLOCKS
106  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_ERROR, "%s %s Read lock ACQUIRED\n",
108 #endif
109  }
110  }
111  }
112 
113  return status;
114 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_channel_t * channel
switch_status_t switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:255
#define switch_channel_down_nosig(_channel)
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_status_t
Common return values.
switch_status_t switch_core_session_wake_session_thread(_In_ switch_core_session_t *session)
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_thread_rwlock_t * rwlock

◆ switch_core_session_read_lock_hangup()

switch_status_t switch_core_session_read_lock_hangup ( switch_core_session_t session)

Definition at line 120 of file switch_core_rwlock.c.

References switch_core_session::channel, CS_DESTROY, switch_core_session::rwlock, SSF_DESTROYED, switch_channel_get_name(), switch_channel_get_state(), SWITCH_CHANNEL_ID_LOG, switch_core_session_get_uuid(), SWITCH_DECLARE, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_test_flag, switch_thread_rwlock_tryrdlock(), and switch_thread_rwlock_unlock().

122 {
124 
125  if (session->rwlock) {
126  if ((status = switch_thread_rwlock_tryrdlock(session->rwlock)) == SWITCH_STATUS_SUCCESS) {
128  status = SWITCH_STATUS_FALSE;
129 #ifdef SWITCH_DEBUG_RWLOCKS
130  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_ERROR, "%s %s Read lock FAIL\n",
132 #endif
134  } else {
135 #ifdef SWITCH_DEBUG_RWLOCKS
136  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_ERROR, "%s %s Read lock ACQUIRED\n",
138 #endif
139  }
140  }
141  }
142 
143  return status;
144 }
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_channel_t * channel
switch_status_t switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:255
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_status_t
Common return values.
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_thread_rwlock_t * rwlock

◆ switch_core_session_rwunlock()

void switch_core_session_rwunlock ( switch_core_session_t session)

Definition at line 165 of file switch_core_rwlock.c.

References switch_core_session::rwlock, and switch_thread_rwlock_unlock().

166 {
167 #endif
169 
170 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * rwlock

◆ switch_core_session_write_lock()

void switch_core_session_write_lock ( switch_core_session_t session)

Definition at line 153 of file switch_core_rwlock.c.

References switch_core_session::channel, switch_core_session::rwlock, switch_channel_get_name(), SWITCH_CHANNEL_ID_LOG, switch_core_session_get_uuid(), SWITCH_DECLARE, SWITCH_LOG_ERROR, switch_log_printf(), and switch_thread_rwlock_wrlock().

154 {
155 #endif
157 }
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
switch_thread_rwlock_t * rwlock