本文整理汇总了C++中counter_inc函数的典型用法代码示例。如果您正苦于以下问题:C++ counter_inc函数的具体用法?C++ counter_inc怎么用?C++ counter_inc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了counter_inc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: db_mysql_submit_query
/**
* \brief Send a SQL query to the server.
*
* Send a SQL query to the database server. This methods tries to reconnect
* to the server if the connection is gone and the auto_reconnect parameter is
* enabled. It also issues a mysql_ping before the query to connect again after
* a long waiting period because for some older mysql versions the auto reconnect
* don't work sufficient. If auto_reconnect is enabled and the server supports it,
* then the mysql_ping is probably not necessary, but its safer to do it in this
* cases too.
*
* \param _h handle for the db
* \param _s executed query
* \return zero on success, negative value on failure
*/
static int db_mysql_submit_query(const db1_con_t* _h, const str* _s)
{
time_t t;
int i, code;
if (!_h || !_s || !_s->s) {
LM_ERR("invalid parameter value\n");
return -1;
}
if (my_ping_interval) {
t = time(0);
if ((t - CON_TIMESTAMP(_h)) > my_ping_interval) {
for (i=0; i < (db_mysql_auto_reconnect ? 3 : 1); i++) {
if (mysql_ping(CON_CONNECTION(_h))) {
LM_INFO("driver error on ping: %s\n", mysql_error(CON_CONNECTION(_h)));
counter_inc(mysql_cnts_h.driver_err);
} else {
break;
}
}
}
/*
* We're doing later a query anyway that will reset the timout of the server,
* so it makes sense to set the timestamp value to the actual time in order
* to prevent unnecessary pings.
*/
CON_TIMESTAMP(_h) = t;
}
/* When a server connection is lost and a query is attempted, most of
* the time the query will return a CR_SERVER_LOST, then at the second
* attempt to execute it, the mysql lib will reconnect and succeed.
* However is a few cases, the first attempt returns CR_SERVER_GONE_ERROR
* the second CR_SERVER_LOST and only the third succeeds.
* Thus the 3 in the loop count. Increasing the loop count over this
* value shouldn't be needed, but it doesn't hurt either, since the loop
* will most of the time stop at the second or sometimes at the third
* iteration. In the case of CR_SERVER_GONE_ERROR and CR_SERVER_LOST the
* driver error counter is increased
*/
for (i=0; i < (db_mysql_auto_reconnect ? 3 : 1); i++) {
if (mysql_real_query(CON_CONNECTION(_h), _s->s, _s->len) == 0) {
return 0;
}
code = mysql_errno(CON_CONNECTION(_h));
if (code!=CR_SERVER_GONE_ERROR && code!=CR_SERVER_LOST
&& code!=CR_SSL_CONNECTION_ERROR && code!=CR_CONNECTION_ERROR
&& code!=CR_CONN_HOST_ERROR && code!=CR_SERVER_LOST_EXTENDED) {
break;
}
counter_inc(mysql_cnts_h.driver_err);
}
LM_ERR("driver error on query: %s (%d)\n", mysql_error(CON_CONNECTION(_h)),
mysql_errno(CON_CONNECTION(_h)));
return -2;
}
示例2: db_mysql_store_result
/**
* Retrieve a result set
* \param _h handle to the database
* \param _r result set that should be retrieved
* \return zero on success, negative value on failure
*/
static int db_mysql_store_result(const db1_con_t* _h, db1_res_t** _r)
{
int code;
if ((!_h) || (!_r)) {
LM_ERR("invalid parameter value\n");
return -1;
}
*_r = db_mysql_new_result();
if (*_r == 0) {
LM_ERR("no memory left\n");
return -2;
}
RES_RESULT(*_r) = mysql_store_result(CON_CONNECTION(_h));
if (!RES_RESULT(*_r)) {
if (mysql_field_count(CON_CONNECTION(_h)) == 0) {
(*_r)->col.n = 0;
(*_r)->n = 0;
goto done;
} else {
LM_ERR("driver error: %s\n", mysql_error(CON_CONNECTION(_h)));
code = mysql_errno(CON_CONNECTION(_h));
if (code == CR_SERVER_GONE_ERROR || code == CR_SERVER_LOST) {
counter_inc(mysql_cnts_h.driver_err);
}
db_mysql_free_result(_h, *_r);
*_r = 0;
return -3;
}
}
if (db_mysql_convert_result(_h, *_r) < 0) {
LM_ERR("error while converting result\n");
LM_DBG("freeing result set at %p\n", _r);
/* all mem on Kamailio API side is already freed by
* db_mysql_convert_result in case of error, but we also need
* to free the mem from the mysql lib side, internal pkg for it
* and *_r */
db_mysql_free_result(_h, *_r);
*_r = 0;
#if (MYSQL_VERSION_ID >= 40100)
while( mysql_more_results(CON_CONNECTION(_h)) && mysql_next_result(CON_CONNECTION(_h)) == 0 ) {
MYSQL_RES *res = mysql_store_result( CON_CONNECTION(_h) );
mysql_free_result(res);
}
#endif
return -4;
}
done:
#if (MYSQL_VERSION_ID >= 40100)
while( mysql_more_results(CON_CONNECTION(_h)) && mysql_next_result(CON_CONNECTION(_h)) == 0 ) {
MYSQL_RES *res = mysql_store_result( CON_CONNECTION(_h) );
mysql_free_result(res);
}
#endif
return 0;
}
示例3: cdp_trans_timer
/**
* Timer callback for checking the transaction status.
* @param now - time of call
* @param ptr - generic pointer, passed to the transactional callbacks
*/
int cdp_trans_timer(time_t now, void* ptr)
{
cdp_trans_t *x,*n;
lock_get(trans_list->lock);
x = trans_list->head;
while(x)
{
if (now>x->expires) {
counter_inc(cdp_cnts_h.timeout); //Transaction has timed out waiting for response
x->ans = 0;
if (x->cb) {
(x->cb)(1,*(x->ptr),0, (now - x->expires));
}
n = x->next;
if (x->prev) x->prev->next = x->next;
else trans_list->head = x->next;
if (x->next) x->next->prev = x->prev;
else trans_list->tail = x->prev;
if (x->auto_drop) cdp_free_trans(x);
x = n;
} else
x = x->next;
}
lock_release(trans_list->lock);
return 1;
}
示例4: rx_process_asr
/*
* Called upon receipt of an ASR. Terminates the user session and returns the ASA.
* Terminates the corresponding dialog
* @param request - the received request
* @returns 0 always because ASA will be generated by the State Machine
*
*/
AAAMessage* rx_process_asr(AAAMessage *request) {
AAASession* session;
unsigned int code = 0;
rx_authsessiondata_t* p_session_data = 0;
if (!request || !request->sessionId) return 0;
counter_inc(ims_qos_cnts_h.asrs);
session = cdpb.AAAGetAuthSession(request->sessionId->data);
if (!session) {
LM_DBG("received an ASR but the session is already deleted\n");
return 0;
}
code = rx_get_abort_cause(request);
LM_DBG("abort-cause code is %u\n", code);
LM_DBG("PCRF requested an ASR");
p_session_data = (rx_authsessiondata_t*) session->u.auth.generic_data;
if (p_session_data->subscribed_to_signaling_path_status) {
LM_DBG("This is a subscription to signalling status\n");
} else {
LM_DBG("This is a normal media bearer - bearer is releaed by CDP callbacks\n");
}
cdpb.AAASessionsUnlock(session->hash);
return 0;
}
示例5: cop421_execute
unsigned int cop421_execute(unsigned int cycles)
{
unsigned int completed_cycles;
for (completed_cycles = 0; completed_cycles < cycles; completed_cycles++)
{
// Store current instruction
cur_inst = coprom[PC];
inst_pc = PC;
// Do preinstruction stuff
preinst();
pc_inc();
if (!g_skip)
{
if (cur_inst == 0x23 || cur_inst == 0x33 || (cur_inst >= 0x60 && cur_inst <= 0x63) || (cur_inst >= 0x68 && cur_inst <= 0x6b))
{
cur_operand = coprom[PC];
pc_inc();
execute_two_byte();
// TODO: two byte instructions take two clocks?
completed_cycles++;
counter_inc();
counter_inc();
}
else // If its one byte
{
counter_inc();
execute_one_byte();
}
}
else
{
g_skip = 0;
if (cur_inst == 0x23 || cur_inst == 0x33 || (cur_inst >= 0x60 && cur_inst <= 0x63) || (cur_inst >= 0x68 && cur_inst <= 0x6b))
{
pc_inc();
}
completed_cycles--; // TODO: a skipped instruction doesn't take a clock cycle?
}
}
return completed_cycles;
}
示例6: dlg_ontimeout
/*!
* \brief Timer function that removes expired dialogs, run timeout route
* \param tl dialog timer list
*/
void dlg_ontimeout(struct dlg_tl *tl) {
struct dlg_cell *dlg;
int new_state, old_state, unref;
struct sip_msg *fmsg;
/* get the dialog tl payload */
dlg = ((struct dlg_cell*) ((char *) (tl) -
(unsigned long) (&((struct dlg_cell*) 0)->tl)));
if (dlg->toroute > 0 && dlg->toroute < main_rt.entries
&& main_rt.rlist[dlg->toroute] != NULL) {
fmsg = faked_msg_next();
if (exec_pre_script_cb(fmsg, REQUEST_CB_TYPE) > 0) {
dlg_set_ctx_dialog(dlg);
LM_DBG("executing route %d on timeout\n", dlg->toroute);
set_route_type(REQUEST_ROUTE);
run_top_route(main_rt.rlist[dlg->toroute], fmsg, 0);
dlg_set_ctx_dialog(0);
exec_post_script_cb(fmsg, REQUEST_CB_TYPE);
}
}
if (dlg->state == DLG_STATE_CONFIRMED) {
dlg_bye_all(dlg, NULL);
unref_dlg(dlg, 1);
return;
}
next_state_dlg(dlg, DLG_EVENT_REQBYE, &old_state, &new_state, &unref, 0);
if (new_state == DLG_STATE_DELETED && old_state != DLG_STATE_DELETED) {
LM_WARN("timeout for dlg with CallID '%.*s' and tags '%.*s'\n",
dlg->callid.len, dlg->callid.s,
dlg->from_tag.len, dlg->from_tag.s);
/* dialog timeout */
run_dlg_callbacks(DLGCB_EXPIRED, dlg, NULL, NULL, DLG_DIR_NONE, 0);
unref_dlg(dlg, unref + 1);
counter_add(dialog_ng_cnts_h.active, -1);
counter_inc(dialog_ng_cnts_h.expired);
counter_inc(dialog_ng_cnts_h.processed);
} else {
unref_dlg(dlg, 1);
}
return;
}
示例7: cnt_inc_f
static int cnt_inc_f(struct sip_msg* msg, char* handle, char* bar)
{
counter_handle_t h;
h.id = (long)(void*)handle;
counter_inc(h);
return 1;
}
示例8: ki_cnt_inc
static int ki_cnt_inc(sip_msg_t* msg, str *sname)
{
char* name;
char* grp;
char* p;
counter_handle_t h;
cnt_op_handle_get();
counter_inc(h);
return 1;
}
示例9: thread_wakeup_safe
//the "policy" here isn't strictly necessary (one can sleep when preemption is
//disabled), but _maybe_ this is what an API user might expect
void thread_wakeup_safe(Thread* thread, void* object)
{
#ifdef COLLECT_HEAVY_THREAD_STATISTICS
//we count at this point, because all other functions are too fuzzy
//xxx only meaningful if not executed from an IRQ handler!
counter_inc(&g_current_thread->wakeup_counter);
#endif
if (preemption_is_disabled())
thread_wakeup_delayed(thread, object);
else
thread_wakeup_undelayed(thread, object);
}
示例10: subs_slot_add
/*!
* \brief Add an element to an slot's linked list
* \param _s hash slot
* \param _r added record
*/
void subs_slot_add(hslot_sp_t* _s, struct ims_subscription_s* _r)
{
if (_s->n == 0) {
_s->first = _s->last = _r;
} else {
_r->prev = _s->last;
_s->last->next = _r;
_s->last = _r;
}
_s->n++;
counter_inc(ul_scscf_cnts_h.active_subscriptions);
_r->slot = _s;
}
示例11: resume_on_termination_ccr
static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *cca, long elapsed_msecs) {
Ro_CCA_t *ro_cca_data = NULL;
if (is_timeout) {
counter_inc(ims_charging_cnts_h.ccr_timeouts);
LM_ERR("Transaction timeout - did not get CCA\n");
goto error;
}
counter_inc(ims_charging_cnts_h.ccr_replies_received);
counter_add(ims_charging_cnts_h.ccr_response_time, elapsed_msecs);
if (!cca) {
LM_ERR("Error in termination CCR.\n");
return;
}
ro_cca_data = Ro_parse_CCA_avps(cca);
if (ro_cca_data == NULL) {
LM_DBG("Could not parse CCA message response.\n");
return;
}
if (ro_cca_data->resultcode != 2001) {
LM_ERR("Got bad CCA result code for STOP record - [%d]\n", ro_cca_data->resultcode);
goto error;
} else {
LM_DBG("Valid CCA response for STOP record\n");
}
counter_inc(ims_charging_cnts_h.successful_final_ccrs);
error:
Ro_free_CCA(ro_cca_data);
if (!is_timeout && cca) {
cdpb.AAAFreeMessage(&cca);
}
}
示例12: thread_sleep
//set the current thread to sleep
//must respect the current preemption disable state (no windows!)
void thread_sleep(void* object)
{
#ifdef COLLECT_HEAVY_THREAD_STATISTICS
counter_inc(&g_current_thread->sleep_counter);
#endif
//preemption must be disabled
//else there'll be a race condition in the _sleep/_wakeup mechanism
assert(preemption_is_disabled());
g_current_thread->state = THREAD_STATE_BLOCKED;
g_current_thread->block_object = object;
reschedule();
}
示例13: _sip_resolvehost
/* resolves a host name trying:
* - NAPTR lookup if enabled, the address is not an ip and *proto==0 and
* *port==0. The result of the NAPTR query will be used for a SRV lookup
* - SRV lookup if the address is not an ip *port==0. The result of the SRV
* query will be used for an A/AAAA lookup.
* - normal A/AAAA lookup (either fallback from the above or if *port!=0
* and *proto!=0 or port==0 && proto==0)
* when performing SRV lookup (*port==0) it will use *proto to look for
* tcp or udp hosts, otherwise proto is unused; if proto==0 => no SRV lookup
*
* returns: hostent struct & *port filled with the port from the SRV record;
* 0 on error
*/
struct hostent* _sip_resolvehost(str* name, unsigned short* port, char* proto)
{
struct hostent* res = NULL;
#ifdef USE_NAPTR
if (cfg_get(core, core_cfg, dns_try_naptr))
res = naptr_sip_resolvehost(name, port, proto);
else
#endif
res = srv_sip_resolvehost(name, 0, port, proto, 0, 0);
if( unlikely(!res) ){
/* failed DNS request */
counter_inc(dns_cnts_h.failed_dns_req);
}
return res;
}
示例14: mem_insert_impurecord
/*!
* \brief Insert a new record into domain in memory
* \param _d domain the record belongs to
* \param _aor address of record
* \param _r new created record
* \return 0 on success, -1 on failure
*/
int mem_insert_impurecord(struct udomain* _d, str* public_identity, str* private_identity, int reg_state, int barring,
ims_subscription** s, str* ccf1, str* ccf2, str* ecf1, str* ecf2,
struct impurecord** _r) {
int sl;
if (new_impurecord(_d->name, public_identity, private_identity, reg_state, barring, s, ccf1, ccf2, ecf1,
ecf2, _r) < 0) {
LM_ERR("creating impurecord failed\n");
return -1;
}
sl = ((*_r)->aorhash) & (_d->size - 1);
slot_add(&_d->table[sl], *_r);
counter_inc(ul_scscf_cnts_h.active_impus);
LM_DBG("inserted new impurecord into memory [%.*s]\n", (*_r)->public_identity.len, (*_r)->public_identity.s);
return 0;
}
示例15: mem_insert_scontact
/*!
* \brief Add a new contact in memory
*
* Add a new contact in memory, contacts are ordered by:
* 1) q value, 2) descending modification time
* \param _r record this contact belongs to
* \param _c contact
* \param _ci contact information
* \return pointer to new created contact on success, 0 on failure
*/
ucontact_t* mem_insert_scontact(impurecord_t* _r, str* _c, ucontact_info_t* _ci) {
ucontact_t* c;
int sl;
if ((c = new_ucontact(_r->domain, &_r->public_identity, _c, _ci)) == 0) {
LM_ERR("failed to create new contact\n");
return 0;
}
counter_inc(ul_scscf_cnts_h.active_contacts);
LM_DBG("Created new contact in memory with AOR: [%.*s] and hash [%d]\n", _c->len, _c->s, c->sl);
sl = (c->sl);
lock_contact_slot_i(sl);
contact_slot_add(&contact_list->slot[sl], c);
unlock_contact_slot_i(sl);
return c;
}