Skip to content

Commit

Permalink
usrloc: coherent indentation and whitespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Jul 29, 2019
1 parent 5d303af commit 12bf3cb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
39 changes: 19 additions & 20 deletions src/modules/usrloc/udomain.c
Expand Up @@ -83,7 +83,7 @@ int new_udomain(str* _n, int _s, udomain_t** _d)
#ifdef STATISTICS
char *name;
#endif

/* Must be always in shared memory, since
* the cache is accessed from timer which
* lives in a separate process
Expand Down Expand Up @@ -150,7 +150,7 @@ int new_udomain(str* _n, int _s, udomain_t** _d)
void free_udomain(udomain_t* _d)
{
int i;

if (_d->table) {
for(i = 0; i < _d->size; i++) {
deinit_slot(_d->table + i);
Expand Down Expand Up @@ -215,7 +215,7 @@ void print_udomain(FILE* _f, udomain_t* _d)
/*!
* \brief Convert database values into ucontact_info
*
* Convert database values into ucontact_info,
* Convert database values into ucontact_info,
* expects 12 rows (contact, expirs, q, callid, cseq, flags,
* ua, received, path, socket, methods, last_modified)
* \param vals database values
Expand Down Expand Up @@ -294,7 +294,7 @@ static inline ucontact_info_t* dbrow2info(db_val_t *vals, str *contact, int rcon
received.len = strlen(received.s);
}
ci.received = received;

path.s = (char*)VAL_STRING(vals+9);
if (VAL_NULL(vals+9) || !path.s || !path.s[0]) {
path.len = 0;
Expand All @@ -309,7 +309,7 @@ static inline ucontact_info_t* dbrow2info(db_val_t *vals, str *contact, int rcon
if (VAL_NULL(vals+10) || p==0 || p[0]==0){
ci.sock = 0;
} else {
if (parse_phostport( p, &host.s, &host.len,
if (parse_phostport( p, &host.s, &host.len,
&port, &proto)!=0) {
LM_ERR("bad socket <%s>\n", p);
return 0;
Expand Down Expand Up @@ -509,7 +509,6 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
}
}


lock_udomain(_d, &user);
if (get_urecord(_d, &user, &r) > 0) {
if (mem_insert_urecord(_d, &user, &r) < 0) {
Expand Down Expand Up @@ -657,7 +656,7 @@ urecord_t* db_load_urecord(db1_con_t* _c, udomain_t* _d, str *_aor)
_aor->len, _aor->s, _d->name->s);
continue;
}

if ( r==0 )
get_static_urecord( _d, _aor, &r);

Expand Down Expand Up @@ -948,13 +947,13 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)
UL_DB_EXPIRES_SET(&query_vals[1], 0);

if (ul_db_srvid != 0) {
query_cols[2] = &srv_id_col;
query_ops[2] = OP_EQ;
query_vals[2].type = DB1_INT;
query_vals[2].nul = 0;
query_vals[2].val.int_val = server_id;
key_num = 3;
}
query_cols[2] = &srv_id_col;
query_ops[2] = OP_EQ;
query_vals[2].type = DB1_INT;
query_vals[2].nul = 0;
query_vals[2].val.int_val = server_id;
key_num = 3;
}

if (ul_dbf.use_table(_c, _d->name) < 0) {
LM_ERR("sql use_table failed\n");
Expand Down Expand Up @@ -985,8 +984,8 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)

if (RES_ROW_N(res) == 0) {
LM_DBG("no rows to be contact expired\n");
ul_dbf.free_result(_c, res);
return 0;
ul_dbf.free_result(_c, res);
return 0;
}

n = 0;
Expand Down Expand Up @@ -1059,7 +1058,7 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)


/*!
* \brief Timer function to cleanup expired contacts, db_mode: DB_ONLY
* \brief Timer function to cleanup expired contacts, db_mode: DB_ONLY
* and for WRITE_BACK, WRITE_THROUGH on config param
* \param _d cleaned domain
* \return 0 on success, -1 on failure
Expand Down Expand Up @@ -1097,7 +1096,7 @@ int db_timer_udomain(udomain_t* _d)
LM_ERR("use_table failed\n");
return -1;
}

if (ul_dbf.delete(ul_dbh, keys, ops, vals, key_num) < 0) {
LM_ERR("failed to delete from table %s\n",_d->name->s);
return -1;
Expand Down Expand Up @@ -1131,7 +1130,7 @@ int testdb_udomain(db1_con_t* con, udomain_t* d)
VAL_TYPE(val) = DB1_STRING;
VAL_NULL(val) = 0;
VAL_STRING(val) = "dummy_user";

VAL_TYPE(val+1) = DB1_STRING;
VAL_NULL(val+1) = 0;
VAL_STRING(val+1) = "dummy_domain";
Expand All @@ -1157,7 +1156,7 @@ int testdb_udomain(db1_con_t* con, udomain_t* d)
int mem_insert_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
{
int sl;

if (new_urecord(_d->name, _aor, _r) < 0) {
LM_ERR("creating urecord failed\n");
return -1;
Expand Down
51 changes: 25 additions & 26 deletions src/modules/usrloc/urecord.c
Expand Up @@ -94,7 +94,7 @@ void free_urecord(urecord_t* _r)
_r->contacts = _r->contacts->next;
free_ucontact(ptr);
}

/* if mem cache is not used, the urecord struct is static*/
if (db_mode!=DB_ONLY) {
if (_r->aor.s) shm_free(_r->aor.s);
Expand All @@ -117,7 +117,7 @@ void print_urecord(FILE* _f, urecord_t* _r)
fprintf(_f, "aor : '%.*s'\n", _r->aor.len, ZSW(_r->aor.s));
fprintf(_f, "aorhash: '%u'\n", (unsigned)_r->aorhash);
fprintf(_f, "slot: '%d'\n", _r->aorhash&(_r->slot->d->size-1));

if (_r->contacts) {
ptr = _r->contacts;
while(ptr) {
Expand Down Expand Up @@ -201,7 +201,7 @@ void mem_remove_ucontact(urecord_t* _r, ucontact_t* _c)
_c->next->prev = 0;
}
}
}
}


