summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordbj <dbj>1999-09-12 20:12:19 +0000
committerdbj <dbj>1999-09-12 20:12:19 +0000
commit87e73a4ec8dcf737f0b930686cd9277fe08f5155 (patch)
tree79ebd1d4c5a04d8105861e2c992a0f244add19a8
parent89a22df25729eed0c624de828911770497912b32 (diff)
downloadpkgsrc-87e73a4ec8dcf737f0b930686cd9277fe08f5155.tar.gz
added a select call so read doesn't fail with EWOULDBLOCK
assign to result of the read to an ssize_t instead of size_t
-rw-r--r--net/choparp/patches/patch-ac54
1 files changed, 54 insertions, 0 deletions
diff --git a/net/choparp/patches/patch-ac b/net/choparp/patches/patch-ac
new file mode 100644
index 00000000000..ae2aa5ff678
--- /dev/null
+++ b/net/choparp/patches/patch-ac
@@ -0,0 +1,54 @@
+$NetBSD: patch-ac,v 1.3 1999/09/12 20:12:19 dbj Exp $
+
+--- choparp.c.orig Tue Oct 7 05:29:46 1997
++++ choparp.c Sun Sep 12 15:58:41 1999
+@@ -24,6 +24,7 @@
+ #include <netinet/if_ether.h>
+ #include <sys/param.h>
+ #include <errno.h>
++#include <assert.h>
+
+ #define BPFFILENAME "/dev/bpf%d" /* bpf file template */
+ #ifndef NBPFILTER /* number of available bpf */
+@@ -217,20 +218,35 @@
+
+ void
+ loop(int fd, char *buf, size_t buflen){
+- size_t rlen;
++ ssize_t rlen;
+ char *p, *nextp;
+ size_t nextlen;
+ char *rframe;
+ size_t rframe_len;
+ char *sframe;
+ size_t sframe_len;
++ fd_set fdset;
++
++ FD_ZERO(&fdset);
++ FD_SET(fd,&fdset);
+
+ for(;;){
+- if ((rlen = read(fd, buf, buflen)) <= 0){
+- fprintf(stderr,"loop: read: %s\n", strerror(errno));
+- /* XXX: restart itself if daemon mode */
+- return;
+- }
++ int r;
++ r = select(fd+1,&fdset, 0, 0, 0);
++ if ((r < 0) && (errno == EINTR)) continue;
++ if (r < 0) {
++ perror("select");
++ return;
++ }
++ assert(r == 1);
++
++ rlen = read(fd, buf, buflen);
++ if ((rlen < 0) && (errno = EINTR)) continue;
++ if (rlen < 0) {
++ perror("loop: read");
++ return;
++ }
++
+ p = buf;
+ while((rframe = getarp(p, rlen, &nextp, &nextlen)) != NULL){
+ if (checkarp(rframe)){