Re: passfd.c on 64 bits system?

Dryice Liu <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
Dryice Liu <[email protected]> wrote:

> On my FreeBSD6.0-amd64 box the test_passfd.py failed. The error
> message looks like:
>
> ,----
> | rfd 3 wfd 4
> | x
> | Traceback (most recent call last):
> |   File "/usr/local/lib/python2.4/site-packages/scgi/test_passfd.py", line 46, in ?
> |     fileObj = os.fdopen(fd, 'r')
> | OSError: [Errno 9] Bad file descriptor
> `----
>
> I guess this is related to the differences of sizeof(long) on 32/64
> bits machines but can't prove/fix it. Can somebody shine some light on
> this? Thanks!

Well I think I've found the problem. In struct iovec, iov_base is a
void*, while on i386 box a pointer is 32 bits and on amd64 a pointer
is 64 bits. Looks the following patch could fix it. They works at
least on my FreeBSD 6.0 i386 and amd64.

======================================================================
--- passfd.c.orig	Thu Dec  1 21:14:17 2005
+++ passfd.c	Thu Dec  1 21:14:53 2005
@@ -22,7 +22,7 @@
 #include <stddef.h>
 
 
-#define CONTROLLEN sizeof (struct cmsghdr) + sizeof (int)
+#define CONTROLLEN sizeof (struct cmsghdr) + sizeof (void*)
 
 static int
 recv_fd(int sockfd)
@@ -31,7 +31,7 @@
 	struct cmsghdr *cmptr = (struct cmsghdr *) tmpbuf;
 	struct iovec iov[1];
 	struct msghdr msg;
-	char buf[1];
+	void* buf[1];
 
 	iov[0].iov_base = buf;
 	iov[0].iov_len = sizeof (buf);
@@ -56,7 +56,7 @@
 	struct cmsghdr *cmptr = (struct cmsghdr *) tmpbuf;
         struct iovec iov[1];
         struct msghdr msg;
-        char buf[1];
+        void* buf[1];
 
         iov[0].iov_base = buf;
         iov[0].iov_len = 1;
======================================================================

-- 
Dryice @ http://dryice.3322.org

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/sylvester-response.html

_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users
signature.asc (application/pgp-signature, 186 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)

iD8DBQBDjwBGa1t4qHe2eHQRAgBJAJ4nAxhEoo1f4yC1888DetxiU+PnRACfVtJu
Dd9wDK5MS13oxmNUoQ4yT6c=
=KWcl
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.