@cryptotaxi247 / netdata-1 / commits / 05ab253ec

prevent deadlock when renaming config options when the old and new options are in the same section

Costa Tsaousis (ktsaou) committed Jun 17, 2017 at 22:24 UTC 05ab253ec055dcebb6763f6466e1b8089735f868
1 file changed +4 -2
src/appconfig.c
+4 -2
@@ -214,7 +214,8 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam
214 if(!co_new) co_new = appconfig_section_create(root, section_new);
215
216 config_section_wrlock(co_old);
217 - config_section_wrlock(co_new);
217 + if(co_old != co_new)
218 + config_section_wrlock(co_new);
219
220 cv_old = appconfig_option_index_find(co_old, name_old, 0);
221 if(!cv_old) goto cleanup;
@@ -251,7 +252,8 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam
252 ret = 0;
253
254 cleanup:
254 - config_section_unlock(co_new);
255 + if(co_old != co_new)
256 + config_section_unlock(co_new);
257 config_section_unlock(co_old);
258 return ret;
259 }