Discussion:
make test: SHUT_RDWR, SHUT_RD, SHUT_WR not defined
Kevin R. Bulgrien via curl-library
2021-04-19 22:34:14 UTC
Permalink
On SCO OpenServer 5.0.7, sys/socket.h does not define either SHUT_RDWR,
SHUT_RD, and SHUT_WR. This causes a problem when running `make test`.

May I suggest a patch similar to the following patch that improves the
workarounds for missing SHUT_RD, SHUT_WR, and SHUT_RDWR definitions?

$ cat curl-7.76.0-i686-pc-sco3.2v5.0.7-3.patch
--- curl-7.76.0/lib/curl_setup.h.orig 2021-03-30 07:39:12.000000000 -0500
+++ curl-7.76.0/lib/curl_setup.h 2021-04-19 15:37:51.000000000 -0500
@@ -715,10 +715,12 @@
#endif

/*
- * Portable symbolic names for Winsock shutdown() mode flags.
+ * Portable symbolic names for Winsock shutdown() mode flags and other
+ * systems that do not define them.
*/

-#ifdef USE_WINSOCK
+#if defined(USE_WINSOCK) || \
+ !defined(SHUT_RD) && (defined(HAVE_SOCKET_H) || defined(HAVE_SYS_SOCKET_H))
# define SHUT_RD 0x00
# define SHUT_WR 0x01
# define SHUT_RDWR 0x02

Justification:

$ grep shutdown /usr/include/sys/socket.h
int shutdown __P((int, int));

On these systems, `man SSC shutdown` mentions use of -lsocket
and documents the values to use when calling shutdown(). The
man page indicates 0 shuts off reads, 1 shuts off sends, and,
2 disallows both sends and receives.

The only /usr/include reference to SHUT_* defines appears in the
system's /usr/include/php/main/php_network.h file:

/* These are here, rather than with the win32 counterparts above,
* since <sys/socket.h> defines them. */
#ifndef SHUT_RD
# define SHUT_RD 0
# define SHUT_WR 1
# define SHUT_RDWR 2
#endif

--

Kevin R. Bulgrien
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se
Daniel Stenberg via curl-library
2021-04-20 07:24:58 UTC
Permalink
Post by Kevin R. Bulgrien via curl-library
-#ifdef USE_WINSOCK
+#if defined(USE_WINSOCK) || \
+ !defined(SHUT_RD) && (defined(HAVE_SOCKET_H) || defined(HAVE_SYS_SOCKET_H))
# define SHUT_RD 0x00
# define SHUT_WR 0x01
# define SHUT_RDWR 0x02
Isn't it better to just do #ifndef for each define? Like this:

https://github.com/curl/curl/pull/6925
--
/ daniel.haxx.se
| Commercial curl support up to 24x7 is available!
| Private help, bug fixes, support, ports, new features
| https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-l
Kevin R. Bulgrien via curl-library
2021-04-20 07:33:16 UTC
Permalink
Post by Daniel Stenberg via curl-library
Post by Kevin R. Bulgrien via curl-library
-#ifdef USE_WINSOCK
+#if defined(USE_WINSOCK) || \
+ !defined(SHUT_RD) && (defined(HAVE_SOCKET_H) ||
defined(HAVE_SYS_SOCKET_H))
# define SHUT_RD 0x00
# define SHUT_WR 0x01
# define SHUT_RDWR 0x02
https://github.com/curl/curl/pull/6925
Thanks for the change. The intent was to suggest an edit in
a manner that clearly communicated what was wrong. It is
perfectly fine for the patch to look different than what
was proposed as it accomplishes the end goal.

Kevin R. Bulgrien
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://

Loading...