OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | pppd: Close already open ppp descriptors |
2 | |||
3 | When using the kernel PPPoE driver in conjunction with the "persist" option, |
||
4 | the already open descriptor to /dev/ppp is not closed when the link is |
||
5 | reestablished. This eventually leads to high CPU load because the stray |
||
6 | descriptors are always reported as ready by select(). |
||
7 | |||
8 | This patch closes the descriptor if it is already open when establishing a |
||
9 | new connection. It originated from the Debian project. |
||
10 | |||
11 | Signed-off-by: Jo-Philipp Wich <jo@mein.io> |
||
12 | |||
13 | --- a/pppd/sys-linux.c |
||
14 | +++ b/pppd/sys-linux.c |
||
3 | office | 15 | @@ -458,6 +458,13 @@ int generic_establish_ppp (int fd) |
1 | office | 16 | if (new_style_driver) { |
17 | int flags; |
||
18 | |||
19 | + /* if a ppp_fd is already open, close it first */ |
||
20 | + if(ppp_fd > 0) { |
||
21 | + close(ppp_fd); |
||
22 | + remove_fd(ppp_fd); |
||
23 | + ppp_fd = -1; |
||
24 | + } |
||
25 | + |
||
26 | /* Open an instance of /dev/ppp and connect the channel to it */ |
||
27 | if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) { |
||
28 | error("Couldn't get channel number: %m"); |