From 38fb2b306f4f8f4e0ce5da2c6510e8e3dbfc2203 Mon Sep 17 00:00:00 2001 From: Donghee Nals Date: Wed, 20 Mar 2024 00:55:02 +0900 Subject: [PATCH] gh-114727: Update os_{openpty|grantpt}_impl to use per module lock. --- Modules/clinic/posixmodule.c.h | 13 +++++++++++-- Modules/posixmodule.c | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 0398629e3c10ce..eed688d2b14a28 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_long.h" // _PyLong_UnsignedInt_Converter() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() @@ -4537,7 +4538,9 @@ os_grantpt(PyObject *module, PyObject *arg) if (fd < 0) { goto exit; } + Py_BEGIN_CRITICAL_SECTION(module); return_value = os_grantpt_impl(module, fd); + Py_END_CRITICAL_SECTION(); exit: return return_value; @@ -4640,7 +4643,13 @@ os_openpty_impl(PyObject *module); static PyObject * os_openpty(PyObject *module, PyObject *Py_UNUSED(ignored)) { - return os_openpty_impl(module); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(module); + return_value = os_openpty_impl(module); + Py_END_CRITICAL_SECTION(); + + return return_value; } #endif /* (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) */ @@ -12602,4 +12611,4 @@ os__supports_virtual_terminal(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF #define OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF #endif /* !defined(OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF) */ -/*[clinic end generated code: output=511f0788a6b90db0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c961606cd40a4f2c input=a9049054013a1b77]*/ diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 7b2d3661ee5546..631fc24935c866 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -8419,6 +8419,7 @@ os_posix_openpt_impl(PyObject *module, int oflag) #ifdef HAVE_GRANTPT /*[clinic input] +@critical_section os.grantpt fd: fildes @@ -8432,7 +8433,7 @@ Performs a grantpt() C function call. static PyObject * os_grantpt_impl(PyObject *module, int fd) -/*[clinic end generated code: output=dfd580015cf548ab input=0668e3b96760e849]*/ +/*[clinic end generated code: output=dfd580015cf548ab input=c813b58c0ee7d9a0]*/ { int ret; int saved_errno; @@ -8547,6 +8548,7 @@ os_ptsname_impl(PyObject *module, int fd) #if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX) /*[clinic input] +@critical_section os.openpty Open a pseudo-terminal. @@ -8557,7 +8559,7 @@ for both the master and slave ends. static PyObject * os_openpty_impl(PyObject *module) -/*[clinic end generated code: output=98841ce5ec9cef3c input=f3d99fd99e762907]*/ +/*[clinic end generated code: output=98841ce5ec9cef3c input=49472bedd2dfaffe]*/ { int master_fd = -1, slave_fd = -1; #ifndef HAVE_OPENPTY pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy