* init module function */
| 96 | * init module function |
| 97 | */ |
| 98 | static int mod_init(void) |
| 99 | { |
| 100 | LM_NOTICE("initializing module example_cachedb ...\n"); |
| 101 | str key=str_init("opensips_online"); |
| 102 | str value=str_init("1"); |
| 103 | |
| 104 | cachedb_url.len = cachedb_url.s ? strlen(cachedb_url.s) : 0; |
| 105 | LM_DBG("cachedb_url=%s\n", ZSW(cachedb_url.s)); |
| 106 | |
| 107 | if(cachedb_url.s== NULL) |
| 108 | { |
| 109 | LM_ERR("URL not set!\n"); |
| 110 | return -1; |
| 111 | } |
| 112 | |
| 113 | LM_DBG("binding to specific module, based on URL\n"); |
| 114 | |
| 115 | if (cachedb_bind_mod(&cachedb_url,&cdbf) < 0) { |
| 116 | LM_ERR("failed to bind to mod\n"); |
| 117 | return -1; |
| 118 | } |
| 119 | |
| 120 | LM_DBG("initializing connection to back-end \n"); |
| 121 | con = cdbf.init(&cachedb_url); |
| 122 | if (con == NULL) { |
| 123 | LM_ERR("failed to connect to back-end\n"); |
| 124 | return -1; |
| 125 | } |
| 126 | |
| 127 | LM_DBG("Setting key opensips_online in back-end\n"); |
| 128 | if (cdbf.set(con,&key,&value,0) < 0) { |
| 129 | LM_ERR("failed to set key\n"); |
| 130 | return -1; |
| 131 | } |
| 132 | |
| 133 | LM_DBG("Destroying connection to back-end\n"); |
| 134 | cdbf.destroy(con); |
| 135 | |
| 136 | LM_INFO("successfully loaded cachedb_example module\n"); |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | static int child_init(int rank) |
| 141 | { |
nothing calls this directly
no test coverage detected