Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/isdn/isdnd Add some error handling for an ioctl - t...



details:   https://anonhg.NetBSD.org/src/rev/70f60ef9ec97
branches:  trunk
changeset: 547099:70f60ef9ec97
user:      martin <martin%NetBSD.org@localhost>
date:      Tue May 13 07:07:37 2003 +0000

description:
Add some error handling for an ioctl - the old code could loop tightly if
the peer closed a socket unexpectedly.
This addresses one of the issues Frank Kardel patched (differently) in
PR kern/21448, after clarification from Frank via private mail.

diffstat:

 usr.sbin/isdn/isdnd/monitor.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r abe513f2fefe -r 70f60ef9ec97 usr.sbin/isdn/isdnd/monitor.c
--- a/usr.sbin/isdn/isdnd/monitor.c     Tue May 13 06:51:10 2003 +0000
+++ b/usr.sbin/isdn/isdnd/monitor.c     Tue May 13 07:07:37 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: monitor.c,v 1.8 2003/05/08 08:35:40 martin Exp $ */
+/* $NetBSD: monitor.c,v 1.9 2003/05/13 07:07:37 martin Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -833,16 +833,20 @@
        };
 #define        NUMCMD  (sizeof cmd_tab / sizeof cmd_tab[0])
 
-       int avail, bytes;
+       int avail, bytes, err;
 
        /* Network transfer may deliver two or more packets concatenated.
         * Peek at the header and read only one event at a time... */
 
-       ioctl(fd, FIONREAD, &avail);
+       avail = 0;
+       err = ioctl(fd, FIONREAD, &avail);
 
-       if (avail < I4B_MON_CMD_HDR)
+       if (err == -1 || avail < I4B_MON_CMD_HDR)
        {
-               if (avail == 0)
+               if (err == -1 && errno == EINTR)
+                       return 0;       /* try again later */
+
+               if (err == -1 || avail == 0)
                {
                        /* logit(LL_MER, "monitor read 0 bytes"); */
                        /* socket closed by peer */



Home | Main Index | Thread Index | Old Index