trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject trafficserver git commit: TS-4261: Split stats API from process API.
Date Thu, 17 Mar 2016 04:30:49 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master 63e3b2db9 -> dfd977699


TS-4261: Split stats API from process API.

This is useful for TS-4260 as noted in the related bugs. As part
of that work I set up some statistics to track the performance of
the event loop. Without this change doing that requires bringing
all of the process management support in to the event loop component
which is problematic. It seemed much simpler and better overall to
just split those unrelated items apart.

This closes #516.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/dfd97769
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/dfd97769
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/dfd97769

Branch: refs/heads/master
Commit: dfd9776990a6cf04385e5e315c277f2dad3f01d8
Parents: 63e3b2d
Author: Alan M. Carroll <amc@apache.org>
Authored: Sun Mar 6 14:49:30 2016 -0600
Committer: James Peach <jpeach@apache.org>
Committed: Wed Mar 16 21:20:05 2016 -0700

----------------------------------------------------------------------
 lib/records/I_RecProcess.h |   2 +
 lib/records/Makefile.am    |   1 +
 lib/records/P_RecProcess.h |   2 -
 lib/records/RecProcess.cc  | 577 -------------------------------------
 lib/records/RecRawStats.cc | 614 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 617 insertions(+), 579 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfd97769/lib/records/I_RecProcess.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecProcess.h b/lib/records/I_RecProcess.h
index dd1e08d..6b08df1 100644
--- a/lib/records/I_RecProcess.h
+++ b/lib/records/I_RecProcess.h
@@ -73,6 +73,8 @@ int RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData
*data,
 int RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecData *data,
RecRawStatBlock *rsb, int id);
 int RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock
*rsb, int id);
 
+int RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock
*rsb, int id);
+int RecRawStatUpdateSum(RecRawStatBlock* rsb, int id);
 
 //-------------------------------------------------------------------------
 // RawStat Setting/Getting

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfd97769/lib/records/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/records/Makefile.am b/lib/records/Makefile.am
index 2306d48..f6a9c2e 100644
--- a/lib/records/Makefile.am
+++ b/lib/records/Makefile.am
@@ -48,6 +48,7 @@ librecords_COMMON = \
   RecHttp.cc \
   RecMessage.cc \
   RecMutex.cc \
+  RecRawStats.cc \
   RecUtils.cc
 
 librecords_lm_a_SOURCES = \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfd97769/lib/records/P_RecProcess.h
----------------------------------------------------------------------
diff --git a/lib/records/P_RecProcess.h b/lib/records/P_RecProcess.h
index b271188..8c4fe14 100644
--- a/lib/records/P_RecProcess.h
+++ b/lib/records/P_RecProcess.h
@@ -37,8 +37,6 @@
 // Protected Interface
 //-------------------------------------------------------------------------
 
-int RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock
*rsb, int id);
-
 int RecExecRawStatSyncCbs();
 
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfd97769/lib/records/RecProcess.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecProcess.cc b/lib/records/RecProcess.cc
index ed95d6d..e92bd7d 100644
--- a/lib/records/RecProcess.cc
+++ b/lib/records/RecProcess.cc
@@ -120,197 +120,6 @@ RecProcess_set_remote_sync_interval_ms(int ms)
 }
 
 //-------------------------------------------------------------------------
