Author: brane
Date: Mon Feb 2 15:24:16 2015
New Revision: 1656488
URL: http://svn.apache.org/r1656488
Log:
Introduce a private libsvn_client context structure that stores
context information that should not be part of the public API.
* subversion/include/svn_client.h
(svn_client_ctx_t): Remove the 'progress' field, which should be private.
* subversion/libsvn_client/client.h
(client_ctx_t): New; the private context struct.
Contains the equivalent of the 'progress' field.
(svn_client__get_private_ctx): New prototype.
* subversion/libsvn_client/ctx.c: Include stddef.h and client.h.
(CLIENT_CTX_MAGIC): New; magic number for the private context.
(svn_client__get_private_ctx): Implement.
(svn_client_create_context2): Allocate and initialize the private
context structure, with the public context embedded within it.
* subversion/libsvn_client/ra.c
(progress_func): Use the total progress counter from the private context.
Modified:
subversion/trunk/subversion/include/svn_client.h
subversion/trunk/subversion/libsvn_client/client.h
subversion/trunk/subversion/libsvn_client/ctx.c
subversion/trunk/subversion/libsvn_client/ra.c
Modified: subversion/trunk/subversion/include/svn_client.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1656488&r1=1656487&r2=1656488&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Mon Feb 2 15:24:16 2015
@@ -1020,11 +1020,6 @@ typedef struct svn_client_ctx_t
* @since New in 1.7. */
svn_wc_context_t *wc_ctx;
- /** Total number of bytes transferred over network.
- *
- * @since New in 1.9. */
- apr_off_t progress;
-
/** Check-tunnel callback
*
* If not @c NULL, and open_tunnel_func is also not @c NULL, this
Modified: subversion/trunk/subversion/libsvn_client/client.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1656488&r1=1656487&r2=1656488&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Mon Feb 2 15:24:16 2015
@@ -45,6 +45,35 @@
extern "C" {
#endif /* __cplusplus */
+
+/* Private client context.
+ *
+ * This is what is actually allocated by svn_client_create_context2(),
+ * which then returns the address of the public_ctx member. */
+typedef struct client_ctx_t
+{
+ /* Reserved field, always zero, to detect misuse of the private
+ context as a public client context. */
+ apr_uint64_t magic_null;
+
+ /* Reserved field, always set to a known magic number, to identify
+ this struct as the private client context. */
+ apr_uint64_t magic_id;
+
+ /* Total number of bytes transferred over network across all RA sessions. */
+ apr_off_t total_progress;
+
+ /* The public context. */
+ svn_client_ctx_t public_ctx;
+} client_ctx_t;
+
+
+/* Given a public client context CTX, return the private context
+ within which it is allocated. */
+client_ctx_t *
+svn_client__get_private_ctx(svn_client_ctx_t *ctx);
+
+
/* Set *REVNUM to the revision number identified by REVISION.
If REVISION->kind is svn_opt_revision_number, just use
Modified: subversion/trunk/subversion/libsvn_client/ctx.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ctx.c?rev=1656488&r1=1656487&r2=1656488&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ctx.c (original)
+++ subversion/trunk/subversion/libsvn_client/ctx.c Mon Feb 2 15:24:16 2015
@@ -27,6 +27,7 @@
/*** Includes. ***/
+#include <stddef.h>
#include <apr_pools.h>
#include "svn_hash.h"
#include "svn_client.h"
@@ -34,6 +35,8 @@
#include "private/svn_wc_private.h"
+#include "client.h"
+
/*** Code. ***/
@@ -76,6 +79,20 @@ call_conflict_func(svn_wc_conflict_resul
return SVN_NO_ERROR;
}
+/* The magic number in client_ctx_t.magic_id. */
+#define CLIENT_CTX_MAGIC APR_UINT64_C(0xDEADBEEF600DF00D)
+
+client_ctx_t *
+svn_client__get_private_ctx(svn_client_ctx_t *ctx)
+{
+ client_ctx_t *const private_ctx =
+ (void*)((char *)ctx - offsetof(client_ctx_t, public_ctx));
+ SVN_ERR_ASSERT_NO_RETURN(&private_ctx->public_ctx == ctx);
+ SVN_ERR_ASSERT_NO_RETURN(0 == private_ctx->magic_null);
+ SVN_ERR_ASSERT_NO_RETURN(CLIENT_CTX_MAGIC == private_ctx->magic_id);
+ return private_ctx;
+}
+
svn_error_t *
svn_client_create_context2(svn_client_ctx_t **ctx,
apr_hash_t *cfg_hash,
@@ -83,23 +100,28 @@ svn_client_create_context2(svn_client_ct
{
svn_config_t *cfg_config;
- *ctx = apr_pcalloc(pool, sizeof(svn_client_ctx_t));
+ client_ctx_t *const private_ctx = apr_pcalloc(pool, sizeof(*private_ctx));
+ svn_client_ctx_t *const public_ctx = &private_ctx->public_ctx;
+
+ private_ctx->magic_null = 0;
+ private_ctx->magic_id = CLIENT_CTX_MAGIC;
- (*ctx)->notify_func2 = call_notify_func;
- (*ctx)->notify_baton2 = *ctx;
+ public_ctx->notify_func2 = call_notify_func;
+ public_ctx->notify_baton2 = public_ctx;
- (*ctx)->conflict_func2 = call_conflict_func;
- (*ctx)->conflict_baton2 = *ctx;
+ public_ctx->conflict_func2 = call_conflict_func;
+ public_ctx->conflict_baton2 = public_ctx;
- (*ctx)->config = cfg_hash;
+ public_ctx->config = cfg_hash;
if (cfg_hash)
cfg_config = svn_hash_gets(cfg_hash, SVN_CONFIG_CATEGORY_CONFIG);
else
cfg_config = NULL;
- SVN_ERR(svn_wc_context_create(&(*ctx)->wc_ctx, cfg_config, pool,
- pool));
+ SVN_ERR(svn_wc_context_create(&public_ctx->wc_ctx, cfg_config,
+ pool, pool));
+ *ctx = public_ctx;
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1656488&r1=1656487&r2=1656488&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Mon Feb 2 15:24:16 2015
@@ -299,17 +299,19 @@ progress_func(apr_off_t progress,
apr_pool_t *pool)
{
callback_baton_t *b = baton;
- svn_client_ctx_t *ctx = b->ctx;
+ svn_client_ctx_t *public_ctx = b->ctx;
+ client_ctx_t *private_ctx = svn_client__get_private_ctx(public_ctx);
- ctx->progress += (progress - b->last_progress);
+ private_ctx->total_progress += (progress - b->last_progress);
b->last_progress = progress;
- if (ctx->progress_func)
+ if (public_ctx->progress_func)
{
/* All RA implementations currently provide -1 for total. So it doesn't
make sense to develop some complex logic to combine total across all
RA sessions. */
- ctx->progress_func(ctx->progress, -1, ctx->progress_baton, pool);
+ public_ctx->progress_func(private_ctx->total_progress, -1,
+ public_ctx->progress_baton, pool);
}
}