static struct timeval lasttime;
#endif
-static int usecnt;
static int silencesuppression = 0;
static int silencethreshold = 1000;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
AST_MUTEX_DEFINE_STATIC(alsalock);
static const char tdesc[] = "ALSA Console Channel Driver";
c->tech_pvt = NULL;
alsa.owner = NULL;
ast_verbose(" << Hangup on console >> \n");
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
+ ast_module_unref(ast_module_info->self);
if (hookstate) {
hookstate = 0;
if (!autoanswer) {
if (!ast_strlen_zero(language))
ast_string_field_set(tmp, language, language);
p->owner = tmp;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
ast_jb_configure(tmp, &global_jbconf);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
static const char tdesc[] = "Feature Proxy Channel Driver";
-static int usecnt =0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
#define IS_OUTBOUND(a,b) (a == b->chan ? 1 : 0)
struct feature_sub {
p->subs[index].owner = tmp;
if (!p->owner)
p->owner = tmp;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
return tmp;
}
static const char desc[] = "Gtalk Channel";
-static int usecnt = 0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
AST_MUTEX_DEFINE_STATIC(gtalklock); /*!< Protect the interface list (of gtalk_pvt's) */
if (!ast_strlen_zero(client->musicclass))
ast_string_field_set(tmp, musicclass, client->musicclass);
i->owner = tmp;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
+ ast_module_ref(ast_module_info->self);
ast_copy_string(tmp->context, client->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
/* Don't use ast_set_callerid() here because it will
ast_mutex_unlock(&p->lock);
gtalk_free_pvt(client, p);
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
+ ast_module_unref(ast_module_info->self);
return 0;
}
static struct ast_netsock_list *netsock;
static int defaultsockfd = -1;
-static int usecnt = 0;
-
int (*iax2_regfunk)(const char *username, int onoff) = NULL;
/* Ethernet, etc */
c->tech_pvt = NULL;
ast_queue_hangup(c);
pvt->owner = NULL;
- ast_atomic_fetchadd_int(&usecnt, -1);
- ast_update_use_count();
+ ast_module_unref(ast_module_info->self);
}
return 0;
}
for (v = i->vars ; v ; v = v->next)
pbx_builtin_setvar_helper(tmp, v->name, v->value);
- ast_atomic_fetchadd_int(&usecnt, 1);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
return tmp;
}
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
-
-static int usecnt;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
static char *config = "oss.conf"; /* default config file */
static int oss_debug;
c->tech_pvt = NULL;
o->owner = NULL;
ast_verbose(" << Hangup on console >> \n");
- ast_mutex_lock(&usecnt_lock); /* XXX not sure why */
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
+ ast_module_unref(ast_module_info->self);
if (o->hookstate) {
if (o->autoanswer || o->autohangup) {
/* Assume auto-hangup too */
c->cid.cid_dnid = ast_strdup(ext);
o->owner = c;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
ast_jb_configure(c, &global_jbconf);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(c)) {
/* Default language */
static char language[MAX_LANGUAGE] = "";
-static int usecnt =0;
static int echocancel = AEC_OFF;
static int prefformat = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
/* Protect the interface list (of phone_pvt's) */
AST_MUTEX_DEFINE_STATIC(iflock);
p->dialtone = 0;
memset(p->ext, 0, sizeof(p->ext));
((struct phone_pvt *)(ast->tech_pvt))->owner = NULL;
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- if (usecnt < 0)
- ast_log(LOG_WARNING, "Usecnt < 0???\n");
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_unref(ast_module_info->self);
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
ast->tech_pvt = NULL;
tmp->cid.cid_name = ast_strdup(i->cid_name);
i->owner = tmp;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
if (state != AST_STATE_DOWN) {
if (state == AST_STATE_RING) {
ioctl(tmp->fds[0], PHONE_RINGBACK);
if (i->mode == MODE_IMMEDIATE) {
phone_new(i, AST_STATE_RING, i->context);
} else if (i->mode == MODE_DIALTONE) {
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
/* Reset the extension */
i->ext[0] = '\0';
/* Play the dialtone */
ioctl(i->fd, PHONE_PLAY_START);
i->lastformat = -1;
} else if (i->mode == MODE_SIGMA) {
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
/* Reset the extension */
i->ext[0] = '\0';
/* Play the dialtone */
ioctl(i->fd, PHONE_DIALTONE);
}
} else {
- if (i->dialtone) {
- ast_mutex_lock(&usecnt_lock);
- usecnt--;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
- }
+ if (i->dialtone)
+ ast_module_unref(ast_module_info->self);
memset(i->ext, 0, sizeof(i->ext));
if (i->cpt)
{
static const char config[] = "sip.conf";
static const char notify_config[] = "sip_notify.conf";
-static int usecnt = 0;
-
#define RTP 1
#define NO_RTP 0
p->owner = NULL;
ast->tech_pvt = NULL;
- ast_atomic_fetchadd_int(&usecnt, -1);
- ast_update_use_count();
+ ast_module_unref(ast_module_info->self);
/* Do not destroy this pvt until we have timeout or
get an answer to the BYE or INVITE/CANCEL
if (!ast_strlen_zero(i->language))
ast_string_field_set(tmp, language, i->language);
i->owner = tmp;
- ast_atomic_fetchadd_int(&usecnt, 1);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
static struct sched_context *sched;
static struct io_context *io;
-/* usage count and locking */
-static int usecnt = 0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
/* Protect the monitoring thread, so only one process can kill or start it, and not
when it's doing something critical. */
AST_MUTEX_DEFINE_STATIC(monlock);
if (l->amaflags)
tmp->amaflags = l->amaflags;
- ast_mutex_lock(&usecnt_lock);
- usecnt++;
- ast_mutex_unlock(&usecnt_lock);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
tmp->callgroup = l->callgroup;
tmp->pickupgroup = l->pickupgroup;
ast_string_field_set(tmp, call_forward, l->call_forward);
/*! \brief How long to wait for an extra digit, if there is an ambiguous match */
static int matchdigittimeout = 3000;
-static int usecnt = 0;
-
/*! \brief Protect the interface list (of zt_pvt's) */
AST_MUTEX_DEFINE_STATIC(iflock);
p->oprmode = 0;
ast->tech_pvt = NULL;
ast_mutex_unlock(&p->lock);
- ast_atomic_fetchadd_int(&usecnt, -1);
- ast_update_use_count();
+ ast_module_unref(ast_module_info->self);
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
}
}
- ast_atomic_fetchadd_int(&usecnt, 1);
- ast_update_use_count();
+ ast_module_ref(ast_module_info->self);
return tmp;
}