summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-11-11 21:25:24 +0000
committerChris Toshok <toshok@src.gnome.org>2003-11-11 21:25:24 +0000
commit5e14258a9d30c6d7b88013a0066e208b7ea42291 (patch)
treee0e8aa31172639bd56c46e33f92222107c7235bc /src
parent78603c3a3ed08440efdf3054b741b5c6e899f487 (diff)
downloadevolution-data-server-5e14258a9d30c6d7b88013a0066e208b7ea42291.tar.gz
guard against multiple threads here by using a mutex. also, always remove
2003-11-11 Chris Toshok <toshok@ximian.com> * src/server.c (queue_termination): guard against multiple threads here by using a mutex. also, always remove the terminal_handler_id if one exists and reinstate it afterward. This gives us the behavior of always lasting EXIT_TIMEOUT milliseconds after the most recent book/calendar shutdown. Before there was a potential for shutting down EXIT_TIMEOUT milliseconds after the *first* book/calendar shutdown.
Diffstat (limited to 'src')
-rw-r--r--src/server.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/server.c b/src/server.c
index 1c974f2f9..12a04c62a 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1,8 +1,23 @@
-/* Server personal information server - main file
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* server.c
*
- * Author: Nat Friedman <nat@ximian.com>
+ * Copyright (C) 2000-2003, Ximian, Inc.
*
- * Copyright 2000, Ximian, Inc.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Nat Friedman (nat@ximian.com)
*/
#ifdef HAVE_CONFIG_H
@@ -58,6 +73,8 @@ static EDataBookFactory *e_data_book_factory;
/* Timeout ID for termination handler */
static guint termination_handler_id;
+static GStaticMutex termination_lock = G_STATIC_MUTEX_INIT;
+
/* Termination */
@@ -82,10 +99,12 @@ termination_handler (gpointer data)
static void
queue_termination (void)
{
+ g_static_mutex_lock (&termination_lock);
if (termination_handler_id)
- return;
+ g_source_remove (termination_handler_id);
termination_handler_id = g_timeout_add (EXIT_TIMEOUT, termination_handler, NULL);
+ g_static_mutex_unlock (&termination_lock);
}