On 3/13/2015 9:48 AM, Harald Becker wrote:
On 13.03.2015 12:29, Michael Conrad wrote:
On 3/13/2015 3:25 AM, Harald Becker wrote:
1 - kernel-spawned hotplug helpers is the traditional way,
2 - netlink socket daemon is the "right way to solve the forkbomb
problem"
ACK, but #2 blocks usage for those who like / need to stay at #1 / #0
In that case, I would offer this idea:
All you do, is throwing in complex code sharing and the need to chose
a mechanism ahead at build time, to allow for switching to some newer
stuff ... but what about pre-generated binary versions, which
mechanism shall be used in the default options, which mechanism shall
be offered?
Please review it again. My solution solves both #1 and #2 in the same
binary, with no code duplication.
At first complex code reusage, and then: How will you do it without
suffering from hotplug handler problem as current mdev? I'm don't
seeing, that you try to handle this problem. My solution is to enable
kernel hotplug handler mechanism to also benefit and avoid that
parallel parsing for each event.
... beside that, this close / open_netlink look suspicious, looks like
possible race condition.
I thought pseudocode would be clearer than English text, but I suppose
my pseudocode is still really just English... Maybe some comments will
help.
The new code would not be run like a hotplug helper, it would be run as
a daemon, probably from a supervisor. But the old code is still there
and can still be run as a hotplug helper.
mdev_main() {
read_options();
load_config();
// if user requests "--netlink" mode, we act like a daemon
if (option_netlink) {
// If "--netlink-on-stdin" then netlink is open for us already
// if not, then we need to create our netlink socket
if (!option_netlink_on_stdin) {
close(0); // the new socket will now be file descriptor 0
open_netlink_socket();
}
// use 'select()' to see if a new netlink message is ready.
// if the user gave us a "--timeout" then we exit if no new
// netlink message in a certain amount of time
while (select([0], timeout)) {
if (recv(0, message)) {
// Netlink message is a list of variables. We call 'setenv'
for each.
apply_env_from_message(message);
// Now we have all the hotplug variables. So call the old code.
process_request();
}
// keep running in a loop until timeout (or forever if no timeout)
}
}
else
#endif
process_request();
}
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox