这篇教程C++ switch_thread_rwlock_wrlock函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中switch_thread_rwlock_wrlock函数的典型用法代码示例。如果您正苦于以下问题:C++ switch_thread_rwlock_wrlock函数的具体用法?C++ switch_thread_rwlock_wrlock怎么用?C++ switch_thread_rwlock_wrlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了switch_thread_rwlock_wrlock函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: SWITCH_DECLARESWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, switch_media_bug_t **bug){ switch_media_bug_t *bp = NULL, *last = NULL; switch_status_t status = SWITCH_STATUS_FALSE; switch_thread_rwlock_wrlock(session->bug_rwlock); if (session->bugs) { for (bp = session->bugs; bp; bp = bp->next) { if ((!bp->thread_id || bp->thread_id == switch_thread_self()) && bp->ready && bp == *bug) { if (last) { last->next = bp->next; } else { session->bugs = bp->next; } break; } last = bp; } } if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) { switch_core_codec_destroy(&session->bug_codec); } switch_thread_rwlock_unlock(session->bug_rwlock); if (bp) { status = switch_core_media_bug_close(&bp); } return status;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:33,
示例2: remove_xml_clientstatic switch_status_t remove_xml_client(ei_node_t *ei_node, switch_xml_binding_t *binding) { ei_xml_agent_t *agent; ei_xml_client_t *client, *prev = NULL; int found = 0; agent = (ei_xml_agent_t *)switch_xml_get_binding_user_data(binding); /* write-lock the agent */ switch_thread_rwlock_wrlock(agent->lock); client = agent->clients; while (client != NULL) { if (client->ei_node == ei_node) { found = 1; break; } prev = client; client = client->next; } if (found) { fetch_handler_t *fetch_handler; if (!prev) { agent->clients = client->next; } else { prev->next = client->next; } /* the mutex lock is not required since we have the write lock * but hey its fun and safe so do it anyway */ switch_mutex_lock(agent->current_client_mutex); if (agent->current_client == client) { agent->current_client = agent->clients; } switch_mutex_unlock(agent->current_client_mutex); fetch_handler = client->fetch_handlers; while(fetch_handler != NULL) { fetch_handler_t *tmp_fetch_handler = fetch_handler; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removed %s XML handler %s <%d.%d.%d>/n" ,xml_section_to_string(agent->section) ,fetch_handler->pid.node ,fetch_handler->pid.creation ,fetch_handler->pid.num ,fetch_handler->pid.serial); fetch_handler = fetch_handler->next; switch_safe_free(tmp_fetch_handler); } switch_safe_free(client); } switch_thread_rwlock_unlock(agent->lock); return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:60,
示例3: spy_on_hangupstatic switch_status_t spy_on_hangup(switch_core_session_t *session){ switch_channel_t *channel = switch_core_session_get_channel(session); const char *data = switch_channel_get_private(channel, "_userspy_"); const char *uuid = switch_core_session_get_uuid(session); spy_t *spy = NULL, *p = NULL, *prev = NULL; switch_thread_rwlock_wrlock(globals.spy_hash_lock); spy = switch_core_hash_find(globals.spy_hash, data); for (p = spy; p; p = p->next) { if (p->uuid == uuid) { if (prev) { prev->next = p->next; } else { spy = p->next; } globals.spy_count--; break; } prev = p; } switch_core_hash_insert(globals.spy_hash, data, spy); switch_thread_rwlock_unlock(globals.spy_hash_lock); return SWITCH_STATUS_SUCCESS;}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:29,
示例4: SWITCH_DECLARESWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all_function(switch_core_session_t *session, const char *function){ switch_media_bug_t *bp; switch_status_t status = SWITCH_STATUS_FALSE; if (session->bugs) { switch_thread_rwlock_wrlock(session->bug_rwlock); for (bp = session->bugs; bp; bp = bp->next) { if ((bp->thread_id && bp->thread_id != switch_thread_self()) || switch_test_flag(bp, SMBF_LOCK)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "BUG is thread locked skipping./n"); continue; } if (!zstr(function) && strcmp(bp->function, function)) { continue; } if (bp->callback) { bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_CLOSE); } switch_core_media_bug_destroy(bp); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Removing BUG from %s/n", switch_channel_get_name(session->channel)); } session->bugs = NULL; switch_thread_rwlock_unlock(session->bug_rwlock); status = SWITCH_STATUS_SUCCESS; } if (switch_core_codec_ready(&session->bug_codec)) { switch_core_codec_destroy(&session->bug_codec); } return status;}
开发者ID:benlangfeld,项目名称:FreeSWITCH,代码行数:35,
示例5: limit_remote_destroyvoid limit_remote_destroy(limit_remote_t **r){ if (r && *r) { switch_hash_index_t *hi; (*r)->state = REMOTE_OFF; if ((*r)->thread) { switch_status_t retval; switch_thread_join(&retval, (*r)->thread); } switch_thread_rwlock_wrlock((*r)->rwlock); /* Free hashtable data */ for (hi = switch_hash_first(NULL, (*r)->index); hi; hi = switch_hash_next(hi)) { void *val; const void *key; switch_ssize_t keylen; switch_hash_this(hi, &key, &keylen, &val); free(val); } switch_thread_rwlock_unlock((*r)->rwlock); switch_thread_rwlock_destroy((*r)->rwlock); switch_core_destroy_memory_pool(&((*r)->pool)); *r = NULL; }}
开发者ID:moises-silva,项目名称:mod_conference-admin,代码行数:31,
示例6: SWITCH_DECLARESWITCH_DECLARE(switch_status_t) switch_core_hash_insert_wrlock(switch_hash_t *hash, const char *key, const void *data, switch_thread_rwlock_t *rwlock){ if (rwlock) { switch_thread_rwlock_wrlock(rwlock); } sqlite3HashInsert(&hash->table, key, (int) strlen(key) + 1, (void *) data); if (rwlock) { switch_thread_rwlock_unlock(rwlock); } return SWITCH_STATUS_SUCCESS;}
开发者ID:moises-silva,项目名称:freeswitch,代码行数:14,
示例7: SWITCH_DECLARESWITCH_DECLARE(switch_status_t) switch_core_hash_insert_wrlock(switch_hash_t *hash, const char *key, const void *data, switch_thread_rwlock_t *rwlock){ if (rwlock) { switch_thread_rwlock_wrlock(rwlock); } switch_core_hash_insert(hash, key, data); if (rwlock) { switch_thread_rwlock_unlock(rwlock); } return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:14,
示例8: remove_fetch_handlerstatic switch_status_t remove_fetch_handler(ei_node_t *ei_node, erlang_pid *from, switch_xml_binding_t *binding) { ei_xml_agent_t *agent; ei_xml_client_t *client; fetch_handler_t *fetch_handler, *prev = NULL; int found = 0; agent = (ei_xml_agent_t *)switch_xml_get_binding_user_data(binding); /* write-lock the agent */ switch_thread_rwlock_wrlock(agent->lock); if (!(client = find_xml_client(ei_node, agent))) { switch_thread_rwlock_unlock(agent->lock); return SWITCH_STATUS_SUCCESS; } fetch_handler = client->fetch_handlers; while (fetch_handler != NULL) { if (ei_compare_pids(&fetch_handler->pid, from) == SWITCH_STATUS_SUCCESS) { found = 1; break; } prev = fetch_handler; fetch_handler = fetch_handler->next; } if (found) { if (!prev) { client->fetch_handlers = fetch_handler->next; } else { prev->next = fetch_handler->next; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removed %s XML handler %s <%d.%d.%d>/n" ,xml_section_to_string(agent->section) ,fetch_handler->pid.node ,fetch_handler->pid.creation ,fetch_handler->pid.num ,fetch_handler->pid.serial); switch_safe_free(fetch_handler); } switch_thread_rwlock_unlock(agent->lock); return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:47,
示例9: add_fetch_handlerswitch_status_t add_fetch_handler(ei_node_t *ei_node, erlang_pid *from, switch_xml_binding_t *binding) { ei_xml_agent_t *agent; ei_xml_client_t *client; fetch_handler_t *fetch_handler; agent = (ei_xml_agent_t *)switch_xml_get_binding_user_data(binding); /* write-lock the agent */ switch_thread_rwlock_wrlock(agent->lock); if (!(client = find_xml_client(ei_node, agent))) { client = add_xml_client(ei_node, agent); } fetch_handler = client->fetch_handlers; while (fetch_handler != NULL) { if (ei_compare_pids(&fetch_handler->pid, from) == SWITCH_STATUS_SUCCESS) { switch_thread_rwlock_unlock(agent->lock); return SWITCH_STATUS_SUCCESS; } fetch_handler = fetch_handler->next; } switch_malloc(fetch_handler, sizeof(*fetch_handler)); memcpy(&fetch_handler->pid, from, sizeof(erlang_pid));; fetch_handler->next = NULL; if (client->fetch_handlers) { fetch_handler->next = client->fetch_handlers; } client->fetch_handlers = fetch_handler; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Added %s XML handler %s <%d.%d.%d>/n" ,xml_section_to_string(agent->section) ,fetch_handler->pid.node ,fetch_handler->pid.creation ,fetch_handler->pid.num ,fetch_handler->pid.serial); switch_thread_rwlock_unlock(agent->lock); ei_link(ei_node, ei_self(&globals.ei_cnode), from); return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:47,
示例10: SWITCH_DECLARESWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session){ switch_media_bug_t *bp; char *list[100] = { 0 }; int stop_times[100] = { 0 }; int i = 0, x = 0; if (orig_session->bugs) { switch_channel_t *new_channel = switch_core_session_get_channel(new_session); switch_channel_t *orig_channel = switch_core_session_get_channel(orig_session); const char *save_append = switch_channel_get_variable(new_channel, "record_append"); const char *save_stereo = switch_channel_get_variable(new_channel, "record_stereo"); const char *orig_stereo = switch_channel_get_variable(orig_channel, "record_stereo"); const char *new_stereo = orig_stereo; switch_thread_rwlock_wrlock(orig_session->bug_rwlock); switch_channel_set_variable(new_channel, "RECORD_MIN_SEC", "0"); switch_channel_set_variable(new_channel, "record_append", "true"); switch_channel_set_variable(new_channel, "record_stereo", new_stereo); for (bp = orig_session->bugs; bp; bp = bp->next) { if (!strcmp(bp->function, "session_record")) { list[x] = switch_core_session_strdup(new_session, bp->target); if (bp->stop_time > 0) { stop_times[x] = (int)(bp->stop_time - switch_epoch_time_now(NULL)); } x++; } } switch_thread_rwlock_unlock(orig_session->bug_rwlock); for(i = 0; i < x; i++) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_DEBUG, "Transfering %s from %s to %s/n", list[i], switch_core_session_get_name(orig_session), switch_core_session_get_name(new_session)); switch_ivr_stop_record_session(orig_session, list[i]); switch_ivr_record_session(new_session, list[i], stop_times[i], NULL); } switch_channel_set_variable(new_channel, "record_append", save_append); switch_channel_set_variable(new_channel, "record_stereo", save_stereo); } return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;}
开发者ID:utkarsh301994,项目名称:localhost,代码行数:46,
示例11: spy_on_hangupstatic switch_status_t spy_on_hangup(switch_core_session_t *session){ switch_channel_t *channel = switch_core_session_get_channel(session); char *data = switch_channel_get_private(channel, "_userspy_"); switch_thread_rwlock_wrlock(globals.spy_hash_lock); if ((switch_core_hash_delete(globals.spy_hash, data) != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No such key in userspy: %s /n", data); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Userspy deactivated on %s/n", data); globals.spy_count--; } switch_thread_rwlock_unlock(globals.spy_hash_lock); return SWITCH_STATUS_SUCCESS;}
开发者ID:Deepwalker,项目名称:FreeSWITCH,代码行数:18,
示例12: SWITCH_DECLARESWITCH_DECLARE(switch_status_t) switch_core_session_set_real_read_codec(switch_core_session_t *session, switch_codec_t *codec){ switch_event_t *event; switch_channel_t *channel = switch_core_session_get_channel(session); char tmp[30]; switch_status_t status = SWITCH_STATUS_SUCCESS; int changed_read_codec = 0; switch_mutex_lock(session->codec_read_mutex); if (codec && (!codec->implementation || !switch_core_codec_ready(codec))) { codec = NULL; } if (codec) { /* set real_read_codec and read_codec */ if (!session->real_read_codec) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Original read codec set to %s:%d/n", switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode); session->read_codec = session->real_read_codec = codec; changed_read_codec = 1; if (codec->implementation) { session->read_impl = *codec->implementation; session->real_read_impl = *codec->implementation; } else { memset(&session->read_impl, 0, sizeof(session->read_impl)); } } else { /* replace real_read_codec */ switch_codec_t *cur_codec; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Original read codec replaced with %s:%d/n", switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode); /* Set real_read_codec to front of the list of read_codecs */ cur_codec = session->read_codec; while (cur_codec != NULL) { if (cur_codec->next == session->real_read_codec) { cur_codec->next = codec; break; } cur_codec = cur_codec->next; } session->real_read_codec = codec; /* set read_codec with real_read_codec if it no longer is ready */ if (!switch_core_codec_ready(session->read_codec)) { session->read_codec = codec; changed_read_codec = 1; if (codec->implementation) { session->read_impl = *codec->implementation; session->real_read_impl = *codec->implementation; } else { memset(&session->read_impl, 0, sizeof(session->read_impl)); } } } /* force media bugs to copy the read codec from the next frame */ switch_thread_rwlock_wrlock(session->bug_rwlock); if (switch_core_codec_ready(&session->bug_codec)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Destroying BUG Codec %s:%d/n", session->bug_codec.implementation->iananame, session->bug_codec.implementation->ianacode); switch_core_codec_destroy(&session->bug_codec); } switch_thread_rwlock_unlock(session->bug_rwlock); } else { status = SWITCH_STATUS_FALSE; goto end; } if (changed_read_codec && session->read_codec && session->read_impl.decoded_bytes_per_packet) { if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(session->channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", session->read_impl.iananame); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-rate", "%d", session->read_impl.actual_samples_per_second); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-bit-rate", "%d", session->read_impl.bits_per_second); if (session->read_impl.actual_samples_per_second != session->read_impl.samples_per_second) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-read-codec-rate", "%d", session->read_impl.samples_per_second); } switch_event_fire(&event); } switch_channel_set_variable(channel, "read_codec", session->read_impl.iananame); switch_snprintf(tmp, sizeof(tmp), "%d", session->read_impl.actual_samples_per_second); switch_channel_set_variable(channel, "read_rate", tmp); session->raw_read_frame.codec = session->read_codec; session->raw_write_frame.codec = session->read_codec; session->enc_read_frame.codec = session->read_codec; session->enc_write_frame.codec = session->read_codec; } end: if (session->read_codec) { switch_channel_set_flag(channel, CF_MEDIA_SET); } switch_mutex_unlock(session->codec_read_mutex); return status;}
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:98,
示例13: unbind_fetch_agentstatic switch_status_t unbind_fetch_agent(switch_xml_binding_t **binding) { ei_xml_agent_t *agent; ei_xml_client_t *client; /* get a pointer to our user_data */ agent = (ei_xml_agent_t *)switch_xml_get_binding_user_data(*binding); /* unbind from the switch */ switch_xml_unbind_search_function(binding); /* LOCK ALL THE THINGS */ switch_thread_rwlock_wrlock(agent->lock); switch_mutex_lock(agent->current_client_mutex); switch_mutex_lock(agent->replies_mutex); /* cleanly destroy each client */ client = agent->clients; while(client != NULL) { ei_xml_client_t *tmp_client = client; fetch_handler_t *fetch_handler; fetch_handler = client->fetch_handlers; while(fetch_handler != NULL) { fetch_handler_t *tmp_fetch_handler = fetch_handler; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removed %s XML handler %s <%d.%d.%d>/n" ,xml_section_to_string(agent->section) ,fetch_handler->pid.node ,fetch_handler->pid.creation ,fetch_handler->pid.num ,fetch_handler->pid.serial); fetch_handler = fetch_handler->next; switch_safe_free(tmp_fetch_handler); } client = client->next; switch_safe_free(tmp_client); } /* keep the pointers clean, even if its just for a moment */ agent->clients = NULL; agent->current_client = NULL; /* release the locks! */ switch_thread_rwlock_unlock(agent->lock); switch_mutex_unlock(agent->current_client_mutex); switch_mutex_unlock(agent->replies_mutex); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unbound from %s XML requests/n" ,xml_section_to_string(agent->section)); /* cleanly destroy the bindings */ switch_thread_rwlock_destroy(agent->lock); switch_mutex_destroy(agent->current_client_mutex); switch_mutex_destroy(agent->replies_mutex); switch_thread_cond_destroy(agent->new_reply); switch_core_destroy_memory_pool(&agent->pool); return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:61,
示例14: free_contextstatic inline void free_context(shout_context_t *context){ int ret; if (context) { switch_mutex_lock(context->audio_mutex); context->err++; switch_mutex_unlock(context->audio_mutex); if (context->stream_url) { int sanity = 0; while (context->thread_running) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for stream to terminate: %s/n", context->stream_url); switch_yield(500000); if (++sanity > 10) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Giving up waiting for stream to terminate: %s/n", context->stream_url); break; } } } switch_thread_rwlock_wrlock(context->rwlock); if (context->mh) { mpg123_close(context->mh); mpg123_delete(context->mh); } if (context->fp) { unsigned char mp3buffer[8192]; int len; int16_t blank[2048] = { 0 }, *r = NULL; if (context->channels == 2) { r = blank; } len = lame_encode_buffer(context->gfp, blank, r, sizeof(blank) / 2, mp3buffer, sizeof(mp3buffer)); if (len) { ret = fwrite(mp3buffer, 1, len, context->fp); } while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) { ret = fwrite(mp3buffer, 1, len, context->fp); if (ret < 0) { break; } } lame_mp3_tags_fid(context->gfp, context->fp); fclose(context->fp); context->fp = NULL; } if (context->shout) { shout_close(context->shout); context->shout = NULL; } if (context->gfp) { lame_close(context->gfp); context->gfp = NULL; } if (context->audio_buffer) { switch_buffer_destroy(&context->audio_buffer); } switch_mutex_destroy(context->audio_mutex); switch_thread_rwlock_unlock(context->rwlock); switch_thread_rwlock_destroy(context->rwlock); }}
开发者ID:moises-silva,项目名称:mod_handsfree,代码行数:78,
注:本文中的switch_thread_rwlock_wrlock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ switch_true函数代码示例 C++ switch_thread_rwlock_unlock函数代码示例 |