]> arthur.barton.de Git - netatalk.git/blobdiff - etc/papd/session.c
replaced all #include <sys/syslog.h> with #include <syslog.h>
[netatalk.git] / etc / papd / session.c
index 8065633688cfb2ad5bb73b29234b5f30dc914b41..ce8c5b915581b30f57353d732f066ad7577e40d6 100644 (file)
@@ -1,16 +1,25 @@
 /*
+ * $Id: session.c,v 1.12 2002-01-03 17:49:39 sibaz Exp $
+ *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif /* HAVE_SYS_ERRNO_H */
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif /* HAVE_ERRNO_H */
 
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
-#include <sys/syslog.h>
+#include <syslog.h>
 #include <sys/time.h>
 #include <sys/uio.h>
 #include <netatalk/endian.h>
@@ -86,7 +95,7 @@ int session( atp, sat )
     cbuf[ 1 ] = PAP_READ;
     if (++seq == 0) seq = 1;
     netseq = htons( seq );
-    bcopy( &netseq, &cbuf[ 2 ], sizeof( netseq ));
+    memcpy( &cbuf[ 2 ], &netseq, sizeof( netseq ));
     atpb.atp_saddr = sat;
     atpb.atp_sreqdata = cbuf;
     atpb.atp_sreqdlen = 4;             /* bytes in SendData request */
@@ -110,9 +119,14 @@ int session( atp, sat )
        FD_ZERO( &fds );
        FD_SET( atp_fileno( atp ), &fds );
 
-       if (( cc = select( FD_SETSIZE, &fds, 0, 0, &tv )) < 0 ) {
-           syslog( LOG_ERR, "select: %m" );
-           return( -1 );
+       do { /* do list until success or an unrecoverable error occurs */
+         if (( cc = select( FD_SETSIZE, &fds, 0, 0, &tv )) < 0 )
+             syslog( LOG_ERR, "select: %m" ); /* log all errors */
+       } while (( cc < 0 ) && (errno == 4));
+
+       if ( cc < 0 ) {
+         syslog( LOG_ERR, "select: Error is unrecoverable" );
+         return( -1 );
        }
        if ( cc == 0 ) {
            if ( timeout++ > 2 ) {
@@ -162,7 +176,7 @@ int session( atp, sat )
                /*
                 * Other side is ready for some data.
                 */
-               bcopy( &cbuf[ 2 ], &netseq, sizeof( netseq ));
+               memcpy( &netseq, &cbuf[ 2 ], sizeof( netseq ));
                if ( netseq != 0 ) {
                    if ( rseq != ntohs( netseq )) {
                        break;