Don't fork off subprocesses to send to ifchd. Totally unnecessary.

This commit is contained in:
Nicholas J. Kain 2010-11-12 19:04:51 -05:00
parent c4f912a525
commit 31d15af0fa

View File

@ -182,7 +182,6 @@ static void deconfig_if(void)
sockwrite(sockfd, buf, strlen(buf)); sockwrite(sockfd, buf, strlen(buf));
close(sockfd); close(sockfd);
exit(EXIT_SUCCESS);
} }
static void translate_option(int sockfd, struct dhcpMessage *packet, int opt) static void translate_option(int sockfd, struct dhcpMessage *packet, int opt)
@ -240,36 +239,26 @@ static void bound_if(struct dhcpMessage *packet)
translate_option(sockfd, packet, 17); translate_option(sockfd, packet, 17);
close(sockfd); close(sockfd);
exit(EXIT_SUCCESS);
} }
void run_script(struct dhcpMessage *packet, int mode) void run_script(struct dhcpMessage *packet, int mode)
{ {
int pid; switch (mode) {
case SCRIPT_DECONFIG:
pid = fork(); deconfig_if();
if (pid) { break;
waitpid(pid, NULL, 0); case SCRIPT_BOUND:
return; bound_if(packet);
} else if (pid == 0) { break;
switch (mode) { case SCRIPT_RENEW:
case SCRIPT_DECONFIG: bound_if(packet);
deconfig_if(); break;
break; case SCRIPT_NAK:
case SCRIPT_BOUND: deconfig_if();
bound_if(packet); break;
break; default:
case SCRIPT_RENEW: log_error("invalid script mode: %d", mode);
bound_if(packet); break;
break;
case SCRIPT_NAK:
deconfig_if();
break;
default:
break;
}
log_error("invalid script mode: %d", mode);
exit(EXIT_FAILURE);
} }
} }