Bugzilla bug 110868: PR_FileDesc2NativeHandle should look for the NSPR
authorwtc%netscape.com
Thu, 27 Dec 2001 02:19:31 +0000
changeset 2153 94c49932cc1e89c6c3a00d4a2ff0d049e10ef40a
parent 2152 2e4e3584962d2ea4a66283a7150ac212a6ae16e5
child 2154 68581b433f08b90f2c09d21807910f163c5dbd1e
push idunknown
push userunknown
push dateunknown
bugs110868
Bugzilla bug 110868: PR_FileDesc2NativeHandle should look for the NSPR layer as opposed to assuming the bottom layer is the NSPR layer.
pr/src/io/prsocket.c
--- a/pr/src/io/prsocket.c
+++ b/pr/src/io/prsocket.c
@@ -1534,30 +1534,24 @@ failed:
     }
     return PR_FAILURE;
 #endif
 }
 
 PR_IMPLEMENT(PRInt32)
 PR_FileDesc2NativeHandle(PRFileDesc *fd)
 {
-	if (fd) {
-		/*
-		 * The fd may be layered.  Chase the links to the
-		 * bottom layer to get the osfd.
-		 */
-		PRFileDesc *bottom = fd;
-		while (bottom->lower != NULL) {
-			bottom = bottom->lower;
-		}
-		return bottom->secret->md.osfd;
-	} else {
-		PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
-		return -1;
-	}
+    if (fd) {
+        fd = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER);
+    }
+    if (!fd) {
+        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
+        return -1;
+    }
+    return fd->secret->md.osfd;
 }
 
 PR_IMPLEMENT(void)
 PR_ChangeFileDescNativeHandle(PRFileDesc *fd, PRInt32 handle)
 {
 	if (fd)
 		fd->secret->md.osfd = handle;
 }