summaryrefslogtreecommitdiff
path: root/source3/modules/perfcount_test.c
diff options
context:
space:
mode:
authortodd stecher <todd.stecher@gmail.com>2009-02-16 20:45:45 -0800
committerTim Prouty <tprouty@samba.org>2009-02-19 00:01:00 -0800
commitfdcd5a3a201489b1408951936e9bfc0871834a29 (patch)
tree36482aea6ef62202e1e2cb37416838fd4f7d5f6f /source3/modules/perfcount_test.c
parent6bac890533112e6c4f853c0b77a9dd431c471cee (diff)
downloadsamba-fdcd5a3a201489b1408951936e9bfc0871834a29.tar.gz
samba-fdcd5a3a201489b1408951936e9bfc0871834a29.tar.bz2
samba-fdcd5a3a201489b1408951936e9bfc0871834a29.zip
S3: Make changes to perfcount API set for when a single request leads to multiple replies
(e.g. reply_echo). Change test and onefs modules to match new api set (thanks Volker!).
Diffstat (limited to 'source3/modules/perfcount_test.c')
-rw-r--r--source3/modules/perfcount_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/source3/modules/perfcount_test.c b/source3/modules/perfcount_test.c
index b140172af4..418d83ace5 100644
--- a/source3/modules/perfcount_test.c
+++ b/source3/modules/perfcount_test.c
@@ -294,6 +294,52 @@ static void perfcount_test_set_msglen_out(struct smb_perfcount_data *pcd,
ctxt->ops->bytes_out = bytes_out;
}
+static void perfcount_test_copy_context(struct smb_perfcount_data *pcd,
+ struct smb_perfcount_data *new_pcd)
+{
+ struct perfcount_test_context *ctxt =
+ (struct perfcount_test_context *)pcd->context;
+ struct perfcount_test_context *new_ctxt;
+
+ struct perfcount_test_counter *ctr;
+ struct perfcount_test_counter *new_ctr;
+
+ if (pcd->context == NULL)
+ return;
+
+ new_ctxt = SMB_MALLOC_P(struct perfcount_test_context);
+ if (!new_ctxt) {
+ return;
+ }
+
+ memcpy(new_ctxt, ctxt, sizeof(struct perfcount_test_context));
+
+ for (ctr = ctxt->ops; ctr != NULL; ctr = ctr->next) {
+ new_ctr = SMB_MALLOC_P(struct perfcount_test_counter);
+ if (!new_ctr) {
+ goto error;
+ }
+
+ memcpy(new_ctr, ctr, sizeof(struct perfcount_test_counter));
+ new_ctr->next = NULL;
+ new_ctr->prev = NULL;
+ DLIST_ADD(new_ctxt->ops, new_ctr);
+ }
+
+ new_pcd->context = new_ctxt;
+ return;
+
+error:
+
+ for (ctr = new_ctxt->ops; ctr != NULL; ) {
+ new_ctr = ctr->next;
+ SAFE_FREE(ctr);
+ ctr = new_ctr;
+ }
+
+ SAFE_FREE(new_ctxt);
+}
+
/*
* For perf reasons, its best to use some global state
* when an operation is deferred, we need to alloc a copy.
@@ -337,6 +383,7 @@ static struct smb_perfcount_handlers perfcount_test_handlers = {
perfcount_test_set_msglen_in,
perfcount_test_set_msglen_out,
perfcount_test_set_client,
+ perfcount_test_copy_context,
perfcount_test_defer_op,
perfcount_test_end
};