uid_avp_db: better error handling
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 07:31:00 +0000 (09:31 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 20 Jul 2017 07:31:49 +0000 (09:31 +0200)
src/modules/uid_avp_db/extra_attrs.c

index 888f84d..6a88655 100644 (file)
@@ -175,7 +175,8 @@ int declare_attr_group(modparam_t type, char* _param)
        } while (p);
        
        if ((!rt->id) || (!rt->flag_name)) {
-               ERR("at least attribute group ID and flags must ve given\n");
+               ERR("at least attribute group ID and flags must be given\n");
+               pkg_free(rt);
                return -1;
        }
        /* insert new element into registered tables */
@@ -449,6 +450,12 @@ int init_extra_avp_locks()
        int i;
        registered_table_t *t = tables;
 
+       if(register_script_cb(avpdb_post_script_cb,
+                       REQUEST_CB | ONREPLY_CB | POST_SCRIPT_CB, 0)<0) {
+               LM_ERR("failed to register script callbacks\n");
+               return -1;
+       }
+
        /* zero all 'lock counters' */
        memset(lock_counters, 0, sizeof(lock_counters));
 
@@ -468,8 +475,6 @@ int init_extra_avp_locks()
                t = t->next;
        }
 
-       register_script_cb(avpdb_post_script_cb, REQUEST_CB | ONREPLY_CB | POST_SCRIPT_CB, 0);
-
        return 0;
 }