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

fcntl handling



The RTEMS code in the 19991203 snapshot isn't entirely consistent with
the handling of fcntl flags.  In lib/libc, the values stored in
iop->flags are LIBIO_FLAGS_ values.  In libnetworking, the values
checked in iop->flags are O_ values.

The code also doesn't handle O_NONBLOCK at all.  It only handles
O_NDELAY.  The two are not identical on Unix, although the difference
is more annoying than useful and for RTEMS purposes they may as well
be identical.  (The difference is that if you apply O_NDELAY to a
device, and you open the device again to get a fresh file descriptor,
O_NDELAY is still in effect; this is so weird that POSIX invented
O_NONBLOCK, which goes with the file descriptor as one would expect).

These patches try to fix this.  Without these patches, O_NONBLOCK on a
socket doesn't seem to work.  I'm using an older snapshot, and I
adapted these patches for 19991203, so it is possible that this
problem has been fixed in some other way.

Ian

--- /disk2/home/ian/rtems/rtems-19991203/c/src/lib/libc/libio.c	Tue Nov 30 11:52:21 1999
+++ c/src/lib/libc/libio.c	Tue Dec 14 16:17:18 1999
@@ -3,14 +3,15 @@
@@ -109,6 +116,7 @@
 
 rtems_assoc_t status_flags_assoc[] = {
   { "NO DELAY",  LIBIO_FLAGS_NO_DELAY,  O_NDELAY },
+  { "NO DELAY",  LIBIO_FLAGS_NO_DELAY,  O_NONBLOCK },
   { "APPEND",    LIBIO_FLAGS_APPEND,    O_APPEND },
   { "CREATE",    LIBIO_FLAGS_CREATE,    O_CREAT },
   { 0, 0, 0 },
--- /disk2/home/ian/rtems/rtems-19991203/c/src/libnetworking/rtems/rtems_syscall.c	Wed Oct  6 16:37:26 1999
+++ c/src/lib/libnetworking/rtems/rtems_syscall.c	Tue Dec 14 16:17:19 1999
@@ -674,11 +674,11 @@
 	switch (command) {
 	case FIONBIO:
 		if (*(int *)buffer) {
-			iop->flags |= O_NONBLOCK;
+			iop->flags |= LIBIO_FLAGS_NO_DELAY;
 			so->so_state |= SS_NBIO;
 		}
 		else {
-			iop->flags &= ~O_NONBLOCK;
+			iop->flags &= ~LIBIO_FLAGS_NO_DELAY;
 			so->so_state &= ~SS_NBIO;
 		}
 		return 0;
@@ -727,7 +727,7 @@
 			rtems_bsdnet_semaphore_release ();
 			return EBADF;
 		}
-		if (iop->flags & O_NONBLOCK)
+		if (iop->flags & LIBIO_FLAGS_NO_DELAY)
 			so->so_state |= SS_NBIO;
 		else
 			so->so_state &= ~SS_NBIO;