talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit fb963b3aaed5846f39699f537a6332fd7192a56f
parent 450ebe7e8660e9f13faae91d624613c72b31f878
Author: Oliver Lowe <o@olowe.co>
Date:   Mon, 11 Aug 2025 14:01:48 +1000

Always use pthread on unix-like OSs

And drop from Windows. Dropping windows entirely soon.

Diffstat:
Mclaws-features.h.in | 1-
Mconfigure.ac | 40+---------------------------------------
Msrc/Makefile.am | 2+-
Msrc/common/Makefile.am | 2+-
Msrc/common/ssl.c | 36++++++++++++------------------------
Msrc/exporthtml.c | 4----
Msrc/gtk/w32_filesel.c | 56--------------------------------------------------------
Msrc/matcher.c | 27+--------------------------
Msrc/mbox.c | 6------
9 files changed, 16 insertions(+), 158 deletions(-)

diff --git a/claws-features.h.in b/claws-features.h.in @@ -6,5 +6,4 @@ #undef USE_ENCHANT #undef USE_GNUTLS #undef USE_GPGME -#undef USE_PTHREAD #undef __CYGWIN__ diff --git a/configure.ac b/configure.ac @@ -199,18 +199,13 @@ if test $USE_MAINTAINER_MODE = yes; then AM_CFLAGS="$AM_CFLAGS -g" fi -pthread_name= case "$target" in *-darwin*) AM_CFLAGS="$AM_CFLAGS -fno-common" ;; *-*-mingw*) - # Note that we need to link to pthread in all cases. This - # is because some locking is used even when pthread support is - # disabled. - pthread_name=pthread AM_CFLAGS="$AM_CFLAGS -mms-bitfields" - LIBS="$LIBS -l${pthread_name} -lws2_32 -lregex" + LIBS="$LIBS -lws2_32 -lregex" ;; *-*-solaris*) AM_CFLAGS="$AM_CFLAGS -std=gnu99" @@ -258,10 +253,6 @@ AC_ARG_ENABLE(crash-dialog, [ --enable-crash-dialog Build crash dialog], [enable_crash_dialog=$enableval], [enable_crash_dialog=no]) -AC_ARG_ENABLE(pthread, - [ --disable-pthread Do not build pthread support], - [enable_pthread=$enableval], [enable_pthread=yes]) - AC_ARG_ENABLE(startup-notification, [ --disable-startup-notification Do not startup notification support], [enable_startup_notification=$enableval], [enable_startup_notification=yes]) @@ -536,34 +527,6 @@ dnl check if GDB is somewhere AC_MSG_RESULT($enable_crash_dialog) fi -dnl check for pthread support -AC_MSG_CHECKING([whether to use pthread]) -if test x$enable_pthread = xno; then - AC_MSG_RESULT(no) -else - AC_MSG_RESULT(yes) - - # For W32 we need to use a special ptrhead lib. In this case we can't - # use AC_CHECK_LIB because it has no means of checking for a - # library installed under a different name. Checking for the - # header is okay. - if test -n "${pthread_name}" ; then - enable_pthread=yes - else - AC_CHECK_LIB(pthread, pthread_create, :, enable_pthread=no) - fi - AC_CHECK_HEADERS(pthread.h, :, enable_pthread=no) - - if test x$enable_pthread = xyes; then - AC_DEFINE(USE_PTHREAD, 1, Define if you have pthread) - if test -z "${pthread_name}" ; then - PTHREAD_LIBS="-lpthread" - fi - fi - -fi -AC_SUBST(PTHREAD_LIBS) - dnl dnl Check whether we need to pass -lresolv dnl We know that we don't need it for W32. @@ -965,7 +928,6 @@ echo "Crash dialog : $enable_crash_dialog" echo "Manual : $enable_manual" echo "SVG support : $enable_svg" echo "Unit tests : $enable_tests" -echo "pthread : $enable_pthread" echo "Startup notification : $enable_startup_notification" echo "Valgrind support : $enable_valgrind" diff --git a/src/Makefile.am b/src/Makefile.am @@ -536,7 +536,7 @@ claws_mail_LDADD = \ $(GTK_LIBS) \ $(GNUTLS_LIBS) \ $(NETTLE_LIBS) \ - $(PTHREAD_LIBS) \ + -lpthread \ $(LIBICONV) \ $(STARTUP_NOTIFICATION_LIBS) \ $(LIBETPAN_LIBS) \ diff --git a/src/common/Makefile.am b/src/common/Makefile.am @@ -94,7 +94,7 @@ AM_CPPFLAGS = \ libclawscommon_la_LIBADD = \ $(GLIB_LIBS) \ $(CRYPT_LIBS) \ - $(PTHREAD_LIBS) + -lpthread EXTRA_DIST = \ version.h.in diff --git a/src/common/ssl.c b/src/common/ssl.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifdef HAVE_CONFIG_H @@ -46,16 +46,12 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL; #include <libetpan/mailstream_ssl.h> #endif -#ifdef USE_PTHREAD #include <pthread.h> -#endif -#ifdef USE_PTHREAD typedef struct _thread_data { gnutls_session_t ssl; gboolean done; } thread_data; -#endif #if GNUTLS_VERSION_NUMBER < 0x030400 #define DEFAULT_GNUTLS_PRIORITY "NORMAL:-VERS-SSL3.0" @@ -91,7 +87,7 @@ static int gnutls_cert_cb(gnutls_session_t session, hookdata.cert_path = NULL; hookdata.password = NULL; hookdata.is_smtp = sockinfo->is_smtp; - hooks_invoke(SSLCERT_GET_CLIENT_CERT_HOOKLIST, &hookdata); + hooks_invoke(SSLCERT_GET_CLIENT_CERT_HOOKLIST, &hookdata); if (hookdata.cert_path == NULL) { g_free(hookdata.password); @@ -102,7 +98,7 @@ static int gnutls_cert_cb(gnutls_session_t session, sockinfo->client_key = ssl_certificate_get_pkey_from_pem_file(hookdata.cert_path); if (!(sockinfo->client_crt && sockinfo->client_key)) { /* try pkcs12 format */ - ssl_certificate_get_x509_and_pkey_from_p12_file(hookdata.cert_path, hookdata.password, + ssl_certificate_get_x509_and_pkey_from_p12_file(hookdata.cert_path, hookdata.password, &crt, &key); sockinfo->client_crt = crt; sockinfo->client_key = key; @@ -241,7 +237,7 @@ const gchar *claws_ssl_get_cert_dir(void) "/usr/lib/ssl/certs", NULL}; int i; - + for (i = 0; cert_dirs[i]; i++) { if (is_dir_exist(cert_dirs[i])) return cert_dirs[i]; @@ -259,7 +255,7 @@ void ssl_init(void) #endif #ifdef HAVE_LIBETPAN mailstream_gnutls_init_not_required(); -#endif +#endif gnutls_global_init(); } @@ -268,7 +264,6 @@ void ssl_done(void) gnutls_global_deinit(); } -#ifdef USE_PTHREAD static void *SSL_connect_thread(void *data) { thread_data *td = (thread_data *)data; @@ -284,23 +279,21 @@ static void *SSL_connect_thread(void *data) td->done = TRUE; /* let the caller thread join() */ return GINT_TO_POINTER(result); } -#endif static gint SSL_connect_nb(gnutls_session_t ssl) { int result; -#ifdef USE_PTHREAD thread_data *td = g_new0(thread_data, 1); pthread_t pt; void *res = NULL; time_t start_time = time(NULL); gboolean killed = FALSE; - + td->ssl = ssl; td->done = FALSE; - + /* try to create a thread to initialize the SSL connection, - * fallback to blocking method in case of problem + * fallback to blocking method in case of problem */ if (pthread_create(&pt, NULL, SSL_connect_thread, td) != 0) { do { @@ -322,19 +315,14 @@ static gint SSL_connect_nb(gnutls_session_t ssl) /* get the thread's return value and clean its resources */ pthread_join(pt, &res); g_free(td); - + if (killed) { res = GINT_TO_POINTER(-1); } - debug_print("SSL_connect thread returned %d\n", + debug_print("SSL_connect thread returned %d\n", GPOINTER_TO_INT(res)); - + return GPOINTER_TO_INT(res); -#else /* USE_PTHREAD */ - do { - result = gnutls_handshake(ssl); - } while (result == GNUTLS_E_AGAIN || result == GNUTLS_E_INTERRUPTED); -#endif } gnutls_x509_crt_t *ssl_get_certificate_chain(gnutls_session_t session, unsigned int *list_len) @@ -430,7 +418,7 @@ gboolean ssl_init_socket(SockInfo *sockinfo) r = gnutls_certificate_set_x509_trust_file(xcred, claws_ssl_get_cert_file(), GNUTLS_X509_FMT_PEM); if (r < 0) g_warning("can't read SSL_CERT_FILE '%s': %s", - claws_ssl_get_cert_file(), + claws_ssl_get_cert_file(), gnutls_strerror(r)); } else { debug_print("Can't find SSL ca-certificates file\n"); diff --git a/src/exporthtml.c b/src/exporthtml.c @@ -25,10 +25,6 @@ #include "claws-features.h" #endif -#ifdef USE_PTHREAD -#include <pthread.h> -#endif - #include <sys/stat.h> #include <errno.h> #include <time.h> diff --git a/src/gtk/w32_filesel.c b/src/gtk/w32_filesel.c @@ -27,7 +27,6 @@ #include <glib.h> #include <glib/gi18n.h> #include <gdk/gdkwin32.h> -#include <pthread.h> #include <windows.h> #include <shlobj.h> @@ -111,9 +110,6 @@ static const gboolean _file_open_dialog(const gchar *path, const gchar *title, glong conv_items, sz; GError *error = NULL; WinChooserCtx *ctx; -#ifdef USE_PTHREAD - pthread_t pt; -#endif /* Path needs to be converted to UTF-16, so that the native chooser * can understand it. */ @@ -185,22 +181,7 @@ static const gboolean _file_open_dialog(const gchar *path, const gchar *title, ctx->data = &o; ctx->done = FALSE; -#ifdef USE_PTHREAD - if (pthread_create(&pt, NULL, threaded_GetOpenFileName, - (void *)ctx) != 0) { - debug_print("Couldn't run in a thread, continuing unthreaded.\n"); - threaded_GetOpenFileName(ctx); - } else { - while (!ctx->done) { - claws_do_idle(); - } - pthread_join(pt, NULL); - } - ret = ctx->return_value; -#else - debug_print("No threads available, continuing unthreaded.\n"); ret = GetOpenFileName(&o); -#endif g_free(win_filter16); if (path16 != NULL) { @@ -329,9 +310,6 @@ gchar *filesel_select_file_save(const gchar *title, const gchar *path) glong conv_items; GError *error = NULL; WinChooserCtx *ctx; -#ifdef USE_PTHREAD - pthread_t pt; -#endif /* Find the filename part, if any */ if (path == NULL || path[strlen(path)-1] == G_DIR_SEPARATOR) { @@ -392,22 +370,7 @@ gchar *filesel_select_file_save(const gchar *title, const gchar *path) ctx->return_value = FALSE; ctx->done = FALSE; -#ifdef USE_PTHREAD - if (pthread_create(&pt, NULL, threaded_GetSaveFileName, - (void *)ctx) != 0) { - debug_print("Couldn't run in a thread, continuing unthreaded.\n"); - threaded_GetSaveFileName(ctx); - } else { - while (!ctx->done) { - claws_do_idle(); - } - pthread_join(pt, NULL); - } - ret = ctx->return_value; -#else - debug_print("No threads available, continuing unthreaded.\n"); ret = GetSaveFileName(&o); -#endif g_free(filename16); g_free(path16); @@ -453,9 +416,6 @@ gchar *filesel_select_file_open_folder(const gchar *title, const gchar *path) glong conv_items; GError *error = NULL; WinChooserCtx *ctx; -#ifdef USE_PTHREAD - pthread_t pt; -#endif /* Path needs to be converted to UTF-16, so that the native chooser * can understand it. */ @@ -493,23 +453,7 @@ gchar *filesel_select_file_open_folder(const gchar *title, const gchar *path) ctx = g_new0(WinChooserCtx, 1); ctx->data = &b; ctx->done = FALSE; - -#ifdef USE_PTHREAD - if (pthread_create(&pt, NULL, threaded_SHBrowseForFolder, - (void *)ctx) != 0) { - debug_print("Couldn't run in a thread, continuing unthreaded.\n"); - threaded_SHBrowseForFolder(ctx); - } else { - while (!ctx->done) { - claws_do_idle(); - } - pthread_join(pt, NULL); - } - pidl = ctx->return_value_pidl; -#else - debug_print("No threads available, continuing unthreaded.\n"); pidl = SHBrowseForFolder(&b); -#endif g_free(b.pszDisplayName); g_free(title16); diff --git a/src/matcher.c b/src/matcher.c @@ -27,10 +27,7 @@ #include <string.h> #include <stdlib.h> #include <errno.h> - -#ifdef USE_PTHREAD #include <pthread.h> -#endif #include "defs.h" #include "utils.h" @@ -651,14 +648,11 @@ static gboolean matcherprop_header_line_match(MatcherProp *prop, const gchar *hd return res; } -#ifdef USE_PTHREAD typedef struct _thread_data { const gchar *cmd; gboolean done; } thread_data; -#endif -#ifdef USE_PTHREAD static void *matcher_test_thread(void *data) { thread_data *td = (thread_data *)data; @@ -671,7 +665,6 @@ static void *matcher_test_thread(void *data) td->done = TRUE; /* let the caller thread join() */ return GINT_TO_POINTER(result); } -#endif /*! *\brief Execute a command defined in the matcher structure @@ -687,31 +680,24 @@ static gboolean matcherprop_match_test(const MatcherProp *prop, gchar *file; gchar *cmd; gint retval; -#ifdef USE_PTHREAD pthread_t pt; thread_data *td = g_new0(thread_data, 1); void *res = NULL; time_t start_time = time(NULL); -#endif file = procmsg_get_message_file(info); if (file == NULL) { -#ifdef USE_PTHREAD g_free(td); -#endif return FALSE; } g_free(file); cmd = matching_build_command(prop->expr, info); if (cmd == NULL) { -#ifdef USE_PTHREAD g_free(td); -#endif return FALSE; -} + } -#ifdef USE_PTHREAD /* debug output */ if (debug_filtering_session && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) { @@ -742,17 +728,6 @@ static gboolean matcherprop_match_test(const MatcherProp *prop, debug_print(" test thread returned %d\n", retval); } g_free(td); -#else - /* debug output */ - if (debug_filtering_session - && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) { - log_print(LOG_DEBUG_FILTERING, - "starting synchronous command [ %s ]\n", - cmd); - } - - retval = system(cmd); -#endif debug_print("Command exit code: %d\n", retval); /* debug output */ diff --git a/src/mbox.c b/src/mbox.c @@ -22,13 +22,7 @@ #include "claws-features.h" #endif - #include <stdio.h> - -#ifdef USE_PTHREAD -#include <pthread.h> -#endif - #include "defs.h" #include <glib.h> #include <glib/gi18n.h>