Mercurial > hg > freeDiameter
comparison extensions/rt_rewrite/rt_rewrite.c @ 1547:44bb63ba9c2c
rt_rewrite: allocate object later to reduce cleanups
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Mon, 15 Jun 2020 20:33:35 +0200 |
parents | c8057892e56b |
children |
comparison
equal
deleted
inserted
replaced
1546:c48725959e63 | 1547:44bb63ba9c2c |
---|---|
395 if (pthread_rwlock_wrlock(&rt_rewrite_lock) != 0) { | 395 if (pthread_rwlock_wrlock(&rt_rewrite_lock) != 0) { |
396 fd_log_error("%s: locking failed, aborting message rewrite", MODULE_NAME); | 396 fd_log_error("%s: locking failed, aborting message rewrite", MODULE_NAME); |
397 return errno; | 397 return errno; |
398 } | 398 } |
399 | 399 |
400 if ((ret = fd_msg_parse_dict(*msg, fd_g_config->cnf_dict, NULL)) != 0) { | |
401 fd_log_notice("%s: error parsing message", MODULE_NAME); | |
402 pthread_rwlock_unlock(&rt_rewrite_lock); | |
403 return ret; | |
404 } | |
405 if ((ret=fd_msg_browse(*msg, MSG_BRW_FIRST_CHILD, &avp, NULL)) != 0) { | |
406 fd_log_notice("internal error: message has no child"); | |
407 pthread_rwlock_unlock(&rt_rewrite_lock); | |
408 return ret; | |
409 } | |
400 if ((store=store_new()) == NULL) { | 410 if ((store=store_new()) == NULL) { |
401 fd_log_error("%s: malloc failure"); | 411 fd_log_error("%s: malloc failure"); |
402 pthread_rwlock_unlock(&rt_rewrite_lock); | 412 pthread_rwlock_unlock(&rt_rewrite_lock); |
403 return ENOMEM; | 413 return ENOMEM; |
404 } | |
405 if ((ret = fd_msg_parse_dict(*msg, fd_g_config->cnf_dict, NULL)) != 0) { | |
406 fd_log_notice("%s: error parsing message", MODULE_NAME); | |
407 free(store); | |
408 pthread_rwlock_unlock(&rt_rewrite_lock); | |
409 return ret; | |
410 } | |
411 if ((ret=fd_msg_browse(*msg, MSG_BRW_FIRST_CHILD, &avp, NULL)) != 0) { | |
412 fd_log_notice("internal error: message has no child"); | |
413 free(store); | |
414 pthread_rwlock_unlock(&rt_rewrite_lock); | |
415 return ret; | |
416 } | 414 } |
417 if (replace_avps(*msg, avp, avp_match_start->children, store) != 0) { | 415 if (replace_avps(*msg, avp, avp_match_start->children, store) != 0) { |
418 fd_log_error("%s: replace AVP function failed", MODULE_NAME); | 416 fd_log_error("%s: replace AVP function failed", MODULE_NAME); |
419 store_free(store); | 417 store_free(store); |
420 pthread_rwlock_unlock(&rt_rewrite_lock); | 418 pthread_rwlock_unlock(&rt_rewrite_lock); |