kv->key = strdup(Z_STRVAL_P(key));
if (!kv->key) {
+ free(kv);
return "fpm_conf_set_array: strdup(key) failed";
}
if (convert_to_bool) {
char *err = fpm_conf_set_boolean(value, &subconf, 0);
- if (err) return err;
+ if (err) {
+ free(kv->key);
+ free(kv);
+ return err;
+ }
kv->value = strdup(b ? "1" : "0");
} else {
kv->value = strdup(Z_STRVAL_P(value));
if (!kv->value) {
free(kv->key);
+ free(kv);
return "fpm_conf_set_array: strdup(value) failed";
}
wp->config = malloc(sizeof(struct fpm_worker_pool_config_s));
if (!wp->config) {
+ fpm_worker_pool_free(wp);
return 0;
}
if (len != write(fd, buf, len)) {
zlog(ZLOG_SYSERROR, "Unable to write to the PID file.");
+ close(fd);
return -1;
}
close(fd);
if (ini_recursion++ > 4) {
zlog(ZLOG_ERROR, "failed to include more than 5 files recusively");
+ close(fd);
return -1;
}
struct fpm_worker_pool_s *fpm_worker_all_pools;
+void fpm_worker_pool_free(struct fpm_worker_pool_s *wp) /* {{{ */
+{
+ if (wp->config) {
+ free(wp->config);
+ }
+ if (wp->user) {
+ free(wp->user);
+ }
+ if (wp->home) {
+ free(wp->home);
+ }
+ free(wp);
+}
+/* }}} */
+
static void fpm_worker_pool_cleanup(int which, void *arg) /* {{{ */
{
struct fpm_worker_pool_s *wp, *wp_next;
if ((which & FPM_CLEANUP_CHILD) == 0 && fpm_globals.parent_pid == getpid()) {
fpm_scoreboard_free(wp->scoreboard);
}
- free(wp->config);
- free(wp->user);
- free(wp->home);
- free(wp);
+ fpm_worker_pool_free(wp);
}
fpm_worker_all_pools = NULL;
}
};
struct fpm_worker_pool_s *fpm_worker_pool_alloc();
+void fpm_worker_pool_free(struct fpm_worker_pool_s *wp);
int fpm_worker_pool_init_main();
extern struct fpm_worker_pool_s *fpm_worker_all_pools;