Module: xenomai-head
Branch: master
Commit: 34234ca456a898cee2e31e133e0d87766f9cafe1
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=34234ca456a898cee2e31e133e0d87766f9cafe1

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Fri Oct  2 11:18:25 2009 +0200

POSIX: Fix error reporting of __real_accept

The return values of __real_accept must not be processed via set_errno
as errno is already set correctly at this point.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 src/skins/posix/rtdm.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/skins/posix/rtdm.c b/src/skins/posix/rtdm.c
index 6e347fb..4e6685f 100644
--- a/src/skins/posix/rtdm.c
+++ b/src/skins/posix/rtdm.c
@@ -404,18 +404,21 @@ int __wrap_accept(int fd, struct sockaddr *addr, 
socklen_t * addrlen)
 
                pthread_setcanceltype(oldtype, NULL);
 
-               if (fd >= 0)
-                       fd += __rtdm_fd_start;
+               if (fd < 0)
+                       return set_errno(fd);
+
+               return fd + __rtdm_fd_start;
        } else {
                fd = __real_accept(fd, addr, addrlen);
 
                if (fd >= __rtdm_fd_start) {
                        __real_close(fd);
-                       fd = -EMFILE;
+                       errno = EMFILE;
+                       fd = -1;
                }
-       }
 
-       return set_errno(fd);
+               return fd;
+       }
 }
 
 int __wrap_getsockname(int fd, struct sockaddr *name, socklen_t * namelen)


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to