/*!
Expand Down Expand Up @@ -534,7 +534,7 @@ int db_delete_urecord_by_ruid(str *_table, str *_ruid)
}

if (ul_dbf.affected_rows(ul_dbh) == 0) {
return -2;
return -2;
}

return 0;
Expand Down Expand Up @@ -653,12 +653,12 @@ int delete_ucontact(urecord_t* _r, struct ucontact* _c)

int delete_urecord_by_ruid(udomain_t* _d, str *_ruid)
{
if (db_mode != DB_ONLY) {
LM_ERR("delete_urecord_by_ruid currently available only in db_mode=3\n");
return -1;
}
if (db_mode != DB_ONLY) {
LM_ERR("delete_urecord_by_ruid currently available only in db_mode=3\n");
return -1;
}

return db_delete_urecord_by_ruid(_d->name, _ruid);
return db_delete_urecord_by_ruid(_d->name, _ruid);
}


Expand All @@ -674,7 +674,7 @@ static inline struct ucontact* contact_match( ucontact_t* ptr, str* _c)
if ((_c->len == ptr->c.len) && !memcmp(_c->s, ptr->c.s, _c->len)) {
return ptr;
}

ptr = ptr->next;
}
return 0;
Expand All @@ -698,30 +698,29 @@ static inline struct ucontact* contact_callid_match( ucontact_t* ptr,
) {
return ptr;
}

ptr = ptr->next;
}
return 0;
}

/*!
+ * \brief Match a contact record to a contact string and path
+ * \param ptr contact record
+ * \param _c contact string
+ * \param _path path
+ * \return ptr on successfull match, 0 when they not match
+ */
/*!
* \brief Match a contact record to a contact string and path
* \param ptr contact record
* \param _c contact string
* \param _path path
* \return ptr on successfull match, 0 when they not match
*/
static inline struct ucontact* contact_path_match( ucontact_t* ptr, str* _c, str *_path)
{
/* if no path is preset (in REGISTER request) or use_path is not configured
in registrar module, default to contact_match() */
* in registrar module, default to contact_match() */
if( _path == NULL) return contact_match(ptr, _c);

while(ptr) {
if ( (_c->len==ptr->c.len) && (_path->len==ptr->path.len)
&& !memcmp(_c->s, ptr->c.s, _c->len)
&& !memcmp(_path->s, ptr->path.s, _path->len)
) {
&& !memcmp(_c->s, ptr->c.s, _c->len)
&& !memcmp(_path->s, ptr->path.s, _path->len) ) {
return ptr;
}

Expand All @@ -744,7 +743,7 @@ static inline struct ucontact* contact_match_callidonly( ucontact_t* ptr, str* _
if ((_callid->len == ptr->callid.len) && !memcmp(_callid->s, ptr->callid.s, _callid->len)) {
return ptr;
}

ptr = ptr->next;
}
return 0;
Expand All @@ -759,7 +758,7 @@ static inline struct ucontact* contact_match_callidonly( ucontact_t* ptr, str* _
* \param _path path
* \param _cseq CSEQ number
* \param _co found contact
* \return 0 - found, 1 - not found, -1 - invalid found,
* \return 0 - found, 1 - not found, -1 - invalid found,
* -2 - found, but to be skipped (same cseq)
*/
int get_ucontact(urecord_t* _r, str* _c, str* _callid, str* _path, int _cseq,
Expand Down Expand Up @@ -818,7 +817,7 @@ int get_ucontact_by_instance(urecord_t* _r, str* _c, ucontact_info_t* _ci,
ucontact_t* ptr;
str i1;
str i2;

if (_ci->instance.s == NULL || _ci->instance.len <= 0) {
return get_ucontact(_r, _c, _ci->callid, _ci->path, _ci->cseq, _co);
}
Expand All @@ -843,7 +842,7 @@ int get_ucontact_by_instance(urecord_t* _r, str* _c, ucontact_info_t* _ci,
return 0;
}
}

ptr = ptr->next;
}
return 1;
Expand Down

0 comments on commit 12bf3cb

Please sign in to comment.