]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We should test a specific fd instead of index 0 in a structure.
authorRoy Marples <roy@marples.name>
Sat, 7 Jun 2008 00:14:16 +0000 (00:14 +0000)
committerRoy Marples <roy@marples.name>
Sat, 7 Jun 2008 00:14:16 +0000 (00:14 +0000)
signals.c
signals.h

index 4559749caf255b397be43591b3321268ccd75d48..3d7f63cde22dc23e8cbd5fb6ce5bd567de1e55a9 100644 (file)
--- a/signals.c
+++ b/signals.c
@@ -73,9 +73,9 @@ signal_fd(void)
 
 /* Check if we have a signal or not */
 int
-signal_exists(const struct pollfd *fd)
+signal_exists(int fd)
 {
-       if (signals[0] || (fd && fd->revents & POLLIN))
+       if (signals[0] || fd_hasdata(fd) == 1)
                return 0;
        return -1;
 }
@@ -84,7 +84,7 @@ signal_exists(const struct pollfd *fd)
  * no signal, -1 on error (and sets errno appropriately), and
  * your signal on success */
 int
-signal_read(struct pollfd *fd)
+signal_read(int fd)
 {
        int sig = -1;
        unsigned int i = 0;
@@ -101,19 +101,12 @@ signal_read(struct pollfd *fd)
                }
        }
 
-       if (fd && fd->revents & POLLIN) {
+       if (fd_hasdata(fd) == 1) {
                memset(buf, 0, sizeof(buf));
                bytes = read(signal_pipe[0], buf, sizeof(buf));
-
                if (bytes >= sizeof(sig))
                        memcpy(&sig, buf, sizeof(sig));
-
-               /* We need to clear us from rset if nothing left in the buffer
-                * in case we are called many times */
-               if (bytes == sizeof(sig))
-                       fd->revents = 0;
        }
-
        return sig;
 }
 
index 948099d2a8557569900a7bad36f99f634882c858..5972b311987eb5ea2ece45cfe799e1832108642b 100644 (file)
--- a/signals.h
+++ b/signals.h
@@ -34,7 +34,7 @@ int signal_init(void);
 int signal_setup(void);
 int signal_reset(void);
 int signal_fd(void);
-int signal_exists(const struct pollfd *);
-int signal_read(struct pollfd *);
+int signal_exists(int fd);
+int signal_read(int fd);
 
 #endif