本文整理汇总了C++中pj_ioqueue_unregister函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_ioqueue_unregister函数的具体用法?C++ pj_ioqueue_unregister怎么用?C++ pj_ioqueue_unregister使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_ioqueue_unregister函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PJ_DEF
/**
* Close UDP transport.
*/
PJ_DEF(pj_status_t) pjmedia_transport_udp_close(pjmedia_transport *tp)
{
struct transport_udp *udp = (struct transport_udp*) tp;
/* Sanity check */
PJ_ASSERT_RETURN(tp, PJ_EINVAL);
/* Must not close while application is using this */
PJ_ASSERT_RETURN(!udp->attached, PJ_EINVALIDOP);
if (udp->rtp_key) {
pj_ioqueue_unregister(udp->rtp_key);
udp->rtp_key = NULL;
} else if (udp->rtp_sock != PJ_INVALID_SOCKET) {
pj_sock_close(udp->rtp_sock);
udp->rtp_sock = PJ_INVALID_SOCKET;
}
if (udp->rtcp_key) {
pj_ioqueue_unregister(udp->rtcp_key);
udp->rtcp_key = NULL;
} else if (udp->rtcp_sock != PJ_INVALID_SOCKET) {
pj_sock_close(udp->rtcp_sock);
udp->rtcp_sock = PJ_INVALID_SOCKET;
}
pj_pool_release(udp->pool);
return PJ_SUCCESS;
}
示例2: unregister
//
// Unregister this handler from the ioqueue.
//
void unregister()
{
if (key_) {
pj_ioqueue_unregister(key_);
key_ = NULL;
}
}
示例3: udp_destroy
/*
* Destroy listener.
*/
static pj_status_t udp_destroy(pj_turn_listener *listener)
{
struct udp_listener *udp = (struct udp_listener *)listener;
unsigned i;
if (udp->key) {
pj_ioqueue_unregister(udp->key);
udp->key = NULL;
udp->base.sock = PJ_INVALID_SOCKET;
} else if (udp->base.sock != PJ_INVALID_SOCKET) {
pj_sock_close(udp->base.sock);
udp->base.sock = PJ_INVALID_SOCKET;
}
for (i=0; i<udp->read_cnt; ++i) {
if (udp->read_op[i]->pkt.pool) {
pj_pool_t *rpool = udp->read_op[i]->pkt.pool;
udp->read_op[i]->pkt.pool = NULL;
pj_pool_release(rpool);
}
}
if (udp->base.pool) {
pj_pool_t *pool = udp->base.pool;
PJ_LOG(4,(udp->base.obj_name, "Listener %s destroyed",
udp->base.info));
udp->base.pool = NULL;
pj_pool_release(pool);
}
return PJ_SUCCESS;
}
示例4: lis_destroy
/*
* Destroy listener.
*/
static pj_status_t lis_destroy(pj_turn_listener *listener)
{
struct tcp_listener *tcp_lis = (struct tcp_listener *)listener;
unsigned i;
if (tcp_lis->key) {
pj_ioqueue_unregister(tcp_lis->key);
tcp_lis->key = NULL;
tcp_lis->base.sock = PJ_INVALID_SOCKET;
} else if (tcp_lis->base.sock != PJ_INVALID_SOCKET) {
pj_sock_close(tcp_lis->base.sock);
tcp_lis->base.sock = PJ_INVALID_SOCKET;
}
for (i=0; i<tcp_lis->accept_cnt; ++i) {
/* Nothing to do */
}
if (tcp_lis->base.pool) {
pj_pool_t *pool = tcp_lis->base.pool;
PJ_LOG(4,(tcp_lis->base.obj_name, "Listener %s destroyed",
tcp_lis->base.info));
tcp_lis->base.pool = NULL;
pj_pool_release(pool);
}
return PJ_SUCCESS;
}
示例5: unregister_handler
//
// Unregister handler.
//
static void unregister_handler(Pj_Event_Handler *handler)
{
if (handler->key_) {
pj_ioqueue_unregister( handler->key_ );
handler->key_ = NULL;
}
}
示例6: udp_destroy
/*
* udp_destroy()
*
* This function is called by transport manager (by transport->destroy()).
*/
static pj_status_t udp_destroy( pjsip_transport *transport )
{
struct udp_transport *tp = (struct udp_transport*)transport;
int i;
/* Mark this transport as closing. */
tp->is_closing = 1;
/* Cancel all pending operations. */
/* blp: NO NO NO...
* No need to post queued completion as we poll the ioqueue until
* we've got events anyway. Posting completion will only cause
* callback to be called twice with IOCP: one for the post completion
* and another one for closing the socket.
*
for (i=0; i<tp->rdata_cnt; ++i) {
pj_ioqueue_post_completion(tp->key,
&tp->rdata[i]->tp_info.op_key.op_key, -1);
}
*/
/* Unregister from ioqueue. */
if (tp->key) {
pj_ioqueue_unregister(tp->key);
tp->key = NULL;
} else {
/* Close socket. */
if (tp->sock && tp->sock != PJ_INVALID_SOCKET) {
pj_sock_close(tp->sock);
tp->sock = PJ_INVALID_SOCKET;
}
}
/* Must poll ioqueue because IOCP calls the callback when socket
* is closed. We poll the ioqueue until all pending callbacks
* have been called.
*/
for (i=0; i<50 && tp->is_closing < 1+tp->rdata_cnt; ++i) {
int cnt;
pj_time_val timeout = {0, 1};
cnt = pj_ioqueue_poll(pjsip_endpt_get_ioqueue(transport->endpt),
&timeout);
if (cnt == 0)
break;
}
if (tp->grp_lock) {
pj_grp_lock_t *grp_lock = tp->grp_lock;
tp->grp_lock = NULL;
pj_grp_lock_dec_ref(grp_lock);
/* Transport may have been deleted at this point */
} else {
udp_on_destroy(tp);
}
return PJ_SUCCESS;
}
示例7: PJ_DEF
PJ_DEF(pj_status_t) pj_activesock_close(pj_activesock_t *asock)
{
PJ_ASSERT_RETURN(asock, PJ_EINVAL);
if (asock->key) {
pj_ioqueue_unregister(asock->key);
asock->key = NULL;
}
return PJ_SUCCESS;
}
示例8: close_sock
/* Close UDP socket */
static void close_sock(pj_dns_resolver *resv)
{
/* Close existing socket */
if (resv->udp_key != NULL) {
pj_ioqueue_unregister(resv->udp_key);
resv->udp_key = NULL;
resv->udp_sock = PJ_INVALID_SOCKET;
} else if (resv->udp_sock != PJ_INVALID_SOCKET) {
pj_sock_close(resv->udp_sock);
resv->udp_sock = PJ_INVALID_SOCKET;
}
}
示例9: on_sess_timer
/* Timer callback */
static void on_sess_timer(pj_timer_heap_t *th,
pj_timer_entry *te)
{
nat_detect_session *sess;
sess = (nat_detect_session*) te->user_data;
if (te->id == TIMER_DESTROY) {
pj_grp_lock_acquire(sess->grp_lock);
pj_ioqueue_unregister(sess->key);
sess->key = NULL;
sess->sock = PJ_INVALID_SOCKET;
te->id = 0;
pj_grp_lock_release(sess->grp_lock);
sess_destroy(sess);
} else if (te->id == TIMER_TEST) {
pj_bool_t next_timer;
pj_grp_lock_acquire(sess->grp_lock);
next_timer = PJ_FALSE;
if (sess->timer_executed == 0) {
send_test(sess, ST_TEST_1, NULL, 0);
next_timer = PJ_TRUE;
} else if (sess->timer_executed == 1) {
send_test(sess, ST_TEST_2, NULL, CHANGE_IP_PORT_FLAG);
next_timer = PJ_TRUE;
} else if (sess->timer_executed == 2) {
send_test(sess, ST_TEST_3, NULL, CHANGE_PORT_FLAG);
} else {
pj_assert(!"Shouldn't have timer at this state");
}
++sess->timer_executed;
if (next_timer) {
pj_time_val delay = {0, TEST_INTERVAL};
pj_timer_heap_schedule(th, te, &delay);
} else {
te->id = 0;
}
pj_grp_lock_release(sess->grp_lock);
} else {
pj_assert(!"Invalid timer ID");
}
}
示例10: PJ_DEF
PJ_DEF(pj_status_t) pj_activesock_close(pj_activesock_t *asock)
{
PJ_ASSERT_RETURN(asock, PJ_EINVAL);
if (asock->key) {
#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
activesock_destroy_iphone_os_stream(asock);
#endif
pj_ioqueue_unregister(asock->key);
asock->key = NULL;
}
return PJ_SUCCESS;
}
示例11: PJ_DEF
/*
* Temporarily pause or shutdown the transport.
*/
PJ_DEF(pj_status_t) pjsip_udp_transport_pause(pjsip_transport *transport,
unsigned option)
{
struct udp_transport *tp;
unsigned i;
PJ_ASSERT_RETURN(transport != NULL, PJ_EINVAL);
/* Flag must be specified */
PJ_ASSERT_RETURN((option & 0x03) != 0, PJ_EINVAL);
tp = (struct udp_transport*) transport;
/* Transport must not have been paused */
PJ_ASSERT_RETURN(tp->is_paused==0, PJ_EINVALIDOP);
/* Set transport to paused first, so that when the read callback is
* called by pj_ioqueue_post_completion() it will not try to
* re-register the rdata.
*/
tp->is_paused = PJ_TRUE;
/* Cancel the ioqueue operation. */
for (i=0; i<(unsigned)tp->rdata_cnt; ++i) {
pj_ioqueue_post_completion(tp->key,
&tp->rdata[i]->tp_info.op_key.op_key, -1);
}
/* Destroy the socket? */
if (option & PJSIP_UDP_TRANSPORT_DESTROY_SOCKET) {
if (tp->key) {
/* This implicitly closes the socket */
pj_ioqueue_unregister(tp->key);
tp->key = NULL;
} else {
/* Close socket. */
if (tp->sock && tp->sock != PJ_INVALID_SOCKET) {
pj_sock_close(tp->sock);
tp->sock = PJ_INVALID_SOCKET;
}
}
tp->sock = PJ_INVALID_SOCKET;
}
PJ_LOG(4,(tp->base.obj_name, "SIP UDP transport paused"));
return PJ_SUCCESS;
}
示例12: sess_destroy
static void sess_destroy(nat_detect_session *sess)
{
if (sess->stun_sess) {
pj_stun_session_destroy(sess->stun_sess);
sess->stun_sess = NULL;
}
if (sess->key) {
pj_ioqueue_unregister(sess->key);
sess->key = NULL;
sess->sock = PJ_INVALID_SOCKET;
} else if (sess->sock && sess->sock != PJ_INVALID_SOCKET) {
pj_sock_close(sess->sock);
sess->sock = PJ_INVALID_SOCKET;
}
if (sess->grp_lock) {
pj_grp_lock_dec_ref(sess->grp_lock);
}
}
示例13: sess_destroy
static void sess_destroy(nat_detect_session *sess)
{
if (sess->stun_sess) {
pj_stun_session_destroy(sess->stun_sess);
}
if (sess->key) {
pj_ioqueue_unregister(sess->key);
} else if (sess->sock && sess->sock != PJ_INVALID_SOCKET) {
pj_sock_close(sess->sock);
}
if (sess->mutex) {
pj_mutex_destroy(sess->mutex);
}
if (sess->pool) {
pj_pool_release(sess->pool);
}
}
示例14: destroy_relay
/* Destroy relay resource */
static void destroy_relay(pj_turn_relay_res *relay)
{
if (relay->timer.id) {
pj_timer_heap_cancel(relay->allocation->server->core.timer_heap,
&relay->timer);
relay->timer.id = PJ_FALSE;
}
if (relay->tp.key) {
pj_ioqueue_unregister(relay->tp.key);
relay->tp.key = NULL;
relay->tp.sock = PJ_INVALID_SOCKET;
} else if (relay->tp.sock != PJ_INVALID_SOCKET) {
pj_sock_close(relay->tp.sock);
relay->tp.sock = PJ_INVALID_SOCKET;
}
/* Mark as shutdown */
relay->lifetime = 0;
}
示例15: PJ_DEF
/*
* Destroy DNS resolver instance.
*/
PJ_DEF(pj_status_t) pj_dns_resolver_destroy( pj_dns_resolver *resolver,
pj_bool_t notify)
{
pj_hash_iterator_t it_buf, *it;
PJ_ASSERT_RETURN(resolver, PJ_EINVAL);
if (notify) {
/*
* Notify pending queries if requested.
*/
it = pj_hash_first(resolver->hquerybyid, &it_buf);
while (it) {
pj_dns_async_query *q = (pj_dns_async_query *)
pj_hash_this(resolver->hquerybyid, it);
pj_dns_async_query *cq;
if (q->cb)
(*q->cb)(q->user_data, PJ_ECANCELLED, NULL);
cq = q->child_head.next;
while (cq != (pj_dns_async_query*)&q->child_head) {
if (cq->cb)
(*cq->cb)(cq->user_data, PJ_ECANCELLED, NULL);
cq = cq->next;
}
it = pj_hash_next(resolver->hquerybyid, it);
}
}
/* Destroy cached entries */
it = pj_hash_first(resolver->hrescache, &it_buf);
while (it) {
struct cached_res *cache;
cache = (struct cached_res*) pj_hash_this(resolver->hrescache, it);
pj_hash_set(NULL, resolver->hrescache, &cache->key,
sizeof(cache->key), 0, NULL);
pj_pool_release(cache->pool);
it = pj_hash_first(resolver->hrescache, &it_buf);
}
if (resolver->own_timer && resolver->timer) {
pj_timer_heap_destroy(resolver->timer);
resolver->timer = NULL;
}
if (resolver->udp_key != NULL) {
pj_ioqueue_unregister(resolver->udp_key);
resolver->udp_key = NULL;
resolver->udp_sock = PJ_INVALID_SOCKET;
} else if (resolver->udp_sock != PJ_INVALID_SOCKET) {
pj_sock_close(resolver->udp_sock);
resolver->udp_sock = PJ_INVALID_SOCKET;
}
if (resolver->own_ioqueue && resolver->ioqueue) {
pj_ioqueue_destroy(resolver->ioqueue);
resolver->ioqueue = NULL;
}
if (resolver->mutex) {
pj_mutex_destroy(resolver->mutex);
resolver->mutex = NULL;
}
if (resolver->pool) {
pj_pool_t *pool = resolver->pool;
resolver->pool = NULL;
pj_pool_release(pool);
}
return PJ_SUCCESS;
}