From 8caceb7a474bf32cddfd25fba25b531ff65f4365 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 26 Nov 2021 16:16:54 +0200 Subject: bpo-40280: Add configure check for socket shutdown (GH-29795) --- Misc/NEWS.d/next/Build/2021-11-26-14-09-04.bpo-40280.ZLpwQf.rst | 3 +++ Modules/socketmodule.c | 4 ++++ PC/pyconfig.h | 3 +++ configure | 2 +- configure.ac | 2 +- pyconfig.h.in | 3 +++ 6 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2021-11-26-14-09-04.bpo-40280.ZLpwQf.rst diff --git a/Misc/NEWS.d/next/Build/2021-11-26-14-09-04.bpo-40280.ZLpwQf.rst b/Misc/NEWS.d/next/Build/2021-11-26-14-09-04.bpo-40280.ZLpwQf.rst new file mode 100644 index 0000000..ce75feb --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-11-26-14-09-04.bpo-40280.ZLpwQf.rst @@ -0,0 +1,3 @@ +``configure`` now checks for socket ``shutdown`` function. The check makes +it possible to disable ``SYS_shutdown`` with ``ac_cv_func_shutdown=no`` in +CONFIG_SITE. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index ed1043c..89e93c5 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4788,6 +4788,7 @@ Set operation mode, IV and length of associated data for an AF_ALG\n\ operation socket."); #endif +#ifdef HAVE_SHUTDOWN /* s.shutdown(how) method */ static PyObject * @@ -4812,6 +4813,7 @@ PyDoc_STRVAR(shutdown_doc, \n\ Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\ of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR)."); +#endif #if defined(MS_WINDOWS) && defined(SIO_RCVALL) static PyObject* @@ -4957,8 +4959,10 @@ static PyMethodDef sock_methods[] = { gettimeout_doc}, {"setsockopt", (PyCFunction)sock_setsockopt, METH_VARARGS, setsockopt_doc}, +#ifdef HAVE_SHUTDOWN {"shutdown", (PyCFunction)sock_shutdown, METH_O, shutdown_doc}, +#endif #ifdef CMSG_LEN {"recvmsg", (PyCFunction)sock_recvmsg, METH_VARARGS, recvmsg_doc}, diff --git a/PC/pyconfig.h b/PC/pyconfig.h index b3e73d4..5d8d9f3 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -517,6 +517,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define if you have siginterrupt. */ /* #undef HAVE_SIGINTERRUPT */ +/* Define to 1 if you have the `shutdown' function. */ +#define HAVE_SHUTDOWN 1 + /* Define if you have symlink. */ /* #undef HAVE_SYMLINK */ diff --git a/configure b/configure index 1aaa13a..5f8b11c 100755 --- a/configure +++ b/configure @@ -13395,7 +13395,7 @@ for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ setgid sethostname \ setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \ sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \ - sched_rr_get_interval \ + sched_rr_get_interval shutdown \ sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \ sigtimedwait sigwait sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ diff --git a/configure.ac b/configure.ac index 7963f9c..447a9c8 100644 --- a/configure.ac +++ b/configure.ac @@ -3956,7 +3956,7 @@ AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ setgid sethostname \ setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \ sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \ - sched_rr_get_interval \ + sched_rr_get_interval shutdown \ sigaction sigaltstack sigfillset siginterrupt sigpending sigrelse \ sigtimedwait sigwait sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ diff --git a/pyconfig.h.in b/pyconfig.h.in index 842759f..b837b9a 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -992,6 +992,9 @@ /* Define to 1 if you have the `shm_unlink' function. */ #undef HAVE_SHM_UNLINK +/* Define to 1 if you have the `shutdown' function. */ +#undef HAVE_SHUTDOWN + /* Define to 1 if you have the `sigaction' function. */ #undef HAVE_SIGACTION -- cgit v0.12