silc_server_config_ref(&server->config_ref, server->config, server->config);
/* Fix the server_name field */
- if (!strcmp(server->server_name, newconfig->server_info->server_name)) {
- /* We don't need any update */
- silc_free(newconfig->server_info->server_name);
- newconfig->server_info->server_name = NULL;
- } else {
+ if (strcmp(server->server_name, newconfig->server_info->server_name)) {
silc_free(server->server_name);
server->server_name = newconfig->server_info->server_name;
newconfig->server_info->server_name = NULL;
/* Set default to configuration parameters */
silc_server_config_set_defaults(config_new);
+ config_new->refcount = 1;
return config_new;
}
void silc_server_config_unref(SilcServerConfigRef *ref)
{
- SilcServerConfig config = ref->config;
-
- if (ref->ref_ptr) {
- config->refcount--;
- SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config,
- config->refcount + 1, config->refcount));
- if (!config->refcount)
- silc_server_config_destroy(config);
- ref->ref_ptr = NULL;
- }
+ if (ref->ref_ptr)
+ silc_server_config_destroy(ref->config);
}
/* Destroy a config object with all his children lists */
{
void *tmp;
+ config->refcount--;
+ SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config,
+ config->refcount + 1, config->refcount));
+ if (config->refcount > 0)
+ return;
+
SILC_LOG_DEBUG(("Freeing config context"));
silc_free(config->module_path);