[evolution-data-server/gnome-3-38] EReminderWatcher: Catch a race condition when creating a calendar view
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-38] EReminderWatcher: Catch a race condition when creating a calendar view
- Date: Tue, 5 Jan 2021 14:24:15 +0000 (UTC)
commit a044001c3c090e55e06905571f52730cb2f8e0c1
Author: Milan Crha <mcrha redhat com>
Date: Tue Jan 5 15:19:42 2021 +0100
EReminderWatcher: Catch a race condition when creating a calendar view
There could happen a race condition when the calendar had been removed
while the code had been waiting for a calendar view. This was not caught
properly, which could lead to certain issues.
src/calendar/libecal/CMakeLists.txt | 1 +
src/calendar/libecal/e-reminder-watcher.c | 19 +++++++++++++++++--
src/calendar/libecal/libecal.pc.in | 1 +
3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/libecal/CMakeLists.txt b/src/calendar/libecal/CMakeLists.txt
index 58cf6fc1a..00632844a 100644
--- a/src/calendar/libecal/CMakeLists.txt
+++ b/src/calendar/libecal/CMakeLists.txt
@@ -3,6 +3,7 @@ glib_mkenums(e-cal-enumtypes e-cal-enums.h E_CAL_ENUMTYPES_H)
add_pkgconfig_file(libecal.pc.in libecal-${CAL_API_VERSION}.pc)
set(DEPENDENCIES
+ camel
edbus-private
edataserver
)
diff --git a/src/calendar/libecal/e-reminder-watcher.c b/src/calendar/libecal/e-reminder-watcher.c
index c48bd4eb2..d6bbbd32f 100644
--- a/src/calendar/libecal/e-reminder-watcher.c
+++ b/src/calendar/libecal/e-reminder-watcher.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <glib/gi18n-lib.h>
+#include "camel/camel.h"
#include "libedataserver/libedataserver.h"
#include "e-cal-check-timezones.h"
@@ -48,6 +49,7 @@ typedef struct _ClientData {
EReminderWatcher *watcher; /* Just as an owner, not referenced */
ECalClient *client;
ECalClientView *view;
+ GCancellable *cancellable;
} ClientData;
struct _EReminderWatcherPrivate {
@@ -230,6 +232,7 @@ client_data_new (EReminderWatcher *watcher,
cd->watcher = watcher;
cd->client = client;
cd->view = NULL;
+ cd->cancellable = NULL;
return cd;
}
@@ -241,6 +244,11 @@ client_data_free_view (ClientData *cd)
g_return_if_fail (cd != NULL);
+ if (cd->cancellable) {
+ g_cancellable_cancel (cd->cancellable);
+ g_clear_object (&cd->cancellable);
+ }
+
if (!cd->view)
return;
@@ -384,7 +392,7 @@ client_data_view_created_cb (GObject *source_object,
if (!e_cal_client_get_view_finish (client, result, &view, &local_error) || local_error || !view) {
e_reminder_watcher_debug_print ("Failed to get view for %s: %s\n",
- e_source_get_uid (e_client_get_source (E_CLIENT (cd->client))),
+ e_source_get_uid (e_client_get_source (E_CLIENT (client))),
local_error ? local_error->message : "Unknown error");
} else {
cd->view = view;
@@ -446,7 +454,14 @@ client_data_start_view (ClientData *cd,
e_source_get_uid (e_client_get_source (E_CLIENT (cd->client))),
query);
- e_cal_client_get_view (cd->client, query, cancellable, client_data_view_created_cb, cd);
+ if (cd->cancellable) {
+ g_cancellable_cancel (cd->cancellable);
+ g_clear_object (&cd->cancellable);
+ }
+
+ cd->cancellable = camel_operation_new_proxy (cancellable);
+
+ e_cal_client_get_view (cd->client, query, cd->cancellable, client_data_view_created_cb, cd);
g_free (query);
}
diff --git a/src/calendar/libecal/libecal.pc.in b/src/calendar/libecal/libecal.pc.in
index a71e414f6..955ccd53d 100644
--- a/src/calendar/libecal/libecal.pc.in
+++ b/src/calendar/libecal/libecal.pc.in
@@ -10,5 +10,6 @@ Name: libecal
Description: Client library for evolution calendars
Version: @PROJECT_VERSION@
Requires: libical-glib libedataserver-@API_VERSION@
+Requires.private: camel-@API_VERSION@
Libs: -L${libdir} -lecal-@CAL_API_VERSION@
Cflags: -I${privincludedir}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]