-// raw_stat_get_total
-//-------------------------------------------------------------------------
-static int
-raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total)
-{
-  int i;
-  RecRawStat *tlp;
-
-  total->sum = 0;
-  total->count = 0;
-
-  // get global values
-  total->sum = rsb->global[id]->sum;
-  total->count = rsb->global[id]->count;
-
-  // get thread local values
-  for (i = 0; i < eventProcessor.n_ethreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
-    total->sum += tlp->sum;
-    total->count += tlp->count;
-  }
-
-  for (i = 0; i < eventProcessor.n_dthreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
-    total->sum += tlp->sum;
-    total->count += tlp->count;
-  }
-
-  if (total->sum < 0) { // Assure that we stay positive
-    total->sum = 0;
-  }
-
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// raw_stat_sync_to_global
-//-------------------------------------------------------------------------
-static int
-raw_stat_sync_to_global(RecRawStatBlock *rsb, int id)
-{
-  int i;
-  RecRawStat *tlp;
-  RecRawStat total;
-
-  total.sum = 0;
-  total.count = 0;
-
-  // sum the thread local values
-  for (i = 0; i < eventProcessor.n_ethreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
-    total.sum += tlp->sum;
-    total.count += tlp->count;
-  }
-
-  for (i = 0; i < eventProcessor.n_dthreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
-    total.sum += tlp->sum;
-    total.count += tlp->count;
-  }
-
-  if (total.sum < 0) { // Assure that we stay positive
-    total.sum = 0;
-  }
-
-  // lock so the setting of the globals and last values are atomic
-  ink_mutex_acquire(&(rsb->mutex));
-
-  // get the delta from the last sync
-  RecRawStat delta;
-  delta.sum = total.sum - rsb->global[id]->last_sum;
-  delta.count = total.count - rsb->global[id]->last_count;
-
-  // This is too verbose now, so leaving it out / leif
-  // Debug("stats", "raw_stat_sync_to_global(): rsb pointer:%p id:%d delta:%" PRId64 " total:%"
PRId64 " last:%" PRId64 " global:%"
-  // PRId64 "\n",
-  // rsb, id, delta.sum, total.sum, rsb->global[id]->last_sum, rsb->global[id]->sum);
-
-  // increment the global values by the delta
-  ink_atomic_increment(&(rsb->global[id]->sum), delta.sum);
-  ink_atomic_increment(&(rsb->global[id]->count), delta.count);
-
-  // set the new totals as the last values seen
-  ink_atomic_swap(&(rsb->global[id]->last_sum), total.sum);
-  ink_atomic_swap(&(rsb->global[id]->last_count), total.count);
-
-  ink_mutex_release(&(rsb->mutex));
-
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// raw_stat_clear
-//-------------------------------------------------------------------------
-static int
-raw_stat_clear(RecRawStatBlock *rsb, int id)
-{
-  Debug("stats", "raw_stat_clear(): rsb pointer:%p id:%d\n", rsb, id);
-
-  // the globals need to be reset too
-  // lock so the setting of the globals and last values are atomic
-  ink_mutex_acquire(&(rsb->mutex));
-  ink_atomic_swap(&(rsb->global[id]->sum), (int64_t)0);
-  ink_atomic_swap(&(rsb->global[id]->last_sum), (int64_t)0);
-  ink_atomic_swap(&(rsb->global[id]->count), (int64_t)0);
-  ink_atomic_swap(&(rsb->global[id]->last_count), (int64_t)0);
-  ink_mutex_release(&(rsb->mutex));
-
-  // reset the local stats
-  RecRawStat *tlp;
-  for (int i = 0; i < eventProcessor.n_ethreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
-    ink_atomic_swap(&(tlp->sum), (int64_t)0);
-    ink_atomic_swap(&(tlp->count), (int64_t)0);
-  }
-
-  for (int i = 0; i < eventProcessor.n_dthreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
-    ink_atomic_swap(&(tlp->sum), (int64_t)0);
-    ink_atomic_swap(&(tlp->count), (int64_t)0);
-  }
-
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// raw_stat_clear_sum
-//-------------------------------------------------------------------------
-static int
-raw_stat_clear_sum(RecRawStatBlock *rsb, int id)
-{
-  Debug("stats", "raw_stat_clear_sum(): rsb pointer:%p id:%d\n", rsb, id);
-
-  // the globals need to be reset too
-  // lock so the setting of the globals and last values are atomic
-  ink_mutex_acquire(&(rsb->mutex));
-  ink_atomic_swap(&(rsb->global[id]->sum), (int64_t)0);
-  ink_atomic_swap(&(rsb->global[id]->last_sum), (int64_t)0);
-  ink_mutex_release(&(rsb->mutex));
-
-  // reset the local stats
-  RecRawStat *tlp;
-  for (int i = 0; i < eventProcessor.n_ethreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
-    ink_atomic_swap(&(tlp->sum), (int64_t)0);
-  }
-
-  for (int i = 0; i < eventProcessor.n_dthreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
-    ink_atomic_swap(&(tlp->sum), (int64_t)0);
-  }
-
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// raw_stat_clear_count
-//-------------------------------------------------------------------------
-static int
-raw_stat_clear_count(RecRawStatBlock *rsb, int id)
-{
-  Debug("stats", "raw_stat_clear_count(): rsb pointer:%p id:%d\n", rsb, id);
-
-  // the globals need to be reset too
-  // lock so the setting of the globals and last values are atomic
-  ink_mutex_acquire(&(rsb->mutex));
-  ink_atomic_swap(&(rsb->global[id]->count), (int64_t)0);
-  ink_atomic_swap(&(rsb->global[id]->last_count), (int64_t)0);
-  ink_mutex_release(&(rsb->mutex));
-
-  // reset the local stats
-  RecRawStat *tlp;
-  for (int i = 0; i < eventProcessor.n_ethreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
-    ink_atomic_swap(&(tlp->count), (int64_t)0);
-  }
-
-  for (int i = 0; i < eventProcessor.n_dthreads; i++) {
-    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
-    ink_atomic_swap(&(tlp->count), (int64_t)0);
-  }
-
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
 // recv_message_cb__process
 //-------------------------------------------------------------------------
 static int
@@ -515,392 +324,6 @@ RecProcessStart(void)
 }
 
 
-//-------------------------------------------------------------------------
-// RecAllocateRawStatBlock
-//-------------------------------------------------------------------------
-RecRawStatBlock *
-RecAllocateRawStatBlock(int num_stats)
-{
-  off_t ethr_stat_offset;
-  RecRawStatBlock *rsb;
-
-  // allocate thread-local raw-stat memory
-  if ((ethr_stat_offset = eventProcessor.allocate(num_stats * sizeof(RecRawStat))) == -1)
{
-    return NULL;
-  }
-  // create the raw-stat-block structure
-  rsb = (RecRawStatBlock *)ats_malloc(sizeof(RecRawStatBlock));
-  memset(rsb, 0, sizeof(RecRawStatBlock));
-  rsb->ethr_stat_offset = ethr_stat_offset;
-  rsb->global = (RecRawStat **)ats_malloc(num_stats * sizeof(RecRawStat *));
-  memset(rsb->global, 0, num_stats * sizeof(RecRawStat *));
-  rsb->num_stats = 0;
-  rsb->max_stats = num_stats;
-  ink_mutex_init(&(rsb->mutex), "net stat mutex");
-  return rsb;
-}
-
-
-//-------------------------------------------------------------------------
-// RecRegisterRawStat
-//-------------------------------------------------------------------------
-int
-_RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type,
RecPersistT persist_type, int id,
-                    RecRawStatSyncCb sync_cb)
-{
-  Debug("stats", "RecRawStatSyncCb(%s): rsb pointer:%p id:%d\n", name, rsb, id);
-
-  // check to see if we're good to proceed
-  ink_assert(id < rsb->max_stats);
-
-  int err = REC_ERR_OKAY;
-
-  RecRecord *r;
-  RecData data_default;
-  memset(&data_default, 0, sizeof(RecData));
-
-  // register the record
-  if ((r = RecRegisterStat(rec_type, name, data_type, data_default, persist_type)) == NULL)
{
-    err = REC_ERR_FAIL;
-    goto Ldone;
-  }
-  r->rsb_id = id; // This is the index within the RSB raw block for this stat, used for
lookups by name.
-  if (i_am_the_record_owner(r->rec_type)) {
-    r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED;
-  } else {
-    send_register_message(r);
-  }
-
-  // store a pointer to our record->stat_meta.data_raw in our rsb
-  rsb->global[id] = &(r->stat_meta.data_raw);
-  rsb->global[id]->last_sum = 0;
-  rsb->global[id]->last_count = 0;
-
-  // setup the periodic sync callback
-  RecRegisterRawStatSyncCb(name, sync_cb, rsb, id);
-
-Ldone:
-  return err;
-}
-
-
-//-------------------------------------------------------------------------
-// RecRawStatSync...
-//-------------------------------------------------------------------------
-
-// Note: On these RecRawStatSync callbacks, our 'data' is protected
-// under its lock by the caller, so no need to worry!
-int
-RecRawStatSyncSum(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb,
int id)
-{
-  RecRawStat total;
-
-  Debug("stats", "raw sync:sum for %s", name);
-  raw_stat_sync_to_global(rsb, id);
-  total.sum = rsb->global[id]->sum;
-  total.count = rsb->global[id]->count;
-  RecDataSetFromInk64(data_type, data, total.sum);
-
-  return REC_ERR_OKAY;
-}
-
-int
-RecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock
*rsb, int id)
-{
-  RecRawStat total;
-
-  Debug("stats", "raw sync:count for %s", name);
-  raw_stat_sync_to_global(rsb, id);
-  total.sum = rsb->global[id]->sum;
-  total.count = rsb->global[id]->count;
-  RecDataSetFromInk64(data_type, data, total.count);
-
-  return REC_ERR_OKAY;
-}
-
-int
-RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb,
int id)
-{
-  RecRawStat total;
-  RecFloat avg = 0.0f;
-
-  Debug("stats", "raw sync:avg for %s", name);
-  raw_stat_sync_to_global(rsb, id);
-  total.sum = rsb->global[id]->sum;
-  total.count = rsb->global[id]->count;
-  if (total.count != 0)
-    avg = (float)((double)total.sum / (double)total.count);
-  RecDataSetFromFloat(data_type, data, avg);
-  return REC_ERR_OKAY;
-}
-
-int
-RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock
*rsb, int id)
-{
-  RecRawStat total;
-  RecFloat r;
-
-  Debug("stats", "raw sync:hr-timeavg for %s", name);
-  raw_stat_sync_to_global(rsb, id);
-  total.sum = rsb->global[id]->sum;
-  total.count = rsb->global[id]->count;
-  if (total.count == 0) {
-    r = 0.0f;
-  } else {
-    r = (float)((double)total.sum / (double)total.count);
-    r = r / (float)(HRTIME_SECOND);
-  }
-  RecDataSetFromFloat(data_type, data, r);
-  return REC_ERR_OKAY;
-}
-
-int
-RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecData *data,
RecRawStatBlock *rsb, int id)
-{
-  RecRawStat total;
-  RecFloat r;
-
-  Debug("stats", "raw sync:seconds for %s", name);
-  raw_stat_sync_to_global(rsb, id);
-  total.sum = rsb->global[id]->sum;
-  total.count = rsb->global[id]->count;
-  if (total.count == 0) {
-    r = 0.0f;
-  } else {
-    r = (float)((double)total.sum / 1000);
-  }
-  RecDataSetFromFloat(data_type, data, r);
-  return REC_ERR_OKAY;
-}
-
-int
-RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock
*rsb, int id)
-{
-  RecRawStat total;
-  RecFloat r;
-
-  Debug("stats", "raw sync:mhr-timeavg for %s", name);
-  raw_stat_sync_to_global(rsb, id);
-  total.sum = rsb->global[id]->sum;
-  total.count = rsb->global[id]->count;
-  if (total.count == 0) {
-    r = 0.0f;
-  } else {
-    r = (float)((double)total.sum / (double)total.count);
-    r = r / (float)(HRTIME_MSECOND);
-  }
-  RecDataSetFromFloat(data_type, data, r);
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// RecIncrRawStatXXX
-//-------------------------------------------------------------------------
-int
-RecIncrRawStatBlock(RecRawStatBlock * /* rsb ATS_UNUSED */, EThread * /* ethread ATS_UNUSED
*/,
-                    RecRawStat * /* stat_array ATS_UNUSED */)
-{
-  return REC_ERR_FAIL;
-}
-
-
-//-------------------------------------------------------------------------
-// RecSetRawStatXXX
-//-------------------------------------------------------------------------
-int
-RecSetRawStatSum(RecRawStatBlock *rsb, int id, int64_t data)
-{
-  raw_stat_clear_sum(rsb, id);
-  ink_atomic_swap(&(rsb->global[id]->sum), data);
-  return REC_ERR_OKAY;
-}
-
-int
-RecSetRawStatCount(RecRawStatBlock *rsb, int id, int64_t data)
-{
-  raw_stat_clear_count(rsb, id);
-  ink_atomic_swap(&(rsb->global[id]->count), data);
-  return REC_ERR_OKAY;
-}
-
-int
-RecSetRawStatBlock(RecRawStatBlock * /* rsb ATS_UNUSED */, RecRawStat * /* stat_array ATS_UNUSED
*/)
-{
-  return REC_ERR_FAIL;
-}
-
-
-//-------------------------------------------------------------------------
-// RecGetRawStatXXX
-//-------------------------------------------------------------------------
-
-int
-RecGetRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data)
-{
-  RecRawStat total;
-
-  raw_stat_get_total(rsb, id, &total);
-  *data = total.sum;
-  return REC_ERR_OKAY;
-}
-
-int
-RecGetRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data)
-{
-  RecRawStat total;
-
-  raw_stat_get_total(rsb, id, &total);
-  *data = total.count;
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// RecIncrGlobalRawStatXXX
-//-------------------------------------------------------------------------
-int
-RecIncrGlobalRawStat(RecRawStatBlock *rsb, int id, int64_t incr)
-{
-  ink_atomic_increment(&(rsb->global[id]->sum), incr);
-  ink_atomic_increment(&(rsb->global[id]->count), 1);
-  return REC_ERR_OKAY;
-}
-
-int
-RecIncrGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t incr)
-{
-  ink_atomic_increment(&(rsb->global[id]->sum), incr);
-  return REC_ERR_OKAY;
-}
-
-int
-RecIncrGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t incr)
-{
-  ink_atomic_increment(&(rsb->global[id]->count), incr);
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// RecSetGlobalRawStatXXX
-//-------------------------------------------------------------------------
-int
-RecSetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t data)
-{
-  ink_atomic_swap(&(rsb->global[id]->sum), data);
-  return REC_ERR_OKAY;
-}
-
-int
-RecSetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t data)
-{
-  ink_atomic_swap(&(rsb->global[id]->count), data);
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// RecGetGlobalRawStatXXX
-//-------------------------------------------------------------------------
-int
-RecGetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data)
-{
-  *data = rsb->global[id]->sum;
-  return REC_ERR_OKAY;
-}
-
-int
-RecGetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data)
-{
-  *data = rsb->global[id]->count;
-  return REC_ERR_OKAY;
-}
-
-
-//-------------------------------------------------------------------------
-// RegGetGlobalRawStatXXXPtr
-//-------------------------------------------------------------------------
-RecRawStat *
-RecGetGlobalRawStatPtr(RecRawStatBlock *rsb, int id)
-{
-  return rsb->global[id];
-}
-
-int64_t *
-RecGetGlobalRawStatSumPtr(RecRawStatBlock *rsb, int id)
-{
-  return &(rsb->global[id]->sum);
-}
-
-int64_t *
-RecGetGlobalRawStatCountPtr(RecRawStatBlock *rsb, int id)
-{
-  return &(rsb->global[id]->count);
-}
-
-
-//-------------------------------------------------------------------------
-// RecRegisterRawStatSyncCb
-//-------------------------------------------------------------------------
-int
-RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock *rsb,
int id)
-{
-  int err = REC_ERR_FAIL;
-  RecRecord *r;
-
-  ink_rwlock_rdlock(&g_records_rwlock);
-  if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) {
-    rec_mutex_acquire(&(r->lock));
-    if (REC_TYPE_IS_STAT(r->rec_type)) {
-      if (!(r->stat_meta.sync_cb)) {
-        r->stat_meta.sync_rsb = rsb;
-        r->stat_meta.sync_id = id;
-        r->stat_meta.sync_cb = sync_cb;
-        r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version = r->version;
-        err = REC_ERR_OKAY;
-      } else {
-        ink_release_assert(false); // We shouldn't register CBs twice...
-      }
-    }
-    rec_mutex_release(&(r->lock));
-  }
-  ink_rwlock_unlock(&g_records_rwlock);
-
-  return err;
-}
-
-
-//-------------------------------------------------------------------------
-// RecExecRawStatSyncCbs
-//-------------------------------------------------------------------------
-int
-RecExecRawStatSyncCbs()
-{
-  RecRecord *r;
-  int i, num_records;
-
-  num_records = g_num_records;
-  for (i = 0; i < num_records; i++) {
-    r = &(g_records[i]);
-    rec_mutex_acquire(&(r->lock));
-    if (REC_TYPE_IS_STAT(r->rec_type)) {
-      if (r->stat_meta.sync_cb) {
-        if (r->version && r->version != r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version)
{
-          raw_stat_clear(r->stat_meta.sync_rsb, r->stat_meta.sync_id);
-          r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version = r->version;
-        } else {
-          (*(r->stat_meta.sync_cb))(r->name, r->data_type, &(r->data), r->stat_meta.sync_rsb,
r->stat_meta.sync_id);
-        }
-        r->sync_required = REC_SYNC_REQUIRED;
-      }
-    }
-    rec_mutex_release(&(r->lock));
-  }
-
-  return REC_ERR_OKAY;
-}
-
 void
 RecSignalManager(int id, const char *msg, size_t msgsize)
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfd97769/lib/records/RecRawStats.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecRawStats.cc b/lib/records/RecRawStats.cc
new file mode 100644
index 0000000..2de9ecb
--- /dev/null
+++ b/lib/records/RecRawStats.cc
@@ -0,0 +1,614 @@
+/** @file
+
+  Record statistics support.
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include "P_RecCore.h"
+#include "P_RecProcess.h"
+
+//-------------------------------------------------------------------------
+// raw_stat_get_total
+//-------------------------------------------------------------------------
+static int
+raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total)
+{
+  int i;
+  RecRawStat *tlp;
+
+  total->sum = 0;
+  total->count = 0;
+
+  // get global values
+  total->sum = rsb->global[id]->sum;
+  total->count = rsb->global[id]->count;
+
+  // get thread local values
+  for (i = 0; i < eventProcessor.n_ethreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
+    total->sum += tlp->sum;
+    total->count += tlp->count;
+  }
+
+  for (i = 0; i < eventProcessor.n_dthreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
+    total->sum += tlp->sum;
+    total->count += tlp->count;
+  }
+
+  if (total->sum < 0) { // Assure that we stay positive
+    total->sum = 0;
+  }
+
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// raw_stat_sync_to_global
+//-------------------------------------------------------------------------
+static int
+raw_stat_sync_to_global(RecRawStatBlock *rsb, int id)
+{
+  int i;
+  RecRawStat *tlp;
+  RecRawStat total;
+
+  total.sum = 0;
+  total.count = 0;
+
+  // sum the thread local values
+  for (i = 0; i < eventProcessor.n_ethreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
+    total.sum += tlp->sum;
+    total.count += tlp->count;
+  }
+
+  for (i = 0; i < eventProcessor.n_dthreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
+    total.sum += tlp->sum;
+    total.count += tlp->count;
+  }
+
+  if (total.sum < 0) { // Assure that we stay positive
+    total.sum = 0;
+  }
+
+  // lock so the setting of the globals and last values are atomic
+  ink_mutex_acquire(&(rsb->mutex));
+
+  // get the delta from the last sync
+  RecRawStat delta;
+  delta.sum = total.sum - rsb->global[id]->last_sum;
+  delta.count = total.count - rsb->global[id]->last_count;
+
+  // This is too verbose now, so leaving it out / leif
+  // Debug("stats", "raw_stat_sync_to_global(): rsb pointer:%p id:%d delta:%" PRId64 " total:%"
PRId64 " last:%" PRId64 " global:%"
+  // PRId64 "\n",
+  // rsb, id, delta.sum, total.sum, rsb->global[id]->last_sum, rsb->global[id]->sum);
+
+  // increment the global values by the delta
+  ink_atomic_increment(&(rsb->global[id]->sum), delta.sum);
+  ink_atomic_increment(&(rsb->global[id]->count), delta.count);
+
+  // set the new totals as the last values seen
+  ink_atomic_swap(&(rsb->global[id]->last_sum), total.sum);
+  ink_atomic_swap(&(rsb->global[id]->last_count), total.count);
+
+  ink_mutex_release(&(rsb->mutex));
+
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// raw_stat_clear
+//-------------------------------------------------------------------------
+static int
+raw_stat_clear(RecRawStatBlock *rsb, int id)
+{
+  Debug("stats", "raw_stat_clear(): rsb pointer:%p id:%d\n", rsb, id);
+
+  // the globals need to be reset too
+  // lock so the setting of the globals and last values are atomic
+  ink_mutex_acquire(&(rsb->mutex));
+  ink_atomic_swap(&(rsb->global[id]->sum), (int64_t)0);
+  ink_atomic_swap(&(rsb->global[id]->last_sum), (int64_t)0);
+  ink_atomic_swap(&(rsb->global[id]->count), (int64_t)0);
+  ink_atomic_swap(&(rsb->global[id]->last_count), (int64_t)0);
+  ink_mutex_release(&(rsb->mutex));
+
+  // reset the local stats
+  RecRawStat *tlp;
+  for (int i = 0; i < eventProcessor.n_ethreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
+    ink_atomic_swap(&(tlp->sum), (int64_t)0);
+    ink_atomic_swap(&(tlp->count), (int64_t)0);
+  }
+
+  for (int i = 0; i < eventProcessor.n_dthreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
+    ink_atomic_swap(&(tlp->sum), (int64_t)0);
+    ink_atomic_swap(&(tlp->count), (int64_t)0);
+  }
+
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// raw_stat_clear_sum
+//-------------------------------------------------------------------------
+static int
+raw_stat_clear_sum(RecRawStatBlock *rsb, int id)
+{
+  Debug("stats", "raw_stat_clear_sum(): rsb pointer:%p id:%d\n", rsb, id);
+
+  // the globals need to be reset too
+  // lock so the setting of the globals and last values are atomic
+  ink_mutex_acquire(&(rsb->mutex));
+  ink_atomic_swap(&(rsb->global[id]->sum), (int64_t)0);
+  ink_atomic_swap(&(rsb->global[id]->last_sum), (int64_t)0);
+  ink_mutex_release(&(rsb->mutex));
+
+  // reset the local stats
+  RecRawStat *tlp;
+  for (int i = 0; i < eventProcessor.n_ethreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
+    ink_atomic_swap(&(tlp->sum), (int64_t)0);
+  }
+
+  for (int i = 0; i < eventProcessor.n_dthreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
+    ink_atomic_swap(&(tlp->sum), (int64_t)0);
+  }
+
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// raw_stat_clear_count
+//-------------------------------------------------------------------------
+static int
+raw_stat_clear_count(RecRawStatBlock *rsb, int id)
+{
+  Debug("stats", "raw_stat_clear_count(): rsb pointer:%p id:%d\n", rsb, id);
+
+  // the globals need to be reset too
+  // lock so the setting of the globals and last values are atomic
+  ink_mutex_acquire(&(rsb->mutex));
+  ink_atomic_swap(&(rsb->global[id]->count), (int64_t)0);
+  ink_atomic_swap(&(rsb->global[id]->last_count), (int64_t)0);
+  ink_mutex_release(&(rsb->mutex));
+
+  // reset the local stats
+  RecRawStat *tlp;
+  for (int i = 0; i < eventProcessor.n_ethreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset))
+ id;
+    ink_atomic_swap(&(tlp->count), (int64_t)0);
+  }
+
+  for (int i = 0; i < eventProcessor.n_dthreads; i++) {
+    tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset))
+ id;
+    ink_atomic_swap(&(tlp->count), (int64_t)0);
+  }
+
+  return REC_ERR_OKAY;
+}
+
+//-------------------------------------------------------------------------
+// RecAllocateRawStatBlock
+//-------------------------------------------------------------------------
+RecRawStatBlock *
+RecAllocateRawStatBlock(int num_stats)
+{
+  off_t ethr_stat_offset;
+  RecRawStatBlock *rsb;
+
+  // allocate thread-local raw-stat memory
+  if ((ethr_stat_offset = eventProcessor.allocate(num_stats * sizeof(RecRawStat))) == -1)
{
+    return NULL;
+  }
+  // create the raw-stat-block structure
+  rsb = (RecRawStatBlock *)ats_malloc(sizeof(RecRawStatBlock));
+  memset(rsb, 0, sizeof(RecRawStatBlock));
+  rsb->ethr_stat_offset = ethr_stat_offset;
+  rsb->global = (RecRawStat **)ats_malloc(num_stats * sizeof(RecRawStat *));
+  memset(rsb->global, 0, num_stats * sizeof(RecRawStat *));
+  rsb->num_stats = 0;
+  rsb->max_stats = num_stats;
+  ink_mutex_init(&(rsb->mutex), "net stat mutex");
+  return rsb;
+}
+
+
+//-------------------------------------------------------------------------
+// RecRegisterRawStat
+//-------------------------------------------------------------------------
+int
+_RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type,
RecPersistT persist_type, int id,
+                    RecRawStatSyncCb sync_cb)
+{
+  Debug("stats", "RecRawStatSyncCb(%s): rsb pointer:%p id:%d\n", name, rsb, id);
+
+  // check to see if we're good to proceed
+  ink_assert(id < rsb->max_stats);
+
+  int err = REC_ERR_OKAY;
+
+  RecRecord *r;
+  RecData data_default;
+  memset(&data_default, 0, sizeof(RecData));
+
+  // register the record
+  if ((r = RecRegisterStat(rec_type, name, data_type, data_default, persist_type)) == NULL)
{
+    err = REC_ERR_FAIL;
+    goto Ldone;
+  }
+  r->rsb_id = id; // This is the index within the RSB raw block for this stat, used for
lookups by name.
+  if (i_am_the_record_owner(r->rec_type)) {
+    r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED;
+  } else {
+    send_register_message(r);
+  }
+
+  // store a pointer to our record->stat_meta.data_raw in our rsb
+  rsb->global[id] = &(r->stat_meta.data_raw);
+  rsb->global[id]->last_sum = 0;
+  rsb->global[id]->last_count = 0;
+
+  // setup the periodic sync callback
+  if (sync_cb) RecRegisterRawStatSyncCb(name, sync_cb, rsb, id);
+
+Ldone:
+  return err;
+}
+
+
+//-------------------------------------------------------------------------
+// RecRawStatSync...
+//-------------------------------------------------------------------------
+
+// Note: On these RecRawStatSync callbacks, our 'data' is protected
+// under its lock by the caller, so no need to worry!
+int
+RecRawStatSyncSum(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb,
int id)
+{
+  RecRawStat total;
+
+  Debug("stats", "raw sync:sum for %s", name);
+  raw_stat_sync_to_global(rsb, id);
+  total.sum = rsb->global[id]->sum;
+  total.count = rsb->global[id]->count;
+  RecDataSetFromInk64(data_type, data, total.sum);
+
+  return REC_ERR_OKAY;
+}
+
+int
+RecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock
*rsb, int id)
+{
+  RecRawStat total;
+
+  Debug("stats", "raw sync:count for %s", name);
+  raw_stat_sync_to_global(rsb, id);
+  total.sum = rsb->global[id]->sum;
+  total.count = rsb->global[id]->count;
+  RecDataSetFromInk64(data_type, data, total.count);
+
+  return REC_ERR_OKAY;
+}
+
+int
+RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb,
int id)
+{
+  RecRawStat total;
+  RecFloat avg = 0.0f;
+
+  Debug("stats", "raw sync:avg for %s", name);
+  raw_stat_sync_to_global(rsb, id);
+  total.sum = rsb->global[id]->sum;
+  total.count = rsb->global[id]->count;
+  if (total.count != 0)
+    avg = (float)((double)total.sum / (double)total.count);
+  RecDataSetFromFloat(data_type, data, avg);
+  return REC_ERR_OKAY;
+}
+
+int
+RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock
*rsb, int id)
+{
+  RecRawStat total;
+  RecFloat r;
+
+  Debug("stats", "raw sync:hr-timeavg for %s", name);
+  raw_stat_sync_to_global(rsb, id);
+  total.sum = rsb->global[id]->sum;
+  total.count = rsb->global[id]->count;
+  if (total.count == 0) {
+    r = 0.0f;
+  } else {
+    r = (float)((double)total.sum / (double)total.count);
+    r = r / (float)(HRTIME_SECOND);
+  }
+  RecDataSetFromFloat(data_type, data, r);
+  return REC_ERR_OKAY;
+}
+
+int
+RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecData *data,
RecRawStatBlock *rsb, int id)
+{
+  RecRawStat total;
+  RecFloat r;
+
+  Debug("stats", "raw sync:seconds for %s", name);
+  raw_stat_sync_to_global(rsb, id);
+  total.sum = rsb->global[id]->sum;
+  total.count = rsb->global[id]->count;
+  if (total.count == 0) {
+    r = 0.0f;
+  } else {
+    r = (float)((double)total.sum / 1000);
+  }
+  RecDataSetFromFloat(data_type, data, r);
+  return REC_ERR_OKAY;
+}
+
+int
+RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock
*rsb, int id)
+{
+  RecRawStat total;
+  RecFloat r;
+
+  Debug("stats", "raw sync:mhr-timeavg for %s", name);
+  raw_stat_sync_to_global(rsb, id);
+  total.sum = rsb->global[id]->sum;
+  total.count = rsb->global[id]->count;
+  if (total.count == 0) {
+    r = 0.0f;
+  } else {
+    r = (float)((double)total.sum / (double)total.count);
+    r = r / (float)(HRTIME_MSECOND);
+  }
+  RecDataSetFromFloat(data_type, data, r);
+  return REC_ERR_OKAY;
+}
+
+//-------------------------------------------------------------------------
+// RecIncrRawStatXXX
+//-------------------------------------------------------------------------
+int
+RecIncrRawStatBlock(RecRawStatBlock * /* rsb ATS_UNUSED */, EThread * /* ethread ATS_UNUSED
*/,
+                    RecRawStat * /* stat_array ATS_UNUSED */)
+{
+  return REC_ERR_FAIL;
+}
+
+
+//-------------------------------------------------------------------------
+// RecSetRawStatXXX
+//-------------------------------------------------------------------------
+int
+RecSetRawStatSum(RecRawStatBlock *rsb, int id, int64_t data)
+{
+  raw_stat_clear_sum(rsb, id);
+  ink_atomic_swap(&(rsb->global[id]->sum), data);
+  return REC_ERR_OKAY;
+}
+
+int
+RecSetRawStatCount(RecRawStatBlock *rsb, int id, int64_t data)
+{
+  raw_stat_clear_count(rsb, id);
+  ink_atomic_swap(&(rsb->global[id]->count), data);
+  return REC_ERR_OKAY;
+}
+
+int
+RecSetRawStatBlock(RecRawStatBlock * /* rsb ATS_UNUSED */, RecRawStat * /* stat_array ATS_UNUSED
*/)
+{
+  return REC_ERR_FAIL;
+}
+
+
+//-------------------------------------------------------------------------
+// RecGetRawStatXXX
+//-------------------------------------------------------------------------
+
+int
+RecGetRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data)
+{
+  RecRawStat total;
+
+  raw_stat_get_total(rsb, id, &total);
+  *data = total.sum;
+  return REC_ERR_OKAY;
+}
+
+int
+RecGetRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data)
+{
+  RecRawStat total;
+
+  raw_stat_get_total(rsb, id, &total);
+  *data = total.count;
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// RecIncrGlobalRawStatXXX
+//-------------------------------------------------------------------------
+int
+RecIncrGlobalRawStat(RecRawStatBlock *rsb, int id, int64_t incr)
+{
+  ink_atomic_increment(&(rsb->global[id]->sum), incr);
+  ink_atomic_increment(&(rsb->global[id]->count), 1);
+  return REC_ERR_OKAY;
+}
+
+int
+RecIncrGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t incr)
+{
+  ink_atomic_increment(&(rsb->global[id]->sum), incr);
+  return REC_ERR_OKAY;
+}
+
+int
+RecIncrGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t incr)
+{
+  ink_atomic_increment(&(rsb->global[id]->count), incr);
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// RecSetGlobalRawStatXXX
+//-------------------------------------------------------------------------
+int
+RecSetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t data)
+{
+  ink_atomic_swap(&(rsb->global[id]->sum), data);
+  return REC_ERR_OKAY;
+}
+
+int
+RecSetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t data)
+{
+  ink_atomic_swap(&(rsb->global[id]->count), data);
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// RecGetGlobalRawStatXXX
+//-------------------------------------------------------------------------
+int
+RecGetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data)
+{
+  *data = rsb->global[id]->sum;
+  return REC_ERR_OKAY;
+}
+
+int
+RecGetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data)
+{
+  *data = rsb->global[id]->count;
+  return REC_ERR_OKAY;
+}
+
+
+//-------------------------------------------------------------------------
+// RegGetGlobalRawStatXXXPtr
+//-------------------------------------------------------------------------
+RecRawStat *
+RecGetGlobalRawStatPtr(RecRawStatBlock *rsb, int id)
+{
+  return rsb->global[id];
+}
+
+int64_t *
+RecGetGlobalRawStatSumPtr(RecRawStatBlock *rsb, int id)
+{
+  return &(rsb->global[id]->sum);
+}
+
+int64_t *
+RecGetGlobalRawStatCountPtr(RecRawStatBlock *rsb, int id)
+{
+  return &(rsb->global[id]->count);
+}
+
+
+//-------------------------------------------------------------------------
+// RecRegisterRawStatSyncCb
+//-------------------------------------------------------------------------
+int
+RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock *rsb,
int id)
+{
+  int err = REC_ERR_FAIL;
+  RecRecord *r;
+
+  ink_rwlock_rdlock(&g_records_rwlock);
+  if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) {
+    rec_mutex_acquire(&(r->lock));
+    if (REC_TYPE_IS_STAT(r->rec_type)) {
+      if (!(r->stat_meta.sync_cb)) {
+        r->stat_meta.sync_rsb = rsb;
+        r->stat_meta.sync_id = id;
+        r->stat_meta.sync_cb = sync_cb;
+        r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version = r->version;
+        err = REC_ERR_OKAY;
+      } else {
+        ink_release_assert(false); // We shouldn't register CBs twice...
+      }
+    }
+    rec_mutex_release(&(r->lock));
+  }
+  ink_rwlock_unlock(&g_records_rwlock);
+
+  return err;
+}
+
+
+//-------------------------------------------------------------------------
+// RecExecRawStatSyncCbs
+//-------------------------------------------------------------------------
+int
+RecExecRawStatSyncCbs()
+{
+  RecRecord *r;
+  int i, num_records;
+
+  num_records = g_num_records;
+  for (i = 0; i < num_records; i++) {
+    r = &(g_records[i]);
+    rec_mutex_acquire(&(r->lock));
+    if (REC_TYPE_IS_STAT(r->rec_type)) {
+      if (r->stat_meta.sync_cb) {
+        if (r->version && r->version != r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version)
{
+          raw_stat_clear(r->stat_meta.sync_rsb, r->stat_meta.sync_id);
+          r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version = r->version;
+        } else {
+          (*(r->stat_meta.sync_cb))(r->name, r->data_type, &(r->data), r->stat_meta.sync_rsb,
r->stat_meta.sync_id);
+        }
+        r->sync_required = REC_SYNC_REQUIRED;
+      }
+    }
+    rec_mutex_release(&(r->lock));
+  }
+
+  return REC_ERR_OKAY;
+}
+
+int
+RecRawStatUpdateSum(RecRawStatBlock* rsb, int id)
+{
+  RecRawStat* raw = rsb->global[id];
+  if (NULL != raw) {
+    RecRecord* r = reinterpret_cast<RecRecord*>(reinterpret_cast<char*>(raw)
- (reinterpret_cast<char*>(&reinterpret_cast<RecRecord*>(0)->stat_meta)
- reinterpret_cast<char*>(reinterpret_cast<RecRecord*>(0))));
+
+    RecDataSetFromInk64(r->data_type, &r->data, rsb->global[id]->sum);
+    r->sync_required = REC_SYNC_REQUIRED;
+    return REC_ERR_OKAY;
+  }
+  return REC_ERR_FAIL;
+}


Mime
View raw message