Deleted Added
full compact
32c32
< __FBSDID("$FreeBSD: stable/10/usr.sbin/ctld/ctld.c 279006 2015-02-19 14:52:01Z mav $");
---
> __FBSDID("$FreeBSD: stable/10/usr.sbin/ctld/ctld.c 279055 2015-02-20 17:09:49Z mav $");
95a96
> TAILQ_INIT(&conf->conf_pports);
113a115
> struct pport *pp, *pptmp;
125a128,129
> TAILQ_FOREACH_SAFE(pp, &conf->conf_pports, pp_next, pptmp)
> pport_delete(pp);
1135a1140,1188
> struct pport *
> pport_new(struct conf *conf, const char *name, uint32_t ctl_port)
> {
> struct pport *pp;
>
> pp = calloc(1, sizeof(*pp));
> if (pp == NULL)
> log_err(1, "calloc");
> pp->pp_conf = conf;
> pp->pp_name = checked_strdup(name);
> pp->pp_ctl_port = ctl_port;
> TAILQ_INIT(&pp->pp_ports);
> TAILQ_INSERT_TAIL(&conf->conf_pports, pp, pp_next);
> return (pp);
> }
>
> struct pport *
> pport_find(const struct conf *conf, const char *name)
> {
> struct pport *pp;
>
> TAILQ_FOREACH(pp, &conf->conf_pports, pp_next) {
> if (strcasecmp(pp->pp_name, name) == 0)
> return (pp);
> }
> return (NULL);
> }
>
> struct pport *
> pport_copy(struct pport *pp, struct conf *conf)
> {
> struct pport *ppnew;
>
> ppnew = pport_new(conf, pp->pp_name, pp->pp_ctl_port);
> return (ppnew);
> }
>
> void
> pport_delete(struct pport *pp)
> {
> struct port *port, *tport;
>
> TAILQ_FOREACH_SAFE(port, &pp->pp_ports, p_ts, tport)
> port_delete(port);
> TAILQ_REMOVE(&pp->pp_conf->conf_pports, pp, pp_next);
> free(pp->pp_name);
> free(pp);
> }
>
1139a1193
> char *name;
1140a1195,1200
> asprintf(&name, "%s-%s", pg->pg_name, target->t_name);
> if (port_find(conf, name) != NULL) {
> log_warnx("duplicate port \"%s\"", name);
> free(name);
> return (NULL);
> }
1144,1149d1203
< asprintf(&port->p_name, "%s-%s", pg->pg_name, target->t_name);
< if (port_find(conf, port->p_name) != NULL) {
< log_warnx("duplicate port \"%s\"", port->p_name);
< free(port);
< return (NULL);
< }
1150a1205
> port->p_name = name;
1159a1215,1239
> port_new_pp(struct conf *conf, struct target *target, struct pport *pp)
> {
> struct port *port;
> char *name;
>
> asprintf(&name, "%s-%s", pp->pp_name, target->t_name);
> if (port_find(conf, name) != NULL) {
> log_warnx("duplicate port \"%s\"", name);
> free(name);
> return (NULL);
> }
> port = calloc(1, sizeof(*port));
> if (port == NULL)
> log_err(1, "calloc");
> port->p_conf = conf;
> port->p_name = name;
> TAILQ_INSERT_TAIL(&conf->conf_ports, port, p_next);
> TAILQ_INSERT_TAIL(&target->t_ports, port, p_ts);
> port->p_target = target;
> TAILQ_INSERT_TAIL(&pp->pp_ports, port, p_pps);
> port->p_pport = pp;
> return (port);
> }
>
> struct port *
1190a1271,1272
> if (port->p_pport)
> TAILQ_REMOVE(&port->p_pport->pp_ports, port, p_pps);
1763a1846
> log_debugx("removing port \"%s\"", oldport->p_name);
1887a1971
> log_debugx("adding port \"%s\"", newport->p_name);
1889a1974
> log_debugx("updating port \"%s\"", newport->p_name);
2401c2486
< newconf = conf_new_from_file(config_path);
---
> newconf = conf_new_from_file(config_path, oldconf);
2436c2521
< tmpconf = conf_new_from_file(config_path);
---
> tmpconf = conf_new_from_file(config_path, newconf);