Fix pthread bug causing a crash after executing external programs (and

possibly in other situations). Found in upstream repo by Mikolaj Kucharski
after I analysed the problem and proposed a different fix.
This commit is contained in:
sthen 2019-02-04 17:44:43 +00:00
parent b4dbebfb29
commit cf88f7778a
2 changed files with 57 additions and 2 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.26 2018/10/19 14:19:59 naddy Exp $
# $OpenBSD: Makefile,v 1.27 2019/02/04 17:44:43 sthen Exp $
COMMENT= text-based calendar and scheduling application
DISTNAME= calcurse-4.3.0
REVISION= 1
REVISION= 2
EPOCH= 0
CATEGORIES= productivity

View File

@ -0,0 +1,55 @@
$OpenBSD: patch-src_notify_c,v 1.1 2019/02/04 17:44:43 sthen Exp $
From 30f411257ad3bc233184c08b846a2980a9c5d1f0 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <lfleischer@calcurse.org>
Date: Sun, 3 Jun 2018 10:26:24 +0200
Subject: [PATCH] Do not stop already cancelled notification thread
Add a static state variable to indicate whether the notification thread
is already running or not. Only start the thread if the notification
thread is paused. Only stop the thread if the notification thread is
actually running.
Index: src/notify.c
--- src/notify.c.orig
+++ src/notify.c
@@ -55,6 +55,7 @@ static struct notify_vars notify;
static struct notify_app notify_app;
static pthread_attr_t detached_thread_attr;
static pthread_t notify_t_main;
+static int notify_t_main_running;
/*
* Return the number of seconds before next appointment
@@ -190,10 +191,12 @@ void notify_free_app(void)
/* Stop the notify-bar main thread. */
void notify_stop_main_thread(void)
{
- if (notify_t_main) {
- pthread_cancel(notify_t_main);
- pthread_join(notify_t_main, NULL);
- }
+ if (!notify_t_main_running)
+ return;
+
+ pthread_cancel(notify_t_main);
+ pthread_join(notify_t_main, NULL);
+ notify_t_main_running = 0;
}
/*
@@ -549,10 +552,12 @@ int notify_same_recur_item(struct recur_apoint *i)
/* Launch the notify-bar main thread. */
void notify_start_main_thread(void)
{
- /* Avoid starting the notification bar thread twice. */
- notify_stop_main_thread();
+ if (notify_t_main_running)
+ return;
pthread_create(&notify_t_main, NULL, notify_main_thread, NULL);
+ notify_t_main_running = 1;
+
notify_check_next_app(0);
}