Skip to content

gh-117440: Make syslog thread-safe in free-threaded builds #117441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Modules/clinic/syslogmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Modules/syslogmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ syslog_get_argv(void)


/*[clinic input]
@critical_section
syslog.openlog

ident: unicode = NULL
Expand All @@ -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.
Expand Down Expand Up @@ -189,6 +190,7 @@ syslog_openlog_impl(PyObject *module, PyObject *ident, long logopt,


/*[clinic input]
@critical_section
syslog.syslog

[
Expand All @@ -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;
Expand Down Expand Up @@ -243,14 +245,15 @@ 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().
[clinic start generated code]*/

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.
Expand Down