gnome-keyring r1392 - in trunk: . gp11
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-keyring r1392 - in trunk: . gp11
- Date: Wed, 17 Dec 2008 19:55:49 +0000 (UTC)
Author: nnielsen
Date: Wed Dec 17 19:55:48 2008
New Revision: 1392
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1392&view=rev
Log:
* gp11/gp11-call.c: There was a problem when the main loop
wasn't being run for periods of time, things would backup.
Now we process a result for every async call we make.
* gp11/gp11-object.c:
* gp11/gp11-slot.c: Object lifetime fixes.
Modified:
trunk/ChangeLog
trunk/gp11/gp11-call.c
trunk/gp11/gp11-object.c
trunk/gp11/gp11-slot.c
Modified: trunk/gp11/gp11-call.c
==============================================================================
--- trunk/gp11/gp11-call.c (original)
+++ trunk/gp11/gp11-call.c Wed Dec 17 19:55:48 2008
@@ -139,6 +139,23 @@
}
static gboolean
+process_completed (void)
+{
+ gpointer call;
+
+ g_assert (completed_queue);
+
+ call = g_async_queue_try_pop (completed_queue);
+ if (call) {
+ process_result (call, NULL);
+ g_object_unref (call);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
completed_prepare(GSource* source, gint *timeout)
{
gboolean have;
@@ -158,17 +175,7 @@
static gboolean
completed_dispatch(GSource* source, GSourceFunc callback, gpointer user_data)
{
- gpointer *call;
-
- g_assert (completed_queue);
- g_assert (callback);
-
- call = g_async_queue_try_pop (completed_queue);
- if (call) {
- ((GFunc)callback) (call, user_data);
- g_object_unref (call);
- }
-
+ process_completed ();
return TRUE;
}
@@ -253,7 +260,7 @@
gobject_class->finalize = _gp11_call_finalize;
g_assert (!thread_pool);
- thread_pool = g_thread_pool_new ((GFunc)process_async_call, NULL, -1, FALSE, &err);
+ thread_pool = g_thread_pool_new ((GFunc)process_async_call, NULL, 16, FALSE, &err);
if (!thread_pool) {
g_critical ("couldn't create thread pool: %s",
err && err->message ? err->message : "");
@@ -271,7 +278,7 @@
g_assert (!completed_id);
src = g_source_new (&completed_functions, sizeof (GSource));
completed_id = g_source_attach (src, context);
- g_source_set_callback (src, (GSourceFunc)process_result, NULL, NULL);
+ g_source_set_callback (src, NULL, NULL, NULL);
g_source_unref (src);
}
@@ -429,7 +436,10 @@
{
g_assert (GP11_IS_CALL (call));
g_assert (call->args->pkcs11);
-
+
+ /* To keep things balanced, process at one completed event */
+ process_completed();
+
g_assert (thread_pool);
g_thread_pool_push (thread_pool, call, NULL);
}
Modified: trunk/gp11/gp11-object.c
==============================================================================
--- trunk/gp11/gp11-object.c (original)
+++ trunk/gp11/gp11-object.c Wed Dec 17 19:55:48 2008
@@ -49,7 +49,8 @@
g_assert (GP11_IS_SESSION (session));
/* Hold onto this session for the length of the call */
- g_object_set_data_full (G_OBJECT (call), "call-opened-session", session, g_object_unref);
+ g_object_set_data_full (G_OBJECT (call), "call-opened-session",
+ g_object_ref (session), g_object_unref);
_gp11_call_async_object (call, session);
_gp11_call_async_go (call);
@@ -71,9 +72,11 @@
if (!session) {
_gp11_call_async_short (user_data, err->code);
g_error_free (err);
+ return;
}
run_call_with_session (GP11_CALL (user_data), session);
+ g_object_unref (session);
}
static void
Modified: trunk/gp11/gp11-slot.c
==============================================================================
--- trunk/gp11/gp11-slot.c (original)
+++ trunk/gp11/gp11-slot.c Wed Dec 17 19:55:48 2008
@@ -200,7 +200,9 @@
result = g_array_index (pool->sessions, CK_SESSION_HANDLE, pool->sessions->len - 1);
g_assert (result != 0);
g_array_remove_index_fast (pool->sessions, pool->sessions->len - 1);
-
+ if (!pool->sessions->len)
+ g_hash_table_remove(pv->open_sessions, &flags);
+
return result;
}
@@ -272,12 +274,15 @@
*/
flags = g_object_get_data (G_OBJECT (session), "gp11-open-session-flags");
g_return_if_fail (flags);
- if ((*flags & info.flags) != *flags)
+ if ((*flags & info.flags) != *flags) {
+g_message ("discarding session, wrong flags");
return;
+ }
/* Keep this one around for later use */
push_session_table (slot, *flags, session->handle);
session->handle = 0;
+g_message ("keeping the session for reuse");
}
static GP11Session*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]