0001-Fix-compile-without-threads.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From 6c71182dde4d37fd70ee8015f61935254ae6f9a6 Mon Sep 17 00:00:00 2001
  2. From: Maxim Kochetkov <fido_max@inbox.ru>
  3. Date: Thu, 19 Sep 2024 10:04:05 +0300
  4. Subject: [PATCH] Fix compile without threads
  5. All mutexes should be wrapped by #ifdef ENABLE_THREAD_SAFETY.
  6. Fixes: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=52afe563206e753f4c45c014fee2459ad0855826
  7. Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
  8. Signed-off-by: Maxim Kochetkov <m.kochetkov@yadro.com>
  9. Upstream: N/A, as --disable-thread-safety will disappear in PostgreSQL 17.
  10. ---
  11. src/interfaces/ecpg/ecpglib/misc.c | 6 ++++++
  12. src/interfaces/libpq/fe-misc.c | 6 ++++++
  13. 2 files changed, 12 insertions(+)
  14. diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
  15. index 4b54322926..5a4d2e847e 100644
  16. --- a/src/interfaces/ecpg/ecpglib/misc.c
  17. +++ b/src/interfaces/ecpg/ecpglib/misc.c
  18. @@ -538,7 +538,9 @@ ecpg_gettext(const char *msgid)
  19. * might as well do it the same way everywhere.
  20. */
  21. static volatile bool already_bound = false;
  22. +#ifdef ENABLE_THREAD_SAFETY
  23. static pthread_mutex_t binddomain_mutex = PTHREAD_MUTEX_INITIALIZER;
  24. +#endif
  25. if (!already_bound)
  26. {
  27. @@ -549,7 +551,9 @@ ecpg_gettext(const char *msgid)
  28. int save_errno = errno;
  29. #endif
  30. +#ifdef ENABLE_THREAD_SAFETY
  31. (void) pthread_mutex_lock(&binddomain_mutex);
  32. +#endif
  33. if (!already_bound)
  34. {
  35. @@ -566,7 +570,9 @@ ecpg_gettext(const char *msgid)
  36. already_bound = true;
  37. }
  38. +#ifdef ENABLE_THREAD_SAFETY
  39. (void) pthread_mutex_unlock(&binddomain_mutex);
  40. +#endif
  41. #ifdef WIN32
  42. SetLastError(save_errno);
  43. diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
  44. index 488f7d6e55..2185e0ba7a 100644
  45. --- a/src/interfaces/libpq/fe-misc.c
  46. +++ b/src/interfaces/libpq/fe-misc.c
  47. @@ -1232,7 +1232,9 @@ libpq_binddomain(void)
  48. * might as well do it the same way everywhere.
  49. */
  50. static volatile bool already_bound = false;
  51. +#ifdef ENABLE_THREAD_SAFETY
  52. static pthread_mutex_t binddomain_mutex = PTHREAD_MUTEX_INITIALIZER;
  53. +#endif
  54. if (!already_bound)
  55. {
  56. @@ -1243,7 +1245,9 @@ libpq_binddomain(void)
  57. int save_errno = errno;
  58. #endif
  59. +#ifdef ENABLE_THREAD_SAFETY
  60. (void) pthread_mutex_lock(&binddomain_mutex);
  61. +#endif
  62. if (!already_bound)
  63. {
  64. @@ -1260,7 +1264,9 @@ libpq_binddomain(void)
  65. already_bound = true;
  66. }
  67. +#ifdef ENABLE_THREAD_SAFETY
  68. (void) pthread_mutex_unlock(&binddomain_mutex);
  69. +#endif
  70. #ifdef WIN32
  71. SetLastError(save_errno);
  72. --
  73. 2.45.2