Bugzilla bug 121872: define _PR_MD_LISTEN as a function so that we can set
authorwtc%netscape.com
Sun, 27 Jan 2002 02:59:44 +0000
changeset 2200 8909c7061bedfcb03f5f5970fcd59e269c677e12
parent 2199 f3f79419b5f43403083630f61dee6dff43e45400
child 2202 dc4c78401ce1422a3c898ec965a324b04d4ffc24
push idunknown
push userunknown
push dateunknown
bugs121872
Bugzilla bug 121872: define _PR_MD_LISTEN as a function so that we can set error codes if listen() fails. The patch is contributed by Javier Pedemonte <pedemont@us.ibm.com>. Modified files: _os2.h _os2_errors.h os2sock.c
pr/include/md/_os2.h
pr/include/md/_os2_errors.h
pr/src/md/os2/os2sock.c
--- a/pr/include/md/_os2.h
+++ b/pr/include/md/_os2.h
@@ -253,17 +253,17 @@ extern PRInt32 _MD_CloseFile(PRInt32 osf
 #endif  
 
 #define _MD_INIT_FILEDESC(fd)
 extern void _MD_MakeNonblock(PRFileDesc *f);
 #define _MD_MAKE_NONBLOCK             _MD_MakeNonblock
 #define _MD_INIT_FD_INHERITABLE       (_PR_MD_INIT_FD_INHERITABLE)
 #define _MD_QUERY_FD_INHERITABLE      (_PR_MD_QUERY_FD_INHERITABLE)
 #define _MD_SHUTDOWN                  (_PR_MD_SHUTDOWN)
-#define _MD_LISTEN(s, backlog)        listen(s->secret->md.osfd,backlog)
+#define _MD_LISTEN                    _PR_MD_LISTEN
 extern PRInt32 _MD_CloseSocket(PRInt32 osfd);
 #define _MD_CLOSE_SOCKET              _MD_CloseSocket
 #define _MD_SENDTO                    (_PR_MD_SENDTO)
 #define _MD_RECVFROM                  (_PR_MD_RECVFROM)
 #define _MD_SOCKETPAIR(s, type, proto, sv) -1
 #define _MD_GETSOCKNAME               (_PR_MD_GETSOCKNAME)
 #define _MD_GETPEERNAME               (_PR_MD_GETPEERNAME)
 #define _MD_GETSOCKOPT                (_PR_MD_GETSOCKOPT)
--- a/pr/include/md/_os2_errors.h
+++ b/pr/include/md/_os2_errors.h
@@ -35,16 +35,19 @@
 #ifndef nspr_os2_errors_h___
 #define nspr_os2_errors_h___
 
 #include "md/_os2.h"
 #ifndef assert
   #include <assert.h>
 #endif  
 
+NSPR_API(void) _MD_os2_map_default_error(PRInt32 err);
+#define	_PR_MD_MAP_DEFAULT_ERROR	_MD_os2_map_default_error
+
 NSPR_API(void) _MD_os2_map_opendir_error(PRInt32 err);
 #define	_PR_MD_MAP_OPENDIR_ERROR	_MD_os2_map_opendir_error
 
 NSPR_API(void) _MD_os2_map_closedir_error(PRInt32 err);
 #define	_PR_MD_MAP_CLOSEDIR_ERROR	_MD_os2_map_closedir_error
 
 NSPR_API(void) _MD_os2_readdir_error(PRInt32 err);
 #define	_PR_MD_MAP_READDIR_ERROR	_MD_os2_readdir_error
--- a/pr/src/md/os2/os2sock.c
+++ b/pr/src/md/os2/os2sock.c
@@ -353,16 +353,29 @@ PRInt32
         err = sock_errno();
         _PR_MD_MAP_BIND_ERROR(err);
     }
     return(rv);
 }
 
 
 PRInt32
+_PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog)
+{
+    PRInt32 rv, err;
+    rv = listen(fd->secret->md.osfd, backlog);
+    if (rv < 0)  {
+        err = sock_errno();
+        _PR_MD_MAP_DEFAULT_ERROR(err);
+    }
+    return(rv);
+}
+
+
+PRInt32
 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, 
             PRIntervalTime timeout)
 {
     PRInt32 osfd = fd->secret->md.osfd;
     PRInt32 rv, err;
     PRThread *me = _PR_MD_CURRENT_THREAD();
 
     while ((rv = recv(osfd,buf,amount,flags)) == -1)