change the interface to config_trial_assign()

svn:r2737
This commit is contained in:
Roger Dingledine 2004-11-09 07:55:48 +00:00
parent 2d18d9eefb
commit 3901473bf3
3 changed files with 6 additions and 8 deletions

View File

@ -681,10 +681,10 @@ config_assign(or_options_t *options, struct config_line_t *list, int reset)
* keys, -2 on bad values, -3 on bad transition. * keys, -2 on bad values, -3 on bad transition.
*/ */
int int
config_trial_assign(or_options_t **options, struct config_line_t *list, int reset) config_trial_assign(or_options_t *options, struct config_line_t *list, int reset)
{ {
int r; int r;
or_options_t *trial_options = options_dup(*options); or_options_t *trial_options = options_dup(options);
if ((r=config_assign(trial_options, list, reset)) < 0) { if ((r=config_assign(trial_options, list, reset)) < 0) {
options_free(trial_options); options_free(trial_options);
@ -696,12 +696,12 @@ config_trial_assign(or_options_t **options, struct config_line_t *list, int rese
return -2; return -2;
} }
if (options_transition_allowed(*options, trial_options) < 0) { if (options_transition_allowed(options, trial_options) < 0) {
options_free(trial_options); options_free(trial_options);
return -3; return -3;
} }
*options = trial_options; set_options(trial_options); /* we liked it. put it in place. */
return 0; return 0;
} }

View File

@ -202,7 +202,6 @@ handle_control_setconf(connection_t *conn, uint16_t len, char *body)
{ {
int r; int r;
struct config_line_t *lines=NULL; struct config_line_t *lines=NULL;
or_options_t *options = get_options();
if (config_get_lines(body, &lines) < 0) { if (config_get_lines(body, &lines) < 0) {
log_fn(LOG_WARN,"Controller gave us config lines we can't parse."); log_fn(LOG_WARN,"Controller gave us config lines we can't parse.");
@ -210,7 +209,7 @@ handle_control_setconf(connection_t *conn, uint16_t len, char *body)
return 0; return 0;
} }
if ((r=config_trial_assign(&options, lines, 1)) < 0) { if ((r=config_trial_assign(get_options(), lines, 1)) < 0) {
log_fn(LOG_WARN,"Controller gave us config lines that didn't validate."); log_fn(LOG_WARN,"Controller gave us config lines that didn't validate.");
if (r==-1) { if (r==-1) {
send_control_error(conn, ERR_UNRECOGNIZED_CONFIG_KEY, send_control_error(conn, ERR_UNRECOGNIZED_CONFIG_KEY,
@ -223,7 +222,6 @@ handle_control_setconf(connection_t *conn, uint16_t len, char *body)
} }
config_free_lines(lines); config_free_lines(lines);
set_options(options); /* put the new one into place */
if (options_act() < 0) { /* acting on them failed. die. */ if (options_act() < 0) { /* acting on them failed. die. */
log_fn(LOG_ERR,"Acting on config options left us in a broken state. Dying."); log_fn(LOG_ERR,"Acting on config options left us in a broken state. Dying.");
exit(1); exit(1);

View File

@ -1097,7 +1097,7 @@ int options_act(void);
int config_get_lines(char *string, struct config_line_t **result); int config_get_lines(char *string, struct config_line_t **result);
void config_free_lines(struct config_line_t *front); void config_free_lines(struct config_line_t *front);
int config_trial_assign(or_options_t **options, struct config_line_t *list, int reset); int config_trial_assign(or_options_t *options, struct config_line_t *list, int reset);
int resolve_my_address(const char *address, uint32_t *addr); int resolve_my_address(const char *address, uint32_t *addr);
void options_init(or_options_t *options); void options_init(or_options_t *options);
int init_from_config(int argc, char **argv); int init_from_config(int argc, char **argv);