FreeSWITCH API Documentation  1.7.0
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_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, 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_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) {
89  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  }
99  }
100 #ifdef SWITCH_DEBUG_RWLOCKS
101  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",
103 #endif
104  } else {
106 #ifdef SWITCH_DEBUG_RWLOCKS
107  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",
109 #endif
110  }
111  }
112 
113  return status;
114 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
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:232
#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:624
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_status_t switch_core_session_read_lock_hangup ( switch_core_session_t session)

Definition at line 120 of file switch_core_rwlock.c.

References CS_DESTROY, SSF_DESTROYED, switch_channel_get_name(), switch_channel_get_state(), SWITCH_CHANNEL_ID_LOG, switch_core_session_get_uuid(), SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, switch_test_flag, and switch_thread_rwlock_tryrdlock().

122 {
124 
125  if (session->rwlock) {
127  status = SWITCH_STATUS_FALSE;
128 #ifdef SWITCH_DEBUG_RWLOCKS
129  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",
131 #endif
132  } else {
134 #ifdef SWITCH_DEBUG_RWLOCKS
135  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",
137 #endif
138  }
139  }
140 
141  return status;
142 }
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
switch_channel_t * channel
switch_status_t switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:232
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:624
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
void switch_core_session_rwunlock ( switch_core_session_t session)

Definition at line 163 of file switch_core_rwlock.c.

References switch_thread_rwlock_unlock().

164 {
165 #endif
167 
168 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
switch_thread_rwlock_t * rwlock
void switch_core_session_write_lock ( switch_core_session_t session)

Definition at line 151 of file switch_core_rwlock.c.

References switch_thread_rwlock_wrlock().

152 {
153 #endif
155 }
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:237
switch_thread_rwlock_t * rwlock