diff options
author | Sam Gross <colesbury@gmail.com> | 2024-04-02 14:44:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 14:44:26 (GMT) |
commit | 954d616b4c8cd091214aa3b8ea886bcf9067243a (patch) | |
tree | 13e67dbaa98b7288e9d50befd0ac24b9fcba610f /Modules/syslogmodule.c | |
parent | e569f9132b5bdc1c103116a020e19e3ccc20cf34 (diff) | |
download | cpython-954d616b4c8cd091214aa3b8ea886bcf9067243a.zip cpython-954d616b4c8cd091214aa3b8ea886bcf9067243a.tar.gz cpython-954d616b4c8cd091214aa3b8ea886bcf9067243a.tar.bz2 |
gh-117440: Make `syslog` thread-safe in free-threaded builds (#117441)
Use critical sections to protect access to the syslog module.
Diffstat (limited to 'Modules/syslogmodule.c')
-rw-r--r-- | Modules/syslogmodule.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c index 62c7816..cb3f2b0 100644 --- a/Modules/syslogmodule.c +++ b/Modules/syslogmodule.c @@ -132,6 +132,7 @@ syslog_get_argv(void) /*[clinic input] +@critical_section syslog.openlog ident: unicode = NULL @@ -144,7 +145,7 @@ Set logging options of subsequent syslog() calls. static PyObject * syslog_openlog_impl(PyObject *module, PyObject *ident, long logopt, long facility) -/*[clinic end generated code: output=5476c12829b6eb75 input=8a987a96a586eee7]*/ +/*[clinic end generated code: output=5476c12829b6eb75 input=ee700b8786f81c23]*/ { // Since the sys.openlog changes the process level state of syslog library, // this operation is only allowed for the main interpreter. @@ -189,6 +190,7 @@ syslog_openlog_impl(PyObject *module, PyObject *ident, long logopt, /*[clinic input] +@critical_section syslog.syslog [ @@ -205,7 +207,7 @@ Send the string message to the system logger. static PyObject * syslog_syslog_impl(PyObject *module, int group_left_1, int priority, const char *message) -/*[clinic end generated code: output=c3dbc73445a0e078 input=ac83d92b12ea3d4e]*/ +/*[clinic end generated code: output=c3dbc73445a0e078 input=6588ddb0b113af8e]*/ { if (PySys_Audit("syslog.syslog", "is", priority, message) < 0) { return NULL; @@ -243,6 +245,7 @@ syslog_syslog_impl(PyObject *module, int group_left_1, int priority, /*[clinic input] +@critical_section syslog.closelog Reset the syslog module values and call the system library closelog(). @@ -250,7 +253,7 @@ Reset the syslog module values and call the system library closelog(). static PyObject * syslog_closelog_impl(PyObject *module) -/*[clinic end generated code: output=97890a80a24b1b84 input=fb77a54d447acf07]*/ +/*[clinic end generated code: output=97890a80a24b1b84 input=167f489868bd5a72]*/ { // Since the sys.closelog changes the process level state of syslog library, // this operation is only allowed for the main interpreter. |