aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/signalpipe.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-02-16 23:25:44 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-02-16 23:25:44 +0100
commit52a515d18724bbb34e3ccbbb0218efcc4eccc0a8 (patch)
tree16a5a05a328d7e0bd2b4b1bfbcaf543cf8a36d33 /networking/udhcp/signalpipe.c
parentdc207f669675a271812a21b0ddbe3b894adf8e4c (diff)
downloadbusybox-w32-52a515d18724bbb34e3ccbbb0218efcc4eccc0a8.tar.gz
busybox-w32-52a515d18724bbb34e3ccbbb0218efcc4eccc0a8.tar.bz2
busybox-w32-52a515d18724bbb34e3ccbbb0218efcc4eccc0a8.zip
udhcp: use poll() instead of select()
function old new delta udhcp_sp_read 65 46 -19 udhcp_sp_fd_set 79 54 -25 udhcpd_main 1530 1482 -48 udhcpc_main 2780 2730 -50 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-142) Total: -142 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/signalpipe.c')
-rw-r--r--networking/udhcp/signalpipe.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/networking/udhcp/signalpipe.c b/networking/udhcp/signalpipe.c
index 30bccd6bf..b101b4ce4 100644
--- a/networking/udhcp/signalpipe.c
+++ b/networking/udhcp/signalpipe.c
@@ -48,28 +48,29 @@ void FAST_FUNC udhcp_sp_setup(void)
48 , signal_handler); 48 , signal_handler);
49} 49}
50 50
51/* Quick little function to setup the rfds. Will return the 51/* Quick little function to setup the pfds.
52 * max_fd for use with select. Limited in that you can only pass 52 * Limited in that you can only pass one extra fd.
53 * one extra fd */ 53 */
54int FAST_FUNC udhcp_sp_fd_set(fd_set *rfds, int extra_fd) 54void FAST_FUNC udhcp_sp_fd_set(struct pollfd pfds[2], int extra_fd)
55{ 55{
56 FD_ZERO(rfds); 56 pfds[0].fd = signal_pipe.rd;
57 FD_SET(signal_pipe.rd, rfds); 57 pfds[0].events = POLLIN;
58 pfds[1].fd = -1;
58 if (extra_fd >= 0) { 59 if (extra_fd >= 0) {
59 close_on_exec_on(extra_fd); 60 close_on_exec_on(extra_fd);
60 FD_SET(extra_fd, rfds); 61 pfds[1].fd = extra_fd;
62 pfds[1].events = POLLIN;
61 } 63 }
62 return signal_pipe.rd > extra_fd ? signal_pipe.rd : extra_fd;
63} 64}
64 65
65/* Read a signal from the signal pipe. Returns 0 if there is 66/* Read a signal from the signal pipe. Returns 0 if there is
66 * no signal, -1 on error (and sets errno appropriately), and 67 * no signal, -1 on error (and sets errno appropriately), and
67 * your signal on success */ 68 * your signal on success */
68int FAST_FUNC udhcp_sp_read(const fd_set *rfds) 69int FAST_FUNC udhcp_sp_read(struct pollfd pfds[2])
69{ 70{
70 unsigned char sig; 71 unsigned char sig;
71 72
72 if (!FD_ISSET(signal_pipe.rd, rfds)) 73 if (!pfds[0].revents)
73 return 0; 74 return 0;
74 75
75 if (safe_read(signal_pipe.rd, &sig, 1) != 1) 76 if (safe_read(signal_pipe.rd, &sig, 1) != 1)