Author: svn-role
Date: Thu Nov 27 04:00:36 2014
New Revision: 1642023
URL: http://svn.apache.org/r1642023
Log:
Merge the r1386594 group from trunk:
* r1386594, 1386601, 1640730
Use sync Gnome Keyring API as our use of the async is not thread safe.
Justification:
Fix issue 3498: eclipse IDE crashes.
Notes:
r1640730 is the fix, r1386594 and r1386601 to avoid conflict.
Votes:
+1: philip, markphip
+1: rhuijben (unable to test, but fix looks sane and simplifies code)
Modified:
subversion/branches/1.7.x/ (props changed)
subversion/branches/1.7.x/STATUS
subversion/branches/1.7.x/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
Propchange: subversion/branches/1.7.x/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1386594,1386601,1640730
Modified: subversion/branches/1.7.x/STATUS
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x/STATUS?rev=1642023&r1=1642022&r2=1642023&view=diff
==============================================================================
--- subversion/branches/1.7.x/STATUS (original)
+++ subversion/branches/1.7.x/STATUS Thu Nov 27 04:00:36 2014
@@ -154,13 +154,3 @@ Veto-blocked changes:
Approved changes:
=================
-
- * r1386594, 1386601, 1640730
- Use sync Gnome Keyring API as our use of the async is not thread safe.
- Justification:
- Fix issue 3498: eclipse IDE crashes.
- Notes:
- r1640730 is the fix, r1386594 and r1386601 to avoid conflict.
- Votes:
- +1: philip, markphip
- +1: rhuijben (unable to test, but fix looks sane and simplifies code)
Modified:
subversion/branches/1.7.x/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c?rev=1642023&r1=1642022&r2=1642023&view=diff
==============================================================================
---
subversion/branches/1.7.x/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
(original)
+++
subversion/branches/1.7.x/subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
Thu Nov 27 04:00:36 2014
@@ -28,6 +28,7 @@
/*** Includes. ***/
#include <apr_pools.h>
+#include <apr_strings.h>
#include "svn_auth.h"
#include "svn_config.h"
#include "svn_error.h"
@@ -46,120 +47,19 @@
/*-----------------------------------------------------------------------*/
-struct gnome_keyring_baton
-{
- const char *keyring_name;
- GnomeKeyringInfo *info;
- GMainLoop *loop;
-};
-
-
-/* Callback function to destroy gnome_keyring_baton. */
-static void
-callback_destroy_data_keyring(void *data)
-{
- struct gnome_keyring_baton *key_info = data;
-
- if (data == NULL)
- return;
-
- free((void*)key_info->keyring_name);
- key_info->keyring_name = NULL;
-
- if (key_info->info)
- {
- gnome_keyring_info_free(key_info->info);
- key_info->info = NULL;
- }
-
- return;
-}
-
-
-/* Callback function to complete the keyring operation. */
-static void
-callback_done(GnomeKeyringResult result,
- gpointer data)
-{
- struct gnome_keyring_baton *key_info = data;
-
- g_main_loop_quit(key_info->loop);
- return;
-}
-
-
-/* Callback function to get the keyring info. */
-static void
-callback_get_info_keyring(GnomeKeyringResult result,
- GnomeKeyringInfo *info,
- void *data)
-{
- struct gnome_keyring_baton *key_info = data;
-
- if (result == GNOME_KEYRING_RESULT_OK && info != NULL)
- {
- key_info->info = gnome_keyring_info_copy(info);
- }
- else
- {
- if (key_info->info != NULL)
- gnome_keyring_info_free(key_info->info);
-
- key_info->info = NULL;
- }
-
- g_main_loop_quit(key_info->loop);
-
- return;
-}
-
-
-/* Callback function to get the default keyring string name. */
-static void
-callback_default_keyring(GnomeKeyringResult result,
- const char *string,
- void *data)
-{
- struct gnome_keyring_baton *key_info = data;
-
- if (result == GNOME_KEYRING_RESULT_OK && string != NULL)
- {
- key_info->keyring_name = strdup(string);
- }
- else
- {
- free((void*)key_info->keyring_name);
- key_info->keyring_name = NULL;
- }
-
- g_main_loop_quit(key_info->loop);
-
- return;
-}
-
-/* Returns the default keyring name. */
+/* Returns the default keyring name, allocated in RESULT_POOL. */
static char*
-get_default_keyring_name(apr_pool_t *pool)
+get_default_keyring_name(apr_pool_t *result_pool)
{
- char *def = NULL;
- struct gnome_keyring_baton key_info;
-
- key_info.info = NULL;
- key_info.keyring_name = NULL;
+ char *name, *def;
+ GnomeKeyringResult gkr;
- /* Finds default keyring. */
- key_info.loop = g_main_loop_new(NULL, FALSE);
- gnome_keyring_get_default_keyring(callback_default_keyring, &key_info, NULL);
- g_main_loop_run(key_info.loop);
+ gkr = gnome_keyring_get_default_keyring_sync(&name);
+ if (gkr != GNOME_KEYRING_RESULT_OK)
+ return NULL;
- if (key_info.keyring_name == NULL)
- {
- callback_destroy_data_keyring(&key_info);
- return NULL;
- }
-
- def = strdup(key_info.keyring_name);
- callback_destroy_data_keyring(&key_info);
+ def = apr_pstrdup(result_pool, name);
+ g_free(name);
return def;
}
@@ -168,28 +68,22 @@ get_default_keyring_name(apr_pool_t *poo
static svn_boolean_t
check_keyring_is_locked(const char *keyring_name)
{
- struct gnome_keyring_baton key_info;
+ GnomeKeyringInfo *info;
+ svn_boolean_t locked;
+ GnomeKeyringResult gkr;
- key_info.info = NULL;
- key_info.keyring_name = NULL;
+ gkr = gnome_keyring_get_info_sync(keyring_name, &info);
+ if (gkr != GNOME_KEYRING_RESULT_OK)
+ return FALSE;
- /* Get details about the default keyring. */
- key_info.loop = g_main_loop_new(NULL, FALSE);
- gnome_keyring_get_info(keyring_name, callback_get_info_keyring, &key_info,
- NULL);
- g_main_loop_run(key_info.loop);
+ if (gnome_keyring_info_get_is_locked(info))
+ locked = TRUE;
+ else
+ locked = FALSE;
- if (key_info.info == NULL)
- {
- callback_destroy_data_keyring(&key_info);
- return FALSE;
- }
+ gnome_keyring_info_free(info);
- /* Check if keyring is locked. */
- if (gnome_keyring_info_get_is_locked(key_info.info))
- return TRUE;
- else
- return FALSE;
+ return locked;
}
/* Unlock the KEYRING_NAME with the KEYRING_PASSWORD. If KEYRING was
@@ -199,34 +93,19 @@ unlock_gnome_keyring(const char *keyring
const char *keyring_password,
apr_pool_t *pool)
{
- struct gnome_keyring_baton key_info;
-
- key_info.info = NULL;
- key_info.keyring_name = NULL;
+ GnomeKeyringInfo *info;
+ GnomeKeyringResult gkr;
- /* Get details about the default keyring. */
- key_info.loop = g_main_loop_new(NULL, FALSE);
- gnome_keyring_get_info(keyring_name, callback_get_info_keyring,
- &key_info, NULL);
- g_main_loop_run(key_info.loop);
+ gkr = gnome_keyring_get_info_sync(keyring_name, &info);
+ if (gkr != GNOME_KEYRING_RESULT_OK)
+ return FALSE;
- if (key_info.info == NULL)
- {
- callback_destroy_data_keyring(&key_info);
- return FALSE;
- }
- else
- {
- key_info.loop = g_main_loop_new(NULL, FALSE);
- gnome_keyring_unlock(keyring_name, keyring_password,
- callback_done, &key_info, NULL);
- g_main_loop_run(key_info.loop);
- }
- callback_destroy_data_keyring(&key_info);
- if (check_keyring_is_locked(keyring_name))
+ gkr = gnome_keyring_unlock_sync(keyring_name, keyring_password);
+ gnome_keyring_info_free(info);
+ if (gkr != GNOME_KEYRING_RESULT_OK)
return FALSE;
- return TRUE;
+ return check_keyring_is_locked(keyring_name);
}