本文整理汇总了C++中pj_ioqueue_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_ioqueue_destroy函数的具体用法?C++ pj_ioqueue_destroy怎么用?C++ pj_ioqueue_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_ioqueue_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PJ_DEF
/**
* Deinitialize media endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_endpt_destroy (pjmedia_endpt *endpt)
{
exit_cb *ecb;
pjmedia_endpt_stop_threads(endpt);
/* Destroy internal ioqueue */
if (endpt->ioqueue && endpt->own_ioqueue) {
pj_ioqueue_destroy(endpt->ioqueue);
endpt->ioqueue = NULL;
}
endpt->pf = NULL;
pjmedia_codec_mgr_destroy(&endpt->codec_mgr);
pjmedia_aud_subsys_shutdown();
/* Call all registered exit callbacks */
ecb = endpt->exit_cb_list.next;
while (ecb != &endpt->exit_cb_list) {
(*ecb->func)(endpt);
ecb = ecb->next;
}
pj_pool_release (endpt->pool);
return PJ_SUCCESS;
}
示例2: create_stun_config
pj_status_t create_stun_config(pj_pool_t *pool, pj_stun_config *stun_cfg)
{
pj_ioqueue_t *ioqueue;
pj_timer_heap_t *timer_heap;
pj_lock_t *lock;
pj_status_t status;
status = pj_ioqueue_create(pool, 64, &ioqueue);
if (status != PJ_SUCCESS) {
app_perror(" pj_ioqueue_create()", status);
return status;
}
status = pj_timer_heap_create(pool, 256, &timer_heap);
if (status != PJ_SUCCESS) {
app_perror(" pj_timer_heap_create()", status);
pj_ioqueue_destroy(ioqueue);
return status;
}
pj_lock_create_recursive_mutex(pool, NULL, &lock);
pj_timer_heap_set_lock(timer_heap, lock, PJ_TRUE);
pj_stun_config_init(stun_cfg, mem, 0, ioqueue, timer_heap);
return PJ_SUCCESS;
}
示例3: PJ_DEF
/**
* Deinitialize media endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_endpt_destroy (pjmedia_endpt *endpt)
{
unsigned i;
PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
endpt->quit_flag = 1;
/* Destroy threads */
for (i=0; i<endpt->thread_cnt; ++i) {
if (endpt->thread[i]) {
pj_thread_join(endpt->thread[i]);
pj_thread_destroy(endpt->thread[i]);
endpt->thread[i] = NULL;
}
}
/* Destroy internal ioqueue */
if (endpt->ioqueue && endpt->own_ioqueue) {
pj_ioqueue_destroy(endpt->ioqueue);
endpt->ioqueue = NULL;
}
endpt->pf = NULL;
pjmedia_aud_subsys_shutdown();
pj_pool_release (endpt->pool);
return PJ_SUCCESS;
}
示例4: err_exit
/* Utility: display error message and exit application (usually
* because of fatal error.
*/
static void err_exit(const char *title, pj_status_t status)
{
if (status != PJ_SUCCESS) {
icedemo_perror(title, status);
}
PJ_LOG(3,(THIS_FILE, "Shutting down.."));
if (icedemo.icest)
pj_ice_strans_destroy(icedemo.icest);
pj_thread_sleep(500);
icedemo.thread_quit_flag = PJ_TRUE;
if (icedemo.thread) {
pj_thread_join(icedemo.thread);
pj_thread_destroy(icedemo.thread);
}
if (icedemo.ice_cfg.stun_cfg.ioqueue)
pj_ioqueue_destroy(icedemo.ice_cfg.stun_cfg.ioqueue);
if (icedemo.ice_cfg.stun_cfg.timer_heap)
pj_timer_heap_destroy(icedemo.ice_cfg.stun_cfg.timer_heap);
pj_caching_pool_destroy(&icedemo.cp);
pj_shutdown();
if (icedemo.log_fhnd) {
fclose(icedemo.log_fhnd);
icedemo.log_fhnd = NULL;
}
exit(status != PJ_SUCCESS);
}
示例5: destroy_stun_config
void destroy_stun_config(pj_stun_config *stun_cfg)
{
if (stun_cfg->timer_heap) {
pj_timer_heap_destroy(stun_cfg->timer_heap);
stun_cfg->timer_heap = NULL;
}
if (stun_cfg->ioqueue) {
pj_ioqueue_destroy(stun_cfg->ioqueue);
stun_cfg->ioqueue = NULL;
}
}
示例6: destroy
//
// Destroy proactor.
//
void destroy()
{
if (ioq_) {
pj_ioqueue_destroy(ioq_);
ioq_ = NULL;
}
if (th_) {
pj_timer_heap_destroy(th_);
th_ = NULL;
}
}
示例7: stun_sock_test
int stun_sock_test(void)
{
struct pjlib_state pjlib_state;
pj_stun_config stun_cfg;
pj_ioqueue_t *ioqueue = NULL;
pj_timer_heap_t *timer_heap = NULL;
pj_pool_t *pool = NULL;
pj_status_t status;
int ret = 0;
pool = pj_pool_create(mem, NULL, 512, 512, NULL);
status = pj_ioqueue_create(pool, 12, &ioqueue);
if (status != PJ_SUCCESS) {
app_perror(" pj_ioqueue_create()", status);
ret = -4;
goto on_return;
}
status = pj_timer_heap_create(pool, 100, &timer_heap);
if (status != PJ_SUCCESS) {
app_perror(" pj_timer_heap_create()", status);
ret = -8;
goto on_return;
}
pj_stun_config_init(&stun_cfg, mem, 0, ioqueue, timer_heap);
DO_TEST(timeout_test(&stun_cfg, PJ_FALSE));
DO_TEST(timeout_test(&stun_cfg, PJ_TRUE));
DO_TEST(missing_attr_test(&stun_cfg, PJ_FALSE));
DO_TEST(missing_attr_test(&stun_cfg, PJ_TRUE));
DO_TEST(keep_alive_test(&stun_cfg));
on_return:
if (timer_heap) pj_timer_heap_destroy(timer_heap);
if (ioqueue) pj_ioqueue_destroy(ioqueue);
if (pool) pj_pool_release(pool);
return ret;
}
示例8: getURL
pj_status_t getURL(const char *curl)
{
pj_str_t url;
pj_http_req_callback hcb;
pj_status_t status;
pj_bzero(&hcb, sizeof(hcb));
hcb.on_complete = &on_complete;
hcb.on_data_read = &on_data_read;
hcb.on_send_data = &on_send_data;
hcb.on_response = &on_response;
/* Create pool, timer, and ioqueue */
pool = pj_pool_create(mem, NULL, 8192, 4096, NULL);
if (pj_timer_heap_create(pool, 16, &timer_heap))
return -31;
if (pj_ioqueue_create(pool, 16, &ioqueue))
return -32;
pj_strdup2(pool, &url, curl);
if ((status = pj_http_req_create(pool, &url, timer_heap, ioqueue,
NULL, &hcb, &http_req)) != PJ_SUCCESS)
return status;
if ((status = pj_http_req_start(http_req)) != PJ_SUCCESS)
return status;
while (pj_http_req_is_running(http_req)) {
pj_time_val delay = {0, 50};
pj_ioqueue_poll(ioqueue, &delay);
pj_timer_heap_poll(timer_heap, NULL);
}
pj_http_req_destroy(http_req);
pj_ioqueue_destroy(ioqueue);
pj_timer_heap_destroy(timer_heap);
pj_pool_release(pool);
return PJ_SUCCESS;
}
示例9: create
//
// Create proactor.
//
pj_status_t create( Pj_Pool *pool, pj_size_t max_fd,
pj_size_t timer_entry_count)
{
pj_status_t status;
destroy();
status = pj_ioqueue_create(pool->pool_(), max_fd, &ioq_);
if (status != PJ_SUCCESS)
return status;
status = pj_timer_heap_create(pool->pool_(),
timer_entry_count, &th_);
if (status != PJ_SUCCESS) {
pj_ioqueue_destroy(ioq_);
ioq_ = NULL;
return NULL;
}
return status;
}
示例10: PJ_DEF
/**
* Deinitialize media endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_endpt_destroy (pjmedia_endpt *endpt)
{
exit_cb *ecb;
unsigned i;
PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
endpt->quit_flag = 1;
/* Destroy threads */
for (i=0; i<endpt->thread_cnt; ++i) {
if (endpt->thread[i]) {
pj_thread_join(endpt->thread[i]);
pj_thread_destroy(endpt->thread[i]);
endpt->thread[i] = NULL;
}
}
/* Destroy internal ioqueue */
if (endpt->ioqueue && endpt->own_ioqueue) {
pj_ioqueue_destroy(endpt->ioqueue);
endpt->ioqueue = NULL;
}
endpt->pf = NULL;
pjmedia_codec_mgr_destroy(&endpt->codec_mgr);
pjmedia_aud_subsys_shutdown();
/* Call all registered exit callbacks */
ecb = endpt->exit_cb_list.next;
while (ecb != &endpt->exit_cb_list) {
(*ecb->func)(endpt);
ecb = ecb->next;
}
pj_pool_release (endpt->pool);
return PJ_SUCCESS;
}
示例11: client_shutdown
static int client_shutdown()
{
unsigned i;
if (g.thread) {
g.quit = 1;
pj_thread_join(g.thread);
pj_thread_destroy(g.thread);
g.thread = NULL;
}
if (g.relay) {
pj_turn_sock_destroy(g.relay);
g.relay = NULL;
}
for (i=0; i<PJ_ARRAY_SIZE(g.peer); ++i) {
if (g.peer[i].stun_sock) {
pj_stun_sock_destroy(g.peer[i].stun_sock);
g.peer[i].stun_sock = NULL;
}
}
if (g.stun_config.timer_heap) {
pj_timer_heap_destroy(g.stun_config.timer_heap);
g.stun_config.timer_heap = NULL;
}
if (g.stun_config.ioqueue) {
pj_ioqueue_destroy(g.stun_config.ioqueue);
g.stun_config.ioqueue = NULL;
}
if (g.pool) {
pj_pool_release(g.pool);
g.pool = NULL;
}
pj_pool_factory_dump(&g.cp.factory, PJ_TRUE);
pj_caching_pool_destroy(&g.cp);
return PJ_SUCCESS;
}
示例12: many_handles_test
/*
* Testing with many handles.
* This will just test registering PJ_IOQUEUE_MAX_HANDLES count
* of sockets to the ioqueue.
*/
static int many_handles_test(pj_bool_t allow_concur)
{
enum { MAX = PJ_IOQUEUE_MAX_HANDLES };
pj_pool_t *pool;
pj_ioqueue_t *ioqueue;
pj_sock_t *sock;
pj_ioqueue_key_t **key;
pj_status_t rc;
int count, i; /* must be signed */
PJ_LOG(3,(THIS_FILE,"...testing with so many handles"));
pool = pj_pool_create(mem, NULL, 4000, 4000, NULL);
if (!pool)
return PJ_ENOMEM;
key = (pj_ioqueue_key_t**)
pj_pool_alloc(pool, MAX*sizeof(pj_ioqueue_key_t*));
sock = (pj_sock_t*) pj_pool_alloc(pool, MAX*sizeof(pj_sock_t));
/* Create IOQueue */
rc = pj_ioqueue_create(pool, MAX, &ioqueue);
if (rc != PJ_SUCCESS || ioqueue == NULL) {
app_perror("...error in pj_ioqueue_create", rc);
return -10;
}
// Set concurrency
rc = pj_ioqueue_set_default_concurrency(ioqueue, allow_concur);
if (rc != PJ_SUCCESS) {
return -11;
}
/* Register as many sockets. */
for (count=0; count<MAX; ++count) {
sock[count] = PJ_INVALID_SOCKET;
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock[count]);
if (rc != PJ_SUCCESS || sock[count] == PJ_INVALID_SOCKET) {
PJ_LOG(3,(THIS_FILE, "....unable to create %d-th socket, rc=%d",
count, rc));
break;
}
key[count] = NULL;
rc = pj_ioqueue_register_sock(pool, ioqueue, sock[count],
NULL, &test_cb, &key[count]);
if (rc != PJ_SUCCESS || key[count] == NULL) {
PJ_LOG(3,(THIS_FILE, "....unable to register %d-th socket, rc=%d",
count, rc));
return -30;
}
}
/* Test complete. */
/* Now deregister and close all handles. */
/* NOTE for RTEMS:
* It seems that the order of close(sock) is pretty important here.
* If we close the sockets with the same order as when they were created,
* RTEMS doesn't seem to reuse the sockets, thus next socket created
* will have descriptor higher than the last socket created.
* If we close the sockets in the reverse order, then the descriptor will
* get reused.
* This used to cause problem with select ioqueue, since the ioqueue
* always gives FD_SETSIZE for the first select() argument. This ioqueue
* behavior can be changed with setting PJ_SELECT_NEEDS_NFDS macro.
*/
for (i=count-1; i>=0; --i) {
///for (i=0; i<count; ++i) {
rc = pj_ioqueue_unregister(key[i]);
if (rc != PJ_SUCCESS) {
app_perror("...error in pj_ioqueue_unregister", rc);
}
}
rc = pj_ioqueue_destroy(ioqueue);
if (rc != PJ_SUCCESS) {
app_perror("...error in pj_ioqueue_destroy", rc);
}
pj_pool_release(pool);
PJ_LOG(3,(THIS_FILE,"....many_handles_test() ok"));
return 0;
}
示例13: bench_test
//.........这里部分代码省略.........
app_perror("...error: pj_ioqueue_sendto()",(pj_status_t)-bytes);
break;
}
}
// Begin time.
pj_get_timestamp(&t1);
// Poll the queue until we've got completion event in the server side.
callback_read_key = NULL;
callback_read_size = 0;
TRACE__((THIS_FILE, " waiting for key = %p", skey));
do {
pj_time_val timeout = { 1, 0 };
#ifdef PJ_SYMBIAN
rc = pj_symbianos_poll(-1, PJ_TIME_VAL_MSEC(timeout));
#else
rc = pj_ioqueue_poll(ioque, &timeout);
#endif
TRACE__((THIS_FILE, " poll rc=%d", rc));
} while (rc >= 0 && callback_read_key != skey);
// End time.
pj_get_timestamp(&t2);
t_elapsed.u64 += (t2.u64 - t1.u64);
if (rc < 0) {
app_perror(" error: pj_ioqueue_poll", -rc);
break;
}
// Compare recv buffer with send buffer.
if (callback_read_size != bufsize ||
pj_memcmp(send_buf, recv_buf, bufsize))
{
rc = -10;
PJ_LOG(3,(THIS_FILE, " error: size/buffer mismatch"));
break;
}
// Poll until all events are exhausted, before we start the next loop.
do {
pj_time_val timeout = { 0, 10 };
#ifdef PJ_SYMBIAN
PJ_UNUSED_ARG(timeout);
rc = pj_symbianos_poll(-1, 100);
#else
rc = pj_ioqueue_poll(ioque, &timeout);
#endif
} while (rc>0);
rc = 0;
}
// Print results
if (rc == 0) {
pj_timestamp tzero;
pj_uint32_t usec_delay;
tzero.u32.hi = tzero.u32.lo = 0;
usec_delay = pj_elapsed_usec( &tzero, &t_elapsed);
PJ_LOG(3, (THIS_FILE, "...%10d %15d % 9d",
bufsize, inactive_sock_count, usec_delay));
} else {
PJ_LOG(2, (THIS_FILE, "...ERROR rc=%d (buf:%d, fds:%d)",
rc, bufsize, inactive_sock_count+2));
}
// Cleaning up.
for (i=inactive_sock_count-1; i>=0; --i) {
pj_ioqueue_unregister(keys[i]);
}
pj_ioqueue_unregister(skey);
pj_ioqueue_unregister(ckey);
pj_ioqueue_destroy(ioque);
pj_pool_release( pool);
return rc;
on_error:
PJ_LOG(1,(THIS_FILE, "...ERROR: %s",
pj_strerror(pj_get_netos_error(), errbuf, sizeof(errbuf))));
if (ssock)
pj_sock_close(ssock);
if (csock)
pj_sock_close(csock);
for (i=0; i<inactive_sock_count && inactive_sock &&
inactive_sock[i]!=PJ_INVALID_SOCKET; ++i)
{
pj_sock_close(inactive_sock[i]);
}
if (ioque != NULL)
pj_ioqueue_destroy(ioque);
pj_pool_release( pool);
return -1;
}
示例14: compliance_test
//.........这里部分代码省略.........
if (rc != PJ_SUCCESS && rc != PJ_EPENDING) {
app_perror("...error: pj_ioqueue_sendto", rc);
status=-30; goto on_error;
} else if (rc == PJ_EPENDING) {
send_pending = 1;
PJ_LOG(3, (THIS_FILE,
"......ok: sendto returned pending"));
} else {
send_pending = 0;
PJ_LOG(3, (THIS_FILE,
"......ok: sendto returned immediate success"));
}
// reset callback variables.
callback_read_size = callback_write_size = 0;
callback_accept_status = callback_connect_status = -2;
callback_read_key = callback_write_key =
callback_accept_key = callback_connect_key = NULL;
callback_read_op = callback_write_op = NULL;
// Poll if pending.
while (send_pending || recv_pending) {
int rc;
pj_time_val timeout = { 5, 0 };
TRACE_("poll...");
#ifdef PJ_SYMBIAN
rc = pj_symbianos_poll(-1, PJ_TIME_VAL_MSEC(timeout));
#else
rc = pj_ioqueue_poll(ioque, &timeout);
#endif
if (rc == 0) {
PJ_LOG(1,(THIS_FILE, "...ERROR: timed out..."));
status=-45; goto on_error;
} else if (rc < 0) {
app_perror("...ERROR in ioqueue_poll()", -rc);
status=-50; goto on_error;
}
if (callback_read_key != NULL) {
if (callback_read_size != bufsize) {
status=-61; goto on_error;
}
if (callback_read_key != skey) {
status=-65; goto on_error;
}
if (callback_read_op != &read_op) {
status=-66; goto on_error;
}
if (pj_memcmp(send_buf, recv_buf, bufsize) != 0) {
status=-67; goto on_error;
}
if (addrlen != sizeof(pj_sockaddr_in)) {
status=-68; goto on_error;
}
if (addr.sin_family != pj_AF_INET()) {
status=-69; goto on_error;
}
recv_pending = 0;
}
if (callback_write_key != NULL) {
if (callback_write_size != bufsize) {
status=-73; goto on_error;
}
if (callback_write_key != ckey) {
status=-75; goto on_error;
}
if (callback_write_op != &write_op) {
status=-76; goto on_error;
}
send_pending = 0;
}
}
// Success
status = 0;
on_error:
if (skey)
pj_ioqueue_unregister(skey);
else if (ssock != -1)
pj_sock_close(ssock);
if (ckey)
pj_ioqueue_unregister(ckey);
else if (csock != -1)
pj_sock_close(csock);
if (ioque != NULL)
pj_ioqueue_destroy(ioque);
pj_pool_release(pool);
return status;
}
示例15: unregister_test
//.........这里部分代码省略.........
/* Init operation key. */
pj_ioqueue_op_key_init(&opkey, sizeof(opkey));
/* Start reading. */
bytes = sizeof(recvbuf);
status = pj_ioqueue_recv( key, &opkey, recvbuf, &bytes, 0);
if (status != PJ_EPENDING) {
app_perror("Expecting PJ_EPENDING, but got this", status);
return -150;
}
/* Init destination address. */
addrlen = sizeof(addr);
status = pj_sock_getsockname(rsock, &addr, &addrlen);
if (status != PJ_SUCCESS) {
app_perror("getsockname error", status);
return -160;
}
/* Override address with 127.0.0.1, since getsockname will return
* zero in the address field.
*/
addr.sin_addr = pj_inet_addr2("127.0.0.1");
/* Init buffer to send */
pj_ansi_strcpy(sendbuf, "Hello0123");
/* Send one packet. */
bytes = sizeof(sendbuf);
status = pj_sock_sendto(ssock, sendbuf, &bytes, 0,
&addr, sizeof(addr));
if (status != PJ_SUCCESS) {
app_perror("sendto error", status);
return -170;
}
/* Check if packet is received. */
timeout.sec = 1; timeout.msec = 0;
#ifdef PJ_SYMBIAN
pj_symbianos_poll(-1, 1000);
#else
pj_ioqueue_poll(ioqueue, &timeout);
#endif
if (packet_cnt != 1) {
return -180;
}
/* Just to make sure things are settled.. */
pj_thread_sleep(100);
/* Start reading again. */
bytes = sizeof(recvbuf);
status = pj_ioqueue_recv( key, &opkey, recvbuf, &bytes, 0);
if (status != PJ_EPENDING) {
app_perror("Expecting PJ_EPENDING, but got this", status);
return -190;
}
/* Reset packet counter */
packet_cnt = 0;
/* Send one packet. */
bytes = sizeof(sendbuf);
status = pj_sock_sendto(ssock, sendbuf, &bytes, 0,
&addr, sizeof(addr));
if (status != PJ_SUCCESS) {
app_perror("sendto error", status);
return -200;
}
/* Now unregister and close socket. */
pj_ioqueue_unregister(key);
/* Poll ioqueue. */
#ifdef PJ_SYMBIAN
pj_symbianos_poll(-1, 1000);
#else
timeout.sec = 1; timeout.msec = 0;
pj_ioqueue_poll(ioqueue, &timeout);
#endif
/* Must NOT receive any packets after socket is closed! */
if (packet_cnt > 0) {
PJ_LOG(3,(THIS_FILE, "....errror: not expecting to receive packet "
"after socket has been closed"));
return -210;
}
/* Success */
pj_sock_close(ssock);
pj_ioqueue_destroy(ioqueue);
pj_pool_release(pool);
return 0;
}