summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-02-10 23:01:44 +0000
committerRoy Marples <roy@marples.name>2008-02-10 23:01:44 +0000
commitb014ee76e17164890317b5a3d9ba070533560f41 (patch)
treea4f6ef1919422fede540469df58649714a2f01ec /socket.c
parentca1e79c0f854186ce84eb0526e9a29bbb0d0c084 (diff)
downloaddhcpcd-b014ee76e17164890317b5a3d9ba070533560f41.tar.xz
Replace select with poll and nanosleep.
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/socket.c b/socket.c
index 814d051b..8292705f 100644
--- a/socket.c
+++ b/socket.c
@@ -31,7 +31,6 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/param.h>
-#include <sys/select.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <net/if.h>
@@ -43,6 +42,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#ifdef BSD
@@ -375,12 +375,12 @@ ssize_t get_packet (const interface_t *iface, unsigned char *data,
*buffer_len = read (iface->fd, bpf.buffer, iface->buffer_length);
*buffer_pos = 0;
if (*buffer_len < 1) {
- struct timeval tv;
+ struct timespec tv;
logger (LOG_ERR, "read: %s", strerror (errno));
- tv.tv_sec = 3;
- tv.tv_usec = 0;
- select (0, NULL, NULL, NULL, &tv);
- return -1;
+ ts.tv_sec = 3;
+ ts.tv_nsec = 0;
+ nanosleep (&ts, NULL);
+ return (-1);
}
} else
bpf.buffer += *buffer_pos;
@@ -566,11 +566,11 @@ ssize_t get_packet (const interface_t *iface, unsigned char *data,
bytes = read (iface->fd, buffer, iface->buffer_length);
if (bytes == -1) {
- struct timeval tv;
+ struct timespec ts;
logger (LOG_ERR, "read: %s", strerror (errno));
- tv.tv_sec = 3;
- tv.tv_usec = 0;
- select (0, NULL, NULL, NULL, &tv);
+ ts.tv_sec = 3;
+ ts.tv_nsec = 0;
+ nanosleep (&ts, NULL);
return (-1);
}