bpo-30766: Make CHECK_STATUS_PTHREAD signal-safe. by pitrou · Pull Request #2404 · python/cpython
| pthread_mutex_t mut; | ||
| } pthread_lock; | ||
|
|
||
| #define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str)) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why casting strlen() to int?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I copied this macro from traceback.c.
| #define CHECK_STATUS_PTHREAD(name) if (status != 0) { fprintf(stderr, \ | ||
| "%s: %s\n", name, strerror(status)); error = 1; } | ||
| /* CHECK_STATUS_PTHREAD is async-signal-safe */ | ||
| #define CHECK_STATUS_PTHREAD(name) \ |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never understood the purpose of these functions. Do we really need these checks? Why not replacing them with an assertion?
If you want to get them at runtime, maybe call Py_FatalError()?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I'm inclined not to remove them right now.
OTOH, this whole PR may be made obsolete by #2408.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I'm inclined not to remove them right now. OTOH, this whole PR may be made obsolete by #2408.
Oh no, please finish your work. I like the idea of more reliable locks :-)