update_call_counter(): indentation fixes and small simplifications

at the top of the function.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44750 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Luigi Rizzo 19 years ago
parent 06ef2c1907
commit ad63b4c7c1

@ -2910,7 +2910,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner)
static int update_call_counter(struct sip_pvt *fup, int event) static int update_call_counter(struct sip_pvt *fup, int event)
{ {
char name[256]; char name[256];
int *inuse, *call_limit, *inringing = NULL; int *inuse, *call_limit, *inringing;
int outgoing = ast_test_flag(&fup->flags[0], SIP_OUTGOING); int outgoing = ast_test_flag(&fup->flags[0], SIP_OUTGOING);
struct sip_user *u = NULL; struct sip_user *u = NULL;
struct sip_peer *p = NULL; struct sip_peer *p = NULL;
@ -2924,19 +2924,12 @@ static int update_call_counter(struct sip_pvt *fup, int event)
ast_copy_string(name, fup->username, sizeof(name)); ast_copy_string(name, fup->username, sizeof(name));
/* Check the list of users */ /* Check the list of users only for incoming calls */
if (!outgoing) /* Only check users for incoming calls */ if (!outgoing && (u = find_user(name, 1)) ) {
u = find_user(name, 1);
if (u) {
inuse = &u->inUse; inuse = &u->inUse;
call_limit = &u->call_limit; call_limit = &u->call_limit;
p = NULL; inringing = NULL;
} else { } else if ( (p = find_peer(fup->peername, NULL, 1) ) ) { /* Try to find peer */
/* Try to find peer */
if (!p)
p = find_peer(fup->peername, NULL, 1);
if (p) {
inuse = &p->inUse; inuse = &p->inUse;
call_limit = &p->call_limit; call_limit = &p->call_limit;
inringing = &p->inRinging; inringing = &p->inRinging;
@ -2946,7 +2939,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
ast_log(LOG_DEBUG, "%s is not a local device, no call limit\n", name); ast_log(LOG_DEBUG, "%s is not a local device, no call limit\n", name);
return 0; return 0;
} }
}
switch(event) { switch(event) {
/* incoming and outgoing affects the inUse counter */ /* incoming and outgoing affects the inUse counter */
case DEC_CALL_LIMIT: case DEC_CALL_LIMIT:
@ -2969,6 +2962,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit); ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
} }
break; break;
case INC_CALL_RINGING: case INC_CALL_RINGING:
case INC_CALL_LIMIT: case INC_CALL_LIMIT:
if (*call_limit > 0 ) { if (*call_limit > 0 ) {
@ -2994,6 +2988,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit); ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
} }
break; break;
case DEC_CALL_RINGING: case DEC_CALL_RINGING:
if (inringing) { if (inringing) {
if (ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) { if (ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
@ -3005,15 +3000,15 @@ static int update_call_counter(struct sip_pvt *fup, int event)
} }
} }
break; break;
default: default:
ast_log(LOG_ERROR, "update_call_counter(%s, %d) called with no event!\n", name, event); ast_log(LOG_ERROR, "update_call_counter(%s, %d) called with no event!\n", name, event);
} }
if (p) if (p) {
ast_device_state_changed("SIP/%s", p->name); ast_device_state_changed("SIP/%s", p->name);
if (u)
ASTOBJ_UNREF(u, sip_destroy_user);
else
ASTOBJ_UNREF(p, sip_destroy_peer); ASTOBJ_UNREF(p, sip_destroy_peer);
} else /* u must be set */
ASTOBJ_UNREF(u, sip_destroy_user);
return 0; return 0;
} }

Loading…
Cancel
Save