Re: HP/UX 11 test_socket failure

Anders Qvist <[email protected]> Sun, 20 Oct 2002 09:56:53 +0200
Newsgroups gmane.comp.python.snake-farm.user
Message-ID <[email protected]>
On Sat, Oct 19, 2002 at 07:08:35AM -0400, Guido van Rossum wrote:
> > I'll patch and try this tomorrow, unless someone else does it before
> > me.
> 
> Good sleuthing!  I didn't know there were platforms where O_NDELAY and
> O_NONBLOCK differed. :-(  On Linux, they're two names for the same flag.

The diff would be thus:

----8<--------------------------------------------------------------------
Index: socketmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.244
diff -u -r1.244 socketmodule.c
--- socketmodule.c	3 Sep 2002 19:10:18 -0000	1.244
+++ socketmodule.c	20 Oct 2002 07:45:53 -0000
@@ -480,9 +480,17 @@
 #else /* !PYOS_OS2 */
 	delay_flag = fcntl(s->sock_fd, F_GETFL, 0);
 	if (block)
+#if definded(__hpux)
+		delay_flag &= (~O_NONBLOCK);
+#else
 		delay_flag &= (~O_NDELAY);
+#endif
 	else
+#if definded(__hpux)
+		delay_flag |= O_NONBLOCK;
+#else
 		delay_flag |= O_NDELAY;
+#endif
 	fcntl(s->sock_fd, F_SETFL, delay_flag);
 #endif /* !PYOS_OS2 */
 #else /* MS_WINDOWS */
----8<--------------------------------------------------------------------

However, I'm not sure any other OS makes this distinction. If not, it
would be better to switch to O_NONBLOCK for all archs rather than
complicate the code with another ifdef.
--
Anders "Quest" Qvist

"We've all heard that a million monkeys banging on a million typewriters
will eventually reproduce the entire works of Shakespeare. Now, thanks 
to the Internet, we know this is not true." -- Robert Wilensky