mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-31 22:28:08 +00:00
closes #5641
This commit is contained in:
parent
b6bd807186
commit
377e5a7368
@ -518,7 +518,7 @@ mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id)
|
|||||||
switch_thread_rwlock_rdlock(profile->contexts_rwlock);
|
switch_thread_rwlock_rdlock(profile->contexts_rwlock);
|
||||||
|
|
||||||
/* Context exists */
|
/* Context exists */
|
||||||
if (profile->contexts_bitmap[context_id % 8] & (1 << (context_id / 8))) {
|
if (profile->contexts_bitmap[context_id / 8] & (1 << (context_id % 8))) {
|
||||||
for (result = profile->contexts[context_id % MG_CONTEXT_MODULO]; result; result = result->next) {
|
for (result = profile->contexts[context_id % MG_CONTEXT_MODULO]; result; result = result->next) {
|
||||||
if (result->context_id == context_id) {
|
if (result->context_id == context_id) {
|
||||||
break;
|
break;
|
||||||
@ -544,10 +544,10 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile)
|
|||||||
|
|
||||||
/* Look for an available context */
|
/* Look for an available context */
|
||||||
for (; profile->next_context_id < MG_MAX_CONTEXTS; profile->next_context_id++) {
|
for (; profile->next_context_id < MG_MAX_CONTEXTS; profile->next_context_id++) {
|
||||||
if ((profile->contexts_bitmap[profile->next_context_id % 8] & (1 << (profile->next_context_id / 8))) == 0) {
|
if ((profile->contexts_bitmap[profile->next_context_id / 8] & (1 << (profile->next_context_id % 8))) == 0) {
|
||||||
/* Found! */
|
/* Found! */
|
||||||
int i = profile->next_context_id % MG_CONTEXT_MODULO;
|
int i = profile->next_context_id % MG_CONTEXT_MODULO;
|
||||||
profile->contexts_bitmap[profile->next_context_id % 8] |= 1 << (profile->next_context_id / 8);
|
profile->contexts_bitmap[profile->next_context_id / 8] |= 1 << (profile->next_context_id % 8);
|
||||||
ctx = malloc(sizeof *ctx);
|
ctx = malloc(sizeof *ctx);
|
||||||
memset(ctx, 0, sizeof *ctx);
|
memset(ctx, 0, sizeof *ctx);
|
||||||
ctx->context_id = profile->next_context_id;
|
ctx->context_id = profile->next_context_id;
|
||||||
@ -591,7 +591,7 @@ void megaco_release_context(mg_context_t *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profile->contexts_bitmap[context_id % 8] &= ~(1 << (context_id / 8));
|
profile->contexts_bitmap[context_id / 8] &= ~(1 << (context_id % 8));
|
||||||
|
|
||||||
memset(ctx, 0, sizeof *ctx);
|
memset(ctx, 0, sizeof *ctx);
|
||||||
free(ctx);
|
free(ctx);
|
||||||
@ -606,8 +606,8 @@ uint32_t mg_rtp_request_id(megaco_profile_t *profile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; profile->rtpid_next < MG_MAX_RTPID; profile->rtpid_next++) {
|
for (; profile->rtpid_next < MG_MAX_RTPID; profile->rtpid_next++) {
|
||||||
if ((profile->rtpid_bitmap[profile->rtpid_next % 8] & (1 << (profile->rtpid_next / 8))) == 0) {
|
if ((profile->rtpid_bitmap[profile->rtpid_next / 8] & (1 << (profile->rtpid_next % 8))) == 0) {
|
||||||
profile->rtpid_bitmap[profile->rtpid_next % 8] |= 1 << (profile->rtpid_next / 8);
|
profile->rtpid_bitmap[profile->rtpid_next / 8] |= 1 << (profile->rtpid_next % 8);
|
||||||
profile->rtpid_next++;
|
profile->rtpid_next++;
|
||||||
return profile->rtpid_next;
|
return profile->rtpid_next;
|
||||||
}
|
}
|
||||||
@ -618,7 +618,7 @@ uint32_t mg_rtp_request_id(megaco_profile_t *profile)
|
|||||||
|
|
||||||
void mg_rtp_release_id(megaco_profile_t *profile, uint32_t id)
|
void mg_rtp_release_id(megaco_profile_t *profile, uint32_t id)
|
||||||
{
|
{
|
||||||
profile->rtpid_bitmap[id % 8] &= ~(1 << (id / 8));
|
profile->rtpid_bitmap[id / 8] &= ~(1 << (id % 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_status_t megaco_profile_start(const char *profilename)
|
switch_status_t megaco_profile_start(const char *profilename)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user