You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2010/09/22 22:30:05 UTC
svn commit: r1000195 - in /trafficserver/traffic/trunk: librecords/ proxy/
proxy/api/ts/ proxy/stats/
Author: zwoop
Date: Wed Sep 22 20:30:04 2010
New Revision: 1000195
URL: http://svn.apache.org/viewvc?rev=1000195&view=rev
Log:
TS-390: Cleanup in the stats code, as preparation.
Modified:
trafficserver/traffic/trunk/librecords/I_RecDefs.h
trafficserver/traffic/trunk/librecords/I_RecProcess.h
trafficserver/traffic/trunk/librecords/P_RecCore.i
trafficserver/traffic/trunk/librecords/P_RecDefs.h
trafficserver/traffic/trunk/librecords/RecCore.cc
trafficserver/traffic/trunk/librecords/RecProcess.cc
trafficserver/traffic/trunk/proxy/InkAPI.cc
trafficserver/traffic/trunk/proxy/api/ts/ts.h
trafficserver/traffic/trunk/proxy/stats/Stats.cc
trafficserver/traffic/trunk/proxy/stats/Stats.h
Modified: trafficserver/traffic/trunk/librecords/I_RecDefs.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/I_RecDefs.h?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/I_RecDefs.h (original)
+++ trafficserver/traffic/trunk/librecords/I_RecDefs.h Wed Sep 22 20:30:04 2010
@@ -31,20 +31,20 @@
#define STAT_PROCESSOR
+
//-------------------------------------------------------------------------
// Error Values
//-------------------------------------------------------------------------
-
enum RecErrT
{
REC_ERR_FAIL = -1,
REC_ERR_OKAY = 0
};
+
//-------------------------------------------------------------------------
// Types
//-------------------------------------------------------------------------
-
#define RecStringNull NULL
typedef int64 RecInt;
@@ -119,10 +119,10 @@ enum RecAccessT
RECA_READ_ONLY
};
+
//-------------------------------------------------------------------------
// Data Union
//-------------------------------------------------------------------------
-
union RecData
{
RecInt rec_int;
@@ -131,10 +131,10 @@ union RecData
RecCounter rec_counter;
};
+
//-------------------------------------------------------------------------
// RawStat Structures
//-------------------------------------------------------------------------
-
struct RecRawStat
{
int64 sum;
@@ -146,9 +146,9 @@ struct RecRawStat
int64 last_count; // value from the last global sync
};
+
// WARNING! It's advised that developers do not modify the contents of
// the RecRawStatBlock. ^_^
-
struct RecRawStatBlock
{
off_t ethr_stat_offset; // thread local raw-stat storage
@@ -158,24 +158,23 @@ struct RecRawStatBlock
ink_mutex mutex;
};
+
//-------------------------------------------------------------------------
// RecCore Callback Types
//-------------------------------------------------------------------------
-
typedef int (*RecConfigUpdateCb) (const char *name, RecDataT data_type, RecData data, void *cookie);
-
typedef int (*RecStatUpdateFunc) (const char *name, RecDataT data_type,
RecData * data, RecRawStatBlock * rsb, int id, void *cookie);
-
typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
+
//-------------------------------------------------------------------------
// RecTree Defines
//-------------------------------------------------------------------------
-
#define REC_VAR_NAME_DELIMITOR '.'
#define REC_VAR_NAME_WILDCARD '*'
+
// System Defaults
extern char system_root_dir[PATH_NAME_MAX + 1];
extern char system_runtime_dir[PATH_NAME_MAX + 1];
Modified: trafficserver/traffic/trunk/librecords/I_RecProcess.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/I_RecProcess.h?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/I_RecProcess.h (original)
+++ trafficserver/traffic/trunk/librecords/I_RecProcess.h Wed Sep 22 20:30:04 2010
@@ -27,22 +27,22 @@
#include "I_RecCore.h"
#include "I_EventSystem.h"
+
//-------------------------------------------------------------------------
// Initialization/Starting
//-------------------------------------------------------------------------
-
int RecProcessInit(RecModeT mode_type, Diags * diags = NULL);
int RecProcessInitMessage(RecModeT mode_type);
int RecProcessStart();
+
//-------------------------------------------------------------------------
// RawStat Registration
//-------------------------------------------------------------------------
-
RecRawStatBlock *RecAllocateRawStatBlock(int num_stats);
-
int RecRegisterRawStat(RecRawStatBlock * rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id, RecRawStatSyncCb sync_cb);
+
// RecRawStatRange* RecAllocateRawStatRange (int num_buckets);
// int RecRegisterRawStatRange (RecRawStatRange *rsr,
@@ -53,10 +53,10 @@ int RecRegisterRawStat(RecRawStatBlock *
// RecInt min,
// RecInt max);
+
//-------------------------------------------------------------------------
// Predefined RawStat Callbacks
//-------------------------------------------------------------------------
-
int RecRawStatSyncSum(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
int RecRawStatSyncCount(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
int RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
@@ -65,6 +65,7 @@ int RecRawStatSyncIntMsecsToFloatSeconds
RecData * data, RecRawStatBlock * rsb, int id);
int RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
+
//-------------------------------------------------------------------------
// RawStat Setting/Getting
//-------------------------------------------------------------------------
@@ -84,10 +85,10 @@ int RecSetRawStatBlock(RecRawStatBlock *
int RecGetRawStatSum(RecRawStatBlock * rsb, int id, int64 * data);
int RecGetRawStatCount(RecRawStatBlock * rsb, int id, int64 * data);
+
//-------------------------------------------------------------------------
// Global RawStat Items (e.g. same as above, but no thread-local behavior)
//-------------------------------------------------------------------------
-
int RecIncrGlobalRawStat(RecRawStatBlock * rsb, int id, int64 incr = 1);
int RecIncrGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64 incr = 1);
int RecIncrGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64 incr = 1);
@@ -102,12 +103,12 @@ RecRawStat *RecGetGlobalRawStatPtr(RecRa
int64 *RecGetGlobalRawStatSumPtr(RecRawStatBlock * rsb, int id);
int64 *RecGetGlobalRawStatCountPtr(RecRawStatBlock * rsb, int id);
+
//-------------------------------------------------------------------------
// RecIncrRawStatXXX
//-------------------------------------------------------------------------
// inlined functions that are used very frequently.
// FIXME: move it to Inline.cc
-
inline RecRawStat *
raw_stat_get_tlp(RecRawStatBlock * rsb, int id, EThread * ethread)
{
Modified: trafficserver/traffic/trunk/librecords/P_RecCore.i
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/P_RecCore.i?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/P_RecCore.i (original)
+++ trafficserver/traffic/trunk/librecords/P_RecCore.i Wed Sep 22 20:30:04 2010
@@ -28,14 +28,13 @@
#include "P_RecCompatibility.h"
#include "P_RecUtils.h"
+
//-------------------------------------------------------------------------
// i_am_the_record_owner
//-------------------------------------------------------------------------
-
static bool
i_am_the_record_owner(RecT rec_type)
{
-
#if defined (REC_LOCAL)
switch (rec_type) {
@@ -91,17 +90,15 @@ i_am_the_record_owner(RecT rec_type)
#endif
return false;
-
}
+
//-------------------------------------------------------------------------
// send_set_message
//-------------------------------------------------------------------------
-
static int
send_set_message(RecRecord * record)
{
-
RecMessage *m;
rec_mutex_acquire(&(record->lock));
@@ -113,17 +110,15 @@ send_set_message(RecRecord * record)
rec_mutex_release(&(record->lock));
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// send_register_message
//-------------------------------------------------------------------------
-
static int
send_register_message(RecRecord * record)
{
-
RecMessage *m;
rec_mutex_acquire(&(record->lock));
@@ -135,17 +130,15 @@ send_register_message(RecRecord * record
rec_mutex_release(&(record->lock));
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// send_push_message
//-------------------------------------------------------------------------
-
static int
send_push_message()
{
-
RecRecord *r;
RecMessage *m;
int i, num_records;
@@ -172,17 +165,15 @@ send_push_message()
RecMessageFree(m);
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// send_pull_message
//-------------------------------------------------------------------------
-
static int
send_pull_message(RecMessageT msg_type)
{
-
RecRecord *r;
RecMessage *m;
int i, num_records;
@@ -225,13 +216,12 @@ send_pull_message(RecMessageT msg_type)
RecMessageFree(m);
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// recv_message_cb
//-------------------------------------------------------------------------
-
static int
recv_message_cb(RecMessage * msg, RecMessageT msg_type, void *cookie)
{
@@ -301,13 +291,12 @@ recv_message_cb(RecMessage * msg, RecMes
}
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecRegisterStatXXX
//-------------------------------------------------------------------------
-
#define REC_REGISTER_STAT_XXX(A, B) \
ink_debug_assert((rec_type == RECT_NODE) || \
(rec_type == RECT_CLUSTER) || \
@@ -353,10 +342,10 @@ RecRegisterStatCounter(RecT rec_type, co
REC_REGISTER_STAT_XXX(rec_counter, RECD_COUNTER);
}
+
//-------------------------------------------------------------------------
// RecRegisterConfigXXX
//-------------------------------------------------------------------------
-
#define REC_REGISTER_CONFIG_XXX(A, B) \
RecRecord *r; \
RecData my_data_default; \
@@ -412,14 +401,13 @@ RecRegisterConfigCounter(RecT rec_type,
REC_REGISTER_CONFIG_XXX(rec_counter, RECD_COUNTER);
}
+
//-------------------------------------------------------------------------
// RecSetRecordXXX
//-------------------------------------------------------------------------
-
int
RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *data_raw, bool lock)
{
-
int err = REC_ERR_OKAY;
RecRecord *r1;
@@ -430,9 +418,7 @@ RecSetRecord(RecT rec_type, const char *
}
if (ink_hash_table_lookup(g_records_ht, name, (void **) &r1)) {
-
if (i_am_the_record_owner(r1->rec_type)) {
-
rec_mutex_acquire(&(r1->lock));
if ((data_type != RECD_NULL) && (r1->data_type != data_type)) {
err = REC_ERR_FAIL;
@@ -525,7 +511,6 @@ Ldone:
}
return err;
-
}
int
@@ -568,14 +553,13 @@ RecSetRecordCounter(const char *name, Re
return RecSetRecord(RECT_NULL, name, RECD_COUNTER, &data, NULL, lock);
}
+
//-------------------------------------------------------------------------
// RecReadStatsFile
//-------------------------------------------------------------------------
-
int
RecReadStatsFile()
{
-
RecRecord *r;
RecMessage *m;
RecMessageItr itr;
@@ -596,17 +580,15 @@ RecReadStatsFile()
ink_rwlock_unlock(&g_records_rwlock);
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecSyncStatsFile
//-------------------------------------------------------------------------
-
int
RecSyncStatsFile()
{
-
RecRecord *r;
RecMessage *m;
int i, num_records;
@@ -615,7 +597,6 @@ RecSyncStatsFile()
// g_mode_type is defined in either RecLocal.cc or RecProcess.cc.
// We can access it since we're inlined by on of these two files.
if (g_mode_type == RECM_SERVER || g_mode_type == RECM_STAND_ALONE) {
-
m = RecMessageAlloc(RECG_NULL);
num_records = g_num_records;
sync_to_disk = false;
@@ -635,21 +616,18 @@ RecSyncStatsFile()
RecMessageWriteToDisk(m, g_stats_snap_fpath);
}
RecMessageFree(m);
-
}
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecReadConfigFile
//-------------------------------------------------------------------------
-
int
RecReadConfigFile()
{
-
char *fbuf;
int fsize;
@@ -695,7 +673,6 @@ RecReadConfigFile()
line = line_tok.iterFirst(&line_tok_state);
line_num = 1;
while (line) {
-
char *lc = xstrdup(line);
char *lt = lc;
char *ln;
@@ -756,8 +733,7 @@ RecReadConfigFile()
} else if (strcmp(rec_type_str, "LOCAL") == 0) {
rec_type = RECT_LOCAL;
} else {
- RecLog(DL_Warning, "Unknown record type '%s' at '%s:%d' -- skipping line",
- rec_type_str, g_rec_config_fpath, line_num);
+ RecLog(DL_Warning, "Unknown record type '%s' at '%s:%d' -- skipping line", rec_type_str, g_rec_config_fpath, line_num);
goto L_next_line;
}
@@ -772,8 +748,7 @@ RecReadConfigFile()
} else if (strcmp(data_type_str, "COUNTER") == 0) {
data_type = RECD_COUNTER;
} else {
- RecLog(DL_Warning, "Unknown data type '%s' at '%s:%d' -- skipping line",
- data_type_str, g_rec_config_fpath, line_num);
+ RecLog(DL_Warning, "Unknown data type '%s' at '%s:%d' -- skipping line", data_type_str, g_rec_config_fpath, line_num);
goto L_next_line;
}
@@ -788,7 +763,6 @@ RecReadConfigFile()
cfe->entry = xstrdup(name_str);
enqueue(g_rec_config_contents_llq, (void *) cfe);
ink_hash_table_insert(g_rec_config_contents_ht, name_str, NULL);
-
goto L_done;
L_next_line:
@@ -803,34 +777,28 @@ RecReadConfigFile()
line = line_tok.iterNext(&line_tok_state);
line_num++;
xfree(lc);
-
}
// release our hash table
ink_rwlock_unlock(&g_records_rwlock);
-
ink_mutex_release(&g_rec_config_lock);
-
xfree(fbuf);
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecSyncConfigFile
//-------------------------------------------------------------------------
-
int
RecSyncConfigToTB(textBuffer * tb)
{
-
int err = REC_ERR_FAIL;
// g_mode_type is defined in either RecLocal.cc or RecProcess.cc.
// We can access it since we're inlined by on of these two files.
if (g_mode_type == RECM_SERVER || g_mode_type == RECM_STAND_ALONE) {
-
RecRecord *r;
int i, num_records;
RecConfigFileEntry *cfe;
@@ -936,27 +904,21 @@ RecSyncConfigToTB(textBuffer * tb)
}
llq_rec = llq_rec->next;
}
-
ink_rwlock_unlock(&g_records_rwlock);
-
}
-
ink_mutex_release(&g_rec_config_lock);
-
}
return err;
-
}
+
//-------------------------------------------------------------------------
// RecExecConifgUpdateCbs
//-------------------------------------------------------------------------
-
int
RecExecConfigUpdateCbs()
{
-
RecRecord *r;
int i, num_records;
unsigned int update_required_type;
@@ -991,20 +953,17 @@ RecExecConfigUpdateCbs()
}
r->config_meta.update_required = r->config_meta.update_required & ~update_required_type;
}
-
}
rec_mutex_release(&(r->lock));
}
return REC_ERR_OKAY;
-
}
//------------------------------------------------------------------------
// RecResetStatRecord
//------------------------------------------------------------------------
-
int
RecResetStatRecord(char *name)
{
@@ -1012,16 +971,12 @@ RecResetStatRecord(char *name)
int err = REC_ERR_OKAY;
if (ink_hash_table_lookup(g_records_ht, name, (void **) &r1)) {
-
if (i_am_the_record_owner(r1->rec_type)) {
-
rec_mutex_acquire(&(r1->lock));
RecDataSet(r1->data_type, &(r1->data), &(r1->data_default));
rec_mutex_release(&(r1->lock));
err = REC_ERR_OKAY;
-
} else {
-
RecRecord r2;
memset(&r2, 0, sizeof(RecRecord));
r2.rec_type = r1->rec_type;
@@ -1030,11 +985,8 @@ RecResetStatRecord(char *name)
r2.data = r1->data_default;
err = send_set_message(&r2);
-
}
-
} else {
-
err = REC_ERR_FAIL;
}
@@ -1045,7 +997,6 @@ RecResetStatRecord(char *name)
//------------------------------------------------------------------------
// RecResetStatRecord
//------------------------------------------------------------------------
-
int
RecResetStatRecord(RecT type)
{
@@ -1061,17 +1012,13 @@ RecResetStatRecord(RecT type)
if (REC_TYPE_IS_STAT(r1->rec_type) &&
((type == RECT_NULL) || (r1->rec_type == type)) &&
(r1->stat_meta.persist_type != RECP_NON_PERSISTENT) && (r1->data_type != RECD_STRING)) {
-
if (i_am_the_record_owner(r1->rec_type)) {
-
rec_mutex_acquire(&(r1->lock));
if (!RecDataSet(r1->data_type, &(r1->data), &(r1->data_default))) {
err = REC_ERR_FAIL;
}
rec_mutex_release(&(r1->lock));
-
} else {
-
RecRecord r2;
memset(&r2, 0, sizeof(RecRecord));
r2.rec_type = r1->rec_type;
@@ -1080,11 +1027,8 @@ RecResetStatRecord(RecT type)
r2.data = r1->data_default;
err = send_set_message(&r2);
-
}
-
}
-
}
return err;
}
@@ -1093,7 +1037,6 @@ RecResetStatRecord(RecT type)
int
RecSetSyncRequired(char *name, bool lock)
{
-
int err = REC_ERR_FAIL;
RecRecord *r1;
@@ -1105,7 +1048,6 @@ RecSetSyncRequired(char *name, bool lock
if (ink_hash_table_lookup(g_records_ht, name, (void **) &r1)) {
if (i_am_the_record_owner(r1->rec_type)) {
-
rec_mutex_acquire(&(r1->lock));
r1->sync_required = REC_SYNC_REQUIRED;
if (REC_TYPE_IS_CONFIG(r1->rec_type)) {
@@ -1113,9 +1055,7 @@ RecSetSyncRequired(char *name, bool lock
}
rec_mutex_release(&(r1->lock));
err = REC_ERR_OKAY;
-
} else {
-
// No point of doing the following because our peer will
// set the value with RecDataSet. However, since
// r2.name == r1->name, the sync_required bit will not be
@@ -1131,9 +1071,7 @@ RecSetSyncRequired(char *name, bool lock
err = send_set_message(&r2);
*/
-
}
-
}
if (lock) {
@@ -1141,5 +1079,4 @@ RecSetSyncRequired(char *name, bool lock
}
return err;
-
}
Modified: trafficserver/traffic/trunk/librecords/P_RecDefs.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/P_RecDefs.h?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/P_RecDefs.h (original)
+++ trafficserver/traffic/trunk/librecords/P_RecDefs.h Wed Sep 22 20:30:04 2010
@@ -38,14 +38,14 @@
// TODO: We really need to try to make this setting dynamic, based
// on proxy.config.stat_api.max_stats_allowed (since it's the only
// variable piece). XXX
-// This allocates 10k for InkAPI stats, 3k for "core" (2x what we use)
-#define REC_MAX_RECORDS 13000
+// This allocates 5k for InkAPI stats, 3k for "core" (2x what we use)
+#define REC_MAX_RECORDS 8000
#define REC_CONFIG_UPDATE_INTERVAL_SEC 3
#define REC_REMOTE_SYNC_INTERVAL_SEC 5
-#define REC_RAW_STAT_SYNC_INTERVAL_SEC 3
-#define REC_STAT_UPDATE_INTERVAL_SEC 3
+#define REC_RAW_STAT_SYNC_INTERVAL_SEC 5
+#define REC_STAT_UPDATE_INTERVAL_SEC 10
//-------------------------------------------------------------------------
// Record Items
Modified: trafficserver/traffic/trunk/librecords/RecCore.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/RecCore.cc?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/RecCore.cc (original)
+++ trafficserver/traffic/trunk/librecords/RecCore.cc Wed Sep 22 20:30:04 2010
@@ -53,38 +53,37 @@ RecTree *g_records_tree = NULL;
int g_type_records[RECT_MAX][REC_MAX_RECORDS];
int g_type_num_records[RECT_MAX];
+
//-------------------------------------------------------------------------
// register_record
//-------------------------------------------------------------------------
-
static RecRecord *
register_record(RecT rec_type, const char *name, RecDataT data_type, RecData data_default, bool release_record_lock)
{
-
RecRecord *r = NULL;
if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) {
-
- rec_mutex_acquire(&(r->lock));
+ if (release_record_lock) {
+ rec_mutex_acquire(&(r->lock));
+ }
ink_release_assert(r->rec_type == rec_type);
ink_release_assert(r->data_type == data_type);
// Note: do not set r->data as we want to keep the previous value
RecDataSet(r->data_type, &(r->data_default), &(data_default));
-
} else {
-
if ((r = RecAlloc(rec_type, name, data_type)) == NULL) {
return NULL;
}
- rec_mutex_acquire(&(r->lock));
+ if (release_record_lock) {
+ rec_mutex_acquire(&(r->lock));
+ }
// Set the r->data to its default value as this is a new record
RecDataSet(r->data_type, &(r->data), &(data_default));
RecDataSet(r->data_type, &(r->data_default), &(data_default));
ink_hash_table_insert(g_records_ht, name, (void *) r);
-
}
- // we're not registered
+ // we're now registered
r->registered = true;
if (release_record_lock) {
@@ -92,13 +91,12 @@ register_record(RecT rec_type, const cha
}
return r;
-
}
+
//-------------------------------------------------------------------------
// link_XXX
//-------------------------------------------------------------------------
-
static int
link_int(const char *name, RecDataT data_type, RecData data, void *cookie)
{
@@ -173,14 +171,13 @@ link_string_alloc(const char *name, RecD
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// RecCoreInit
//-------------------------------------------------------------------------
-
int
RecCoreInit(RecModeT mode_type, Diags *_diags)
{
-
if (g_initialized) {
return REC_ERR_OKAY;
}
@@ -242,13 +239,12 @@ RecCoreInit(RecModeT mode_type, Diags *_
g_initialized = true;
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecSetDiags
//-------------------------------------------------------------------------
-
int
RecSetDiags(Diags * _diags)
{
@@ -258,10 +254,10 @@ RecSetDiags(Diags * _diags)
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// RecLinkCnfigXXX
//-------------------------------------------------------------------------
-
int
RecLinkConfigInt(const char *name, RecInt * rec_int)
{
@@ -310,14 +306,13 @@ RecLinkConfigString(const char *name, Re
return RecRegisterConfigUpdateCb(name, link_string_alloc, (void *) rec_string);
}
+
//-------------------------------------------------------------------------
// RecRegisterConfigUpdateCb
//-------------------------------------------------------------------------
-
int
RecRegisterConfigUpdateCb(const char *name, RecConfigUpdateCb update_cb, void *cookie)
{
-
int err = REC_ERR_FAIL;
RecRecord *r;
@@ -362,14 +357,12 @@ RecRegisterConfigUpdateCb(const char *na
ink_rwlock_unlock(&g_records_rwlock);
return err;
-
}
//-------------------------------------------------------------------------
// RecGetRecordXXX
//-------------------------------------------------------------------------
-
int
RecGetRecordInt(const char *name, RecInt *rec_int, bool lock)
{
@@ -480,10 +473,10 @@ RecGetRecordGeneric_Xmalloc(const char *
return err;
}
+
//-------------------------------------------------------------------------
// RecGetRec Attributes
//-------------------------------------------------------------------------
-
int
RecGetRecordType(const char *name, RecT * rec_type, bool lock)
{
@@ -657,13 +650,11 @@ RecGetRecordCheckExpr(const char *name,
int
RecGetRecordDefaultDataString_Xmalloc(char *name, char **buf, bool lock)
{
-
REC_NOWARN_UNUSED(lock);
int err;
RecRecord *r = NULL;
if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) {
-
*buf = (char *) xmalloc(sizeof(char) * 1024);
memset(*buf, 0, 1024);
err = REC_ERR_OKAY;
@@ -698,7 +689,6 @@ RecGetRecordDefaultDataString_Xmalloc(ch
}
return err;
-
}
@@ -752,15 +742,12 @@ RecSetRecordAccessType(const char *name,
}
-
//-------------------------------------------------------------------------
// RecRegisterStat
//-------------------------------------------------------------------------
-
RecRecord *
RecRegisterStat(RecT rec_type, const char *name, RecDataT data_type, RecData data_default, RecPersistT persist_type)
{
-
RecRecord *r = NULL;
ink_rwlock_wrlock(&g_records_rwlock);
if ((r = register_record(rec_type, name, data_type, data_default, false)) != NULL) {
@@ -772,19 +759,17 @@ RecRegisterStat(RecT rec_type, const cha
ink_rwlock_unlock(&g_records_rwlock);
return r;
-
}
+
//-------------------------------------------------------------------------
// RecRegisterConfig
//-------------------------------------------------------------------------
-
RecRecord *
RecRegisterConfig(RecT rec_type, const char *name, RecDataT data_type,
RecData data_default, RecUpdateT update_type,
RecCheckT check_type, const char *check_expr, RecAccessT access_type)
{
-
RecRecord *r;
ink_rwlock_wrlock(&g_records_rwlock);
if ((r = register_record(rec_type, name, data_type, data_default, false)) != NULL) {
@@ -802,17 +787,15 @@ RecRegisterConfig(RecT rec_type, const c
ink_rwlock_unlock(&g_records_rwlock);
return r;
-
}
+
//-------------------------------------------------------------------------
// RecGetRecord_Xmalloc
//-------------------------------------------------------------------------
-
int
RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data, bool lock)
{
-
int err = REC_ERR_OKAY;
RecRecord *r;
@@ -842,14 +825,13 @@ RecGetRecord_Xmalloc(const char *name, R
return err;
}
+
//-------------------------------------------------------------------------
// RecForceInsert
//-------------------------------------------------------------------------
-
RecRecord *
RecForceInsert(RecRecord * record)
{
-
RecRecord *r = NULL;
bool r_is_a_new_record;
@@ -895,17 +877,15 @@ RecForceInsert(RecRecord * record)
ink_rwlock_unlock(&g_records_rwlock);
return r;
-
}
+
//-------------------------------------------------------------------------
// RecDumpRecordsHt
//-------------------------------------------------------------------------
-
void
RecDumpRecordsHt(RecT rec_type)
{
-
int i, num_records;
RecDebug(DL_Note, "Dumping Records:");
@@ -936,7 +916,6 @@ RecDumpRecordsHt(RecT rec_type)
rec_mutex_release(&(r->lock));
}
}
-
}
void
@@ -962,11 +941,9 @@ RecGetRecordList(char *var, char ***buff
// mimics/replaces proxy/StatSystem.cc::stat_callback().
// returns the number of variables name match the prefix.
//-------------------------------------------------------------------------
-
int
RecGetRecordPrefix_Xmalloc(char *prefix, char **buf, int *buf_len)
{
-
int num_records = g_num_records;
int result_size = num_records * 128; /* estimate buffer size */
int num_matched = 0;
@@ -1004,19 +981,16 @@ RecGetRecordPrefix_Xmalloc(char *prefix,
}
}
-
*buf = result;
*buf_len = strlen(result);
return num_matched;
-
}
//-------------------------------------------------------------------------
// REC_ConfigReadInteger (backwards compatibility)
//-------------------------------------------------------------------------
-
RecInt
REC_ConfigReadInteger(const char *name)
{
@@ -1025,10 +999,10 @@ REC_ConfigReadInteger(const char *name)
return t;
}
+
//-------------------------------------------------------------------------
// REC_ConfigReadString (backwards compatibility)
//-------------------------------------------------------------------------
-
char *
REC_ConfigReadString(const char *name)
{
@@ -1037,10 +1011,10 @@ REC_ConfigReadString(const char *name)
return t;
}
+
//-------------------------------------------------------------------------
// REC_ConfigReadFloat (backwards compatibility)
//-------------------------------------------------------------------------
-
RecFloat
REC_ConfigReadFloat(const char *name)
{
@@ -1049,10 +1023,10 @@ REC_ConfigReadFloat(const char *name)
return t;
}
+
//-------------------------------------------------------------------------
// REC_ConfigReadCounter (backwards compatibility)
//-------------------------------------------------------------------------
-
RecCounter
REC_ConfigReadCounter(const char *name)
{
@@ -1065,7 +1039,6 @@ REC_ConfigReadCounter(const char *name)
//-------------------------------------------------------------------------
// MGMT2 Marco (backwards compatibility)
//-------------------------------------------------------------------------
-
RecInt
REC_readInteger(const char *name, bool * found, bool lock)
{
@@ -1115,7 +1088,6 @@ REC_readString(const char *name, bool *
}
// MGMT2 Marco's -- converting lmgmt->record_data->setXXX
-
bool
REC_setInteger(const char *name, RecInt value, bool dirty)
{
Modified: trafficserver/traffic/trunk/librecords/RecProcess.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/librecords/RecProcess.cc?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/librecords/RecProcess.cc (original)
+++ trafficserver/traffic/trunk/librecords/RecProcess.cc Wed Sep 22 20:30:04 2010
@@ -40,14 +40,13 @@ static RecModeT g_mode_type = RECM_NULL;
#include "P_RecCore.i"
#undef REC_PROCESS
+
//-------------------------------------------------------------------------
// raw_stat_get_total
//-------------------------------------------------------------------------
-
static int
-raw_stat_get_total(RecRawStatBlock * rsb, int id, RecRawStat * total)
+raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total)
{
-
int i;
RecRawStat *tlp;
total->sum = 0;
@@ -65,17 +64,15 @@ raw_stat_get_total(RecRawStatBlock * rsb
}
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;
@@ -97,7 +94,9 @@ raw_stat_sync_to_global(RecRawStatBlock
delta.sum = total.sum - rsb->global[id]->last_sum;
delta.count = total.count - rsb->global[id]->last_count;
- Debug("stats", "raw_stat_sync_to_global(): rsb pointer:%p id:%d delta:%lld total:%lld last:%lld global:%lld\n", rsb, id, delta.sum, total.sum, rsb->global[id]->last_sum, rsb->global[id]->sum);
+ // This is too verbose now, so leaving it out / leif
+ //Debug("stats", "raw_stat_sync_to_global(): rsb pointer:%p id:%d delta:%lld total:%lld last:%lld global:%lld\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_increment64(&(rsb->global[id]->sum), delta.sum);
@@ -112,10 +111,10 @@ raw_stat_sync_to_global(RecRawStatBlock
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// raw_stat_clear_sum
//-------------------------------------------------------------------------
-
static int
raw_stat_clear_sum(RecRawStatBlock *rsb, int id)
{
@@ -137,12 +136,12 @@ raw_stat_clear_sum(RecRawStatBlock *rsb,
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// raw_stat_clear_count
//-------------------------------------------------------------------------
-
static int
-raw_stat_clear_count(RecRawStatBlock * rsb, int id)
+raw_stat_clear_count(RecRawStatBlock *rsb, int id)
{
Debug("stats", "raw_stat_clear_count(): rsb pointer:%p id:%d\n", rsb, id);
@@ -162,12 +161,12 @@ raw_stat_clear_count(RecRawStatBlock * r
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// recv_message_cb__process
//-------------------------------------------------------------------------
-
static int
-recv_message_cb__process(RecMessage * msg, RecMessageT msg_type, void *cookie)
+recv_message_cb__process(RecMessage *msg, RecMessageT msg_type, void *cookie)
{
int err;
if ((err = recv_message_cb(msg, msg_type, cookie)) == REC_ERR_OKAY) {
@@ -180,58 +179,60 @@ recv_message_cb__process(RecMessage * ms
return err;
}
+
//-------------------------------------------------------------------------
// raw_stat_sync_cont
//-------------------------------------------------------------------------
-
struct raw_stat_sync_cont:public Continuation
{
- raw_stat_sync_cont(ProxyMutex * m):Continuation(m)
+ raw_stat_sync_cont(ProxyMutex *m):Continuation(m)
{
SET_HANDLER(&raw_stat_sync_cont::exec_callbacks);
}
- int exec_callbacks(int event, Event * e)
+ int exec_callbacks(int event, Event *e)
{
REC_NOWARN_UNUSED(event);
REC_NOWARN_UNUSED(e);
while (true) {
RecExecRawStatSyncCbs();
+ Debug("statsproc", "raw_stat_sync_cont() processed");
sleep(REC_RAW_STAT_SYNC_INTERVAL_SEC);
}
return EVENT_DONE;
}
};
+
//-------------------------------------------------------------------------
// config_update_cont
//-------------------------------------------------------------------------
-
struct config_update_cont:public Continuation
{
- config_update_cont(ProxyMutex * m):Continuation(m)
+ config_update_cont(ProxyMutex *m):Continuation(m)
{
SET_HANDLER(&config_update_cont::exec_callbacks);
}
- int exec_callbacks(int event, Event * e)
+ int exec_callbacks(int event, Event *e)
{
REC_NOWARN_UNUSED(event);
REC_NOWARN_UNUSED(e);
while (true) {
RecExecConfigUpdateCbs();
+ Debug("statsproc", "config_update_cont() processed");
sleep(REC_CONFIG_UPDATE_INTERVAL_SEC);
}
return EVENT_DONE;
}
};
+
//-------------------------------------------------------------------------
// sync_cont
//-------------------------------------------------------------------------
-
struct sync_cont:public Continuation
{
textBuffer *m_tb;
- sync_cont(ProxyMutex * m):Continuation(m)
+ sync_cont(ProxyMutex *m):Continuation(m)
{
SET_HANDLER(&sync_cont::sync);
m_tb = NEW(new textBuffer(65536));
@@ -243,7 +244,7 @@ struct sync_cont:public Continuation
m_tb = NULL;
}
}
- int sync(int event, Event * e)
+ int sync(int event, Event *e)
{
REC_NOWARN_UNUSED(event);
REC_NOWARN_UNUSED(e);
@@ -257,20 +258,20 @@ struct sync_cont:public Continuation
RecFileWrite(h_file, m_tb->bufPtr(), m_tb->spaceUsed(), &nbytes);
RecFileClose(h_file);
}
+ Debug("statsproc", "sync_cont() processed");
sleep(REC_REMOTE_SYNC_INTERVAL_SEC);
}
return EVENT_DONE;
}
};
+
//-------------------------------------------------------------------------
// RecProcessInit
//-------------------------------------------------------------------------
-
int
-RecProcessInit(RecModeT mode_type, Diags * _diags)
+RecProcessInit(RecModeT mode_type, Diags *_diags)
{
-
if (g_initialized) {
return REC_ERR_OKAY;
}
@@ -305,16 +306,15 @@ RecProcessInit(RecModeT mode_type, Diags
g_initialized = true;
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecProcessInitMessage
//-------------------------------------------------------------------------
int
RecProcessInitMessage(RecModeT mode_type)
{
-
if (g_message_initialized) {
return REC_ERR_OKAY;
}
@@ -339,44 +339,44 @@ RecProcessInitMessage(RecModeT mode_type
g_message_initialized = true;
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecProcessStart
//-------------------------------------------------------------------------
-
int
RecProcessStart()
{
-
if (g_started) {
return REC_ERR_OKAY;
}
+ Debug("statsproc", "Starting sync processors:");
raw_stat_sync_cont *rssc = NEW(new raw_stat_sync_cont(new_ProxyMutex()));
+ Debug("statsproc", "\traw-stat syncer");
eventProcessor.spawn_thread(rssc);
config_update_cont *cuc = NEW(new config_update_cont(new_ProxyMutex()));
+ Debug("statsproc", "\tconfig syncer");
eventProcessor.spawn_thread(cuc);
sync_cont *sc = NEW(new sync_cont(new_ProxyMutex()));
+ Debug("statsproc", "\tremote syncer");
eventProcessor.spawn_thread(sc);
g_started = true;
return REC_ERR_OKAY;
-
}
+
//-------------------------------------------------------------------------
// RecAllocateRawStatBlock
//-------------------------------------------------------------------------
-
RecRawStatBlock *
RecAllocateRawStatBlock(int num_stats)
{
-
off_t ethr_stat_offset;
RecRawStatBlock *rsb;
@@ -394,18 +394,17 @@ RecAllocateRawStatBlock(int num_stats)
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)
+RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id,
+ RecRawStatSyncCb sync_cb)
{
-
- Debug("stats", "RecRawStatSyncCb(): rsb pointer:%p id:%d\n", rsb, id);
+ Debug("stats", "RecRawStatSyncCb(%s): rsb pointer:%p id:%d\n", name, rsb, id);
// check to see if we're good to proceed
ink_debug_assert(id < rsb->max_stats);
@@ -437,46 +436,53 @@ RecRegisterRawStat(RecRawStatBlock * rsb
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)
+RecRawStatSyncSum(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id)
{
REC_NOWARN_UNUSED(name);
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)
+RecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id)
{
REC_NOWARN_UNUSED(name);
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)
+RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id)
{
REC_NOWARN_UNUSED(name);
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;
@@ -487,11 +493,13 @@ RecRawStatSyncAvg(const char *name, RecD
}
int
-RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id)
+RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id)
{
REC_NOWARN_UNUSED(name);
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;
@@ -506,12 +514,13 @@ RecRawStatSyncHrTimeAvg(const char *name
}
int
-RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecData * data,
- RecRawStatBlock * rsb, int id)
+RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id)
{
REC_NOWARN_UNUSED(name);
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;
@@ -525,11 +534,13 @@ RecRawStatSyncIntMsecsToFloatSeconds(con
}
int
-RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id)
+RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id)
{
REC_NOWARN_UNUSED(name);
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;
@@ -543,12 +554,12 @@ RecRawStatSyncMHrTimeAvg(const char *nam
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// RecIncrRawStatXXX
//-------------------------------------------------------------------------
-
int
-RecIncrRawStatBlock(RecRawStatBlock * rsb, EThread * ethread, RecRawStat * stat_array)
+RecIncrRawStatBlock(RecRawStatBlock *rsb, EThread *ethread, RecRawStat *stat_array)
{
REC_NOWARN_UNUSED(rsb);
REC_NOWARN_UNUSED(ethread);
@@ -556,12 +567,12 @@ RecIncrRawStatBlock(RecRawStatBlock * rs
return REC_ERR_FAIL;
}
+
//-------------------------------------------------------------------------
// RecSetRawStatXXX
//-------------------------------------------------------------------------
-
int
-RecSetRawStatSum(RecRawStatBlock * rsb, int id, int64 data)
+RecSetRawStatSum(RecRawStatBlock *rsb, int id, int64 data)
{
raw_stat_clear_sum(rsb, id);
ink_atomic_swap64(&(rsb->global[id]->sum), data);
@@ -569,7 +580,7 @@ RecSetRawStatSum(RecRawStatBlock * rsb,
}
int
-RecSetRawStatCount(RecRawStatBlock * rsb, int id, int64 data)
+RecSetRawStatCount(RecRawStatBlock *rsb, int id, int64 data)
{
raw_stat_clear_count(rsb, id);
ink_atomic_swap64(&(rsb->global[id]->count), data);
@@ -577,19 +588,20 @@ RecSetRawStatCount(RecRawStatBlock * rsb
}
int
-RecSetRawStatBlock(RecRawStatBlock * rsb, RecRawStat * stat_array)
+RecSetRawStatBlock(RecRawStatBlock *rsb, RecRawStat *stat_array)
{
REC_NOWARN_UNUSED(rsb);
REC_NOWARN_UNUSED(stat_array);
return REC_ERR_FAIL;
}
+
//-------------------------------------------------------------------------
// RecGetRawStatXXX
//-------------------------------------------------------------------------
int
-RecGetRawStatSum(RecRawStatBlock * rsb, int id, int64 * data)
+RecGetRawStatSum(RecRawStatBlock *rsb, int id, int64 *data)
{
RecRawStat total;
raw_stat_get_total(rsb, id, &total);
@@ -598,7 +610,7 @@ RecGetRawStatSum(RecRawStatBlock * rsb,
}
int
-RecGetRawStatCount(RecRawStatBlock * rsb, int id, int64 * data)
+RecGetRawStatCount(RecRawStatBlock *rsb, int id, int64 *data)
{
RecRawStat total;
raw_stat_get_total(rsb, id, &total);
@@ -606,12 +618,12 @@ RecGetRawStatCount(RecRawStatBlock * rsb
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// RecIncrGlobalRawStatXXX
//-------------------------------------------------------------------------
-
int
-RecIncrGlobalRawStat(RecRawStatBlock * rsb, int id, int64 incr)
+RecIncrGlobalRawStat(RecRawStatBlock *rsb, int id, int64 incr)
{
ink_atomic_increment64(&(rsb->global[id]->sum), incr);
ink_atomic_increment64(&(rsb->global[id]->count), 1);
@@ -619,83 +631,83 @@ RecIncrGlobalRawStat(RecRawStatBlock * r
}
int
-RecIncrGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64 incr)
+RecIncrGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64 incr)
{
ink_atomic_increment64(&(rsb->global[id]->sum), incr);
return REC_ERR_OKAY;
}
int
-RecIncrGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64 incr)
+RecIncrGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64 incr)
{
ink_atomic_increment64(&(rsb->global[id]->count), incr);
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// RecSetGlobalRawStatXXX
//-------------------------------------------------------------------------
-
int
-RecSetGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64 data)
+RecSetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64 data)
{
ink_atomic_swap64(&(rsb->global[id]->sum), data);
return REC_ERR_OKAY;
}
int
-RecSetGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64 data)
+RecSetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64 data)
{
ink_atomic_swap64(&(rsb->global[id]->count), data);
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// RecGetGlobalRawStatXXX
//-------------------------------------------------------------------------
-
int
-RecGetGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64 * data)
+RecGetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64 *data)
{
*data = rsb->global[id]->sum;
return REC_ERR_OKAY;
}
int
-RecGetGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64 * data)
+RecGetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64 *data)
{
*data = rsb->global[id]->count;
return REC_ERR_OKAY;
}
+
//-------------------------------------------------------------------------
// RegGetGlobalRawStatXXXPtr
//-------------------------------------------------------------------------
-
RecRawStat *
-RecGetGlobalRawStatPtr(RecRawStatBlock * rsb, int id)
+RecGetGlobalRawStatPtr(RecRawStatBlock *rsb, int id)
{
return rsb->global[id];
}
int64 *
-RecGetGlobalRawStatSumPtr(RecRawStatBlock * rsb, int id)
+RecGetGlobalRawStatSumPtr(RecRawStatBlock *rsb, int id)
{
return &(rsb->global[id]->sum);
}
int64 *
-RecGetGlobalRawStatCountPtr(RecRawStatBlock * rsb, int id)
+RecGetGlobalRawStatCountPtr(RecRawStatBlock *rsb, int id)
{
return &(rsb->global[id]->count);
}
+
//-------------------------------------------------------------------------
// RecRegisterRawStatSyncCb
//-------------------------------------------------------------------------
-
int
-RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock * rsb, int id)
+RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock *rsb, int id)
{
int err = REC_ERR_FAIL;
RecRecord *r;
@@ -718,17 +730,15 @@ RecRegisterRawStatSyncCb(const char *nam
ink_rwlock_unlock(&g_records_rwlock);
return err;
-
}
+
//-------------------------------------------------------------------------
// RecExecRawStatSyncCbs
//-------------------------------------------------------------------------
-
int
RecExecRawStatSyncCbs()
{
-
RecRecord *r;
int i, num_records;
@@ -746,5 +756,4 @@ RecExecRawStatSyncCbs()
}
return REC_ERR_OKAY;
-
}
Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Wed Sep 22 20:30:04 2010
@@ -739,7 +739,7 @@ isWriteable(INKMBuffer bufp)
/******************************************************/
static MIMEFieldSDKHandle *
-sdk_alloc_field_handle(INKMBuffer bufp, MIMEHdrImpl * mh)
+sdk_alloc_field_handle(INKMBuffer bufp, MIMEHdrImpl *mh)
{
sdk_sanity_check_mbuffer(bufp);
HdrHeapSDKHandle *sdk_heap = (HdrHeapSDKHandle *) bufp;
@@ -751,7 +751,7 @@ sdk_alloc_field_handle(INKMBuffer bufp,
}
static void
-sdk_free_field_handle(INKMBuffer bufp, MIMEFieldSDKHandle * field_handle)
+sdk_free_field_handle(INKMBuffer bufp, MIMEFieldSDKHandle *field_handle)
{
sdk_sanity_check_mbuffer(bufp);
HdrHeapSDKHandle *sdk_heap = (HdrHeapSDKHandle *) bufp;
@@ -773,7 +773,7 @@ sdk_alloc_standalone_field(INKMBuffer bu
}
static void
-sdk_free_standalone_field(INKMBuffer bufp, MIMEField * sa_field)
+sdk_free_standalone_field(INKMBuffer bufp, MIMEField *sa_field)
{
sdk_sanity_check_mbuffer(bufp);
HdrHeapSDKHandle *sdk_heap = (HdrHeapSDKHandle *) bufp;
@@ -1182,7 +1182,7 @@ INKVConnInternal::handle_event(int event
}
VIO *
-INKVConnInternal::do_io_read(Continuation * c, int64 nbytes, MIOBuffer * buf)
+INKVConnInternal::do_io_read(Continuation *c, int64 nbytes, MIOBuffer *buf)
{
m_read_vio.buffer.writer_for(buf);
m_read_vio.op = VIO::READ;
@@ -1200,7 +1200,7 @@ INKVConnInternal::do_io_read(Continuatio
}
VIO *
-INKVConnInternal::do_io_write(Continuation * c, int64 nbytes, IOBufferReader * buf, bool owner)
+INKVConnInternal::do_io_write(Continuation *c, int64 nbytes, IOBufferReader *buf, bool owner)
{
ink_assert(!owner);
m_write_vio.buffer.reader_for(buf);
@@ -1221,7 +1221,7 @@ INKVConnInternal::do_io_write(Continuati
}
void
-INKVConnInternal::do_io_transform(VConnection * vc)
+INKVConnInternal::do_io_transform(VConnection *vc)
{
m_output_vc = vc;
}
@@ -1275,7 +1275,7 @@ INKVConnInternal::do_io_shutdown(Shutdow
}
void
-INKVConnInternal::reenable(VIO * vio)
+INKVConnInternal::reenable(VIO *vio)
{
NOWARN_UNUSED(vio);
if (ink_atomic_increment((int *) &m_event_count, 1) < 0) {
@@ -1349,7 +1349,7 @@ APIHook::next() const
void
-APIHooks::prepend(INKContInternal * cont)
+APIHooks::prepend(INKContInternal *cont)
{
APIHook *api_hook;
@@ -1360,7 +1360,7 @@ APIHooks::prepend(INKContInternal * cont
}
void
-APIHooks::append(INKContInternal * cont)
+APIHooks::append(INKContInternal *cont)
{
APIHook *api_hook;
@@ -1408,14 +1408,14 @@ HttpAPIHooks::clear()
}
void
-HttpAPIHooks::prepend(INKHttpHookID id, INKContInternal * cont)
+HttpAPIHooks::prepend(INKHttpHookID id, INKContInternal *cont)
{
hooks_set = 1;
m_hooks[id].prepend(cont);
}
void
-HttpAPIHooks::append(INKHttpHookID id, INKContInternal * cont)
+HttpAPIHooks::append(INKHttpHookID id, INKContInternal *cont)
{
hooks_set = 1;
m_hooks[id].append(cont);
@@ -1459,7 +1459,7 @@ CacheAPIHooks::clear()
}
void
-CacheAPIHooks::append(INKCacheHookID id, INKContInternal * cont)
+CacheAPIHooks::append(INKCacheHookID id, INKContInternal *cont)
{
hooks_set = 1;
m_hooks[id].append(cont);
@@ -1472,7 +1472,7 @@ CacheAPIHooks::get(INKCacheHookID id)
}
void
-CacheAPIHooks::prepend(INKCacheHookID id, INKContInternal * cont)
+CacheAPIHooks::prepend(INKCacheHookID id, INKContInternal *cont)
{
hooks_set = 1;
m_hooks[id].prepend(cont);
@@ -1498,7 +1498,7 @@ ConfigUpdateCbTable::~ConfigUpdateCbTabl
}
void
-ConfigUpdateCbTable::insert(INKContInternal * contp, const char *name, const char *config_path)
+ConfigUpdateCbTable::insert(INKContInternal *contp, const char *name, const char *config_path)
{
ink_assert(cb_table != NULL);
@@ -1544,7 +1544,7 @@ ConfigUpdateCbTable::invoke(const char *
}
void
-ConfigUpdateCbTable::invoke(INKContInternal * contp)
+ConfigUpdateCbTable::invoke(INKContInternal *contp)
{
eventProcessor.schedule_imm(NEW(new ConfigUpdateCallback(contp)), ET_NET);
}
@@ -1933,7 +1933,7 @@ INKPluginDirGet(void)
////////////////////////////////////////////////////////////////////
int
-INKPluginRegister(INKSDKVersion sdk_version, INKPluginRegistrationInfo * plugin_info)
+INKPluginRegister(INKSDKVersion sdk_version, INKPluginRegistrationInfo *plugin_info)
{
ink_assert(plugin_reg_current != NULL);
@@ -1974,7 +1974,7 @@ INKPluginRegister(INKSDKVersion sdk_vers
////////////////////////////////////////////////////////////////////
INKReturnCode
-INKPluginInfoRegister(INKPluginRegistrationInfo * plugin_info)
+INKPluginInfoRegister(INKPluginRegistrationInfo *plugin_info)
{
if (sdk_sanity_check_null_ptr((void *) plugin_info) == INK_ERROR) {
return INK_ERROR;
@@ -3771,7 +3771,7 @@ INKMimeHdrFieldValueStringGet(INKMBuffer
}
INKReturnCode
-INKMimeHdrFieldValueDateGet(INKMBuffer bufp, INKMLoc hdr, INKMLoc field, time_t * value_ptr)
+INKMimeHdrFieldValueDateGet(INKMBuffer bufp, INKMLoc hdr, INKMLoc field, time_t *value_ptr)
{
if ((sdk_sanity_check_mbuffer(bufp) == INK_SUCCESS) &&
((sdk_sanity_check_mime_hdr_handle(hdr) == INK_SUCCESS) || (sdk_sanity_check_http_hdr_handle(hdr) == INK_SUCCESS))
@@ -4675,7 +4675,7 @@ INKCacheHeaderKeyGet(INKCacheTxn txnp, v
}
INKReturnCode
-INKCacheKeyCreate(INKCacheKey * new_key)
+INKCacheKeyCreate(INKCacheKey *new_key)
{
#ifdef DEBUG
if (new_key == NULL)
@@ -4781,7 +4781,7 @@ INKCacheHttpInfoCopy(INKCacheHttpInfo in
}
void
-INKCacheHttpInfoReqGet(INKCacheHttpInfo infop, INKMBuffer * bufp, INKMLoc * obj)
+INKCacheHttpInfoReqGet(INKCacheHttpInfo infop, INKMBuffer *bufp, INKMLoc *obj)
{
CacheHTTPInfo *info = (CacheHTTPInfo *) infop;
*bufp = info->request_get();
@@ -4791,7 +4791,7 @@ INKCacheHttpInfoReqGet(INKCacheHttpInfo
void
-INKCacheHttpInfoRespGet(INKCacheHttpInfo infop, INKMBuffer * bufp, INKMLoc * obj)
+INKCacheHttpInfoRespGet(INKCacheHttpInfo infop, INKMBuffer *bufp, INKMLoc *obj)
{
CacheHTTPInfo *info = (CacheHTTPInfo *) infop;
*bufp = info->response_get();
@@ -4843,7 +4843,7 @@ INKCacheHttpInfoVector(INKCacheHttpInfo
void
-INKCacheHttpInfoDestroy(INKCacheHttpInfo * infop)
+INKCacheHttpInfoDestroy(INKCacheHttpInfo *infop)
{
((CacheHTTPInfo *) infop)->destroy();
@@ -4913,26 +4913,25 @@ INKMgmtUpdateRegister(INKCont contp, con
}
int
-INKMgmtIntGet(const char *var_name, INKMgmtInt * result)
+INKMgmtIntGet(const char *var_name, INKMgmtInt *result)
{
return RecGetRecordInt((char *) var_name, (RecInt *) result) == REC_ERR_OKAY ? 1 : 0;
-
}
int
-INKMgmtCounterGet(const char *var_name, INKMgmtCounter * result)
+INKMgmtCounterGet(const char *var_name, INKMgmtCounter *result)
{
return RecGetRecordCounter((char *) var_name, (RecCounter *) result) == REC_ERR_OKAY ? 1 : 0;
}
int
-INKMgmtFloatGet(const char *var_name, INKMgmtFloat * result)
+INKMgmtFloatGet(const char *var_name, INKMgmtFloat *result)
{
return RecGetRecordFloat((char *) var_name, (RecFloat *) result) == REC_ERR_OKAY ? 1 : 0;
}
int
-INKMgmtStringGet(const char *var_name, INKMgmtString * result)
+INKMgmtStringGet(const char *var_name, INKMgmtString *result)
{
RecString tmp = 0;
(void) RecGetRecordString_Xmalloc((char *) var_name, &tmp);
@@ -5120,7 +5119,7 @@ INKHttpSsnHookAdd(INKHttpSsn ssnp, INKHt
class INKHttpSsnCallback:public Continuation
{
public:
- INKHttpSsnCallback(HttpClientSession * cs, INKEvent event)
+ INKHttpSsnCallback(HttpClientSession *cs, INKEvent event)
:Continuation(cs->mutex), m_cs(cs), m_event(event)
{
SET_HANDLER(&INKHttpSsnCallback::event_handler);
@@ -5134,7 +5133,7 @@ public:
}
private:
- HttpClientSession * m_cs;
+ HttpClientSession *m_cs;
INKEvent m_event;
};
@@ -5213,7 +5212,7 @@ int
INKHttpTxnClientKeepaliveSet(INKHttpTxn txnp)
{
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
s->hdr_info.trust_response_cl = true;
return 1;
@@ -5221,7 +5220,7 @@ INKHttpTxnClientKeepaliveSet(INKHttpTxn
int
-INKHttpTxnClientReqGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnClientReqGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS ||
sdk_sanity_check_null_ptr((void *) bufp) != INK_SUCCESS ||
@@ -5269,7 +5268,7 @@ INKHttpTxnPristineUrlGet (INKHttpTxn txn
int
-INKHttpTxnClientRespGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnClientRespGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS ||
sdk_sanity_check_null_ptr((void *) bufp) != INK_SUCCESS ||
@@ -5292,7 +5291,7 @@ INKHttpTxnClientRespGet(INKHttpTxn txnp,
int
-INKHttpTxnServerReqGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnServerReqGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS ||
sdk_sanity_check_null_ptr((void *) bufp) != INK_SUCCESS ||
@@ -5314,7 +5313,7 @@ INKHttpTxnServerReqGet(INKHttpTxn txnp,
}
int
-INKHttpTxnServerRespGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnServerRespGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS ||
sdk_sanity_check_null_ptr((void *) bufp) != INK_SUCCESS ||
@@ -5336,7 +5335,7 @@ INKHttpTxnServerRespGet(INKHttpTxn txnp,
}
int
-INKHttpTxnCachedReqGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnCachedReqGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS ||
sdk_sanity_check_null_ptr((void *) bufp) != INK_SUCCESS ||
@@ -5374,7 +5373,7 @@ INKHttpTxnCachedReqGet(INKHttpTxn txnp,
}
int
-INKHttpTxnCachedRespGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnCachedRespGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS ||
sdk_sanity_check_null_ptr((void *) bufp) != INK_SUCCESS ||
@@ -5413,10 +5412,10 @@ INKHttpTxnCachedRespGet(INKHttpTxn txnp,
int
-INKHttpTxnCachedRespModifiableGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnCachedRespModifiableGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
HTTPHdr *c_resp = NULL;
HTTPInfo *cached_obj = sm->t_state.cache_info.object_read;
HTTPInfo *cached_obj_store = &(sm->t_state.cache_info.object_store);
@@ -5494,7 +5493,7 @@ int
INKHttpTxnCacheLookupStatusSet(INKHttpTxn txnp, int cachelookup)
{
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::CacheLookupResult_t * sm_status = &(sm->t_state.cache_lookup_result);
+ HttpTransact::CacheLookupResult_t *sm_status = &(sm->t_state.cache_lookup_result);
// converting from a miss to a hit is not allowed
if (*sm_status == HttpTransact::CACHE_LOOKUP_MISS && cachelookup != INK_CACHE_LOOKUP_MISS)
@@ -5584,7 +5583,7 @@ INKHttpTxnNewCacheLookupDo(INKHttpTxn tx
return 0;
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
client_url = s->hdr_info.client_request.url_get();
if (!(client_url->valid()))
@@ -5625,7 +5624,7 @@ int
INKHttpTxnSecondUrlTryLock(INKHttpTxn txnp)
{
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
// INKHttpTxnNewCacheLookupDo didn't continue
if (!s->cache_info.original_url.valid())
return 0;
@@ -5651,7 +5650,7 @@ INKHttpTxnRedirectRequest(INKHttpTxn txn
{
URL u, *o_url, *r_url, *client_url;
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
u.m_heap = ((HdrHeapSDKHandle *) bufp)->m_heap;
u.m_url_impl = (URLImpl *) url_loc;
@@ -5697,7 +5696,7 @@ int
INKHttpTxnActiveTimeoutSet(INKHttpTxn txnp, int timeout)
{
Debug("http_timeout", "setting active timeout to %d msec via API", timeout);
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->api_txn_active_timeout_value = timeout;
return 1;
}
@@ -5710,7 +5709,7 @@ int
INKHttpTxnConnectTimeoutSet(INKHttpTxn txnp, int timeout)
{
Debug("http_timeout", "setting inactive timeout to %d msec via API", timeout);
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->api_txn_connect_timeout_value = timeout;
return 1;
}
@@ -5723,7 +5722,7 @@ int
INKHttpTxnDNSTimeoutSet(INKHttpTxn txnp, int timeout)
{
Debug("http_timeout", "setting DNS timeout to %d msec via API", timeout);
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->api_txn_dns_timeout_value = timeout;
return 1;
}
@@ -5737,7 +5736,7 @@ int
INKHttpTxnNoActivityTimeoutSet(INKHttpTxn txnp, int timeout)
{
Debug("http_timeout", "setting DNS timeout to %d msec via API", timeout);
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->api_txn_no_activity_timeout_value = timeout;
return 1;
}
@@ -5745,7 +5744,7 @@ INKHttpTxnNoActivityTimeoutSet(INKHttpTx
int
INKHttpTxnCacheLookupSkip(INKHttpTxn txnp)
{
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->api_skip_cache_lookup = true;
return 1;
}
@@ -5753,7 +5752,7 @@ INKHttpTxnCacheLookupSkip(INKHttpTxn txn
int
INKHttpTxnServerRespNoStore(INKHttpTxn txnp)
{
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->api_server_response_no_store = true;
return 1;
}
@@ -5761,7 +5760,7 @@ INKHttpTxnServerRespNoStore(INKHttpTxn t
int
INKHttpTxnServerRespIgnore(INKHttpTxn txnp)
{
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
HTTPInfo *cached_obj = s->cache_info.object_read;
HTTPHdr *cached_resp;
@@ -5782,7 +5781,7 @@ INKHttpTxnShutDown(INKHttpTxn txnp, INKE
if (event == INK_EVENT_HTTP_TXN_CLOSE)
return 0;
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->api_http_sm_shutdown = true;
return 1;
}
@@ -5832,7 +5831,7 @@ INKHttpTxnClientReqIsServerStyle(INKHttp
int
INKHttpTxnOverwriteExpireTime(INKHttpTxn txnp, time_t expire_time)
{
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
s->plugin_set_expire_time = expire_time;
return 1;
}
@@ -5841,7 +5840,7 @@ int
INKHttpTxnUpdateCachedObject(INKHttpTxn txnp)
{
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
HTTPInfo *cached_obj_store = &(sm->t_state.cache_info.object_store);
HTTPHdr *client_request = &(sm->t_state.hdr_info.client_request);
@@ -5859,7 +5858,7 @@ INKHttpTxnUpdateCachedObject(INKHttpTxn
}
int
-INKHttpTxnTransformRespGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpTxnTransformRespGet(INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *obj)
{
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS) {
return 0;
@@ -5968,7 +5967,7 @@ void
INKHttpTxnServerRequestBodySet(INKHttpTxn txnp, char *buf, int buflength)
{
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
if (buf == NULL || buflength <= 0 || s->method != HTTP_WKSIDX_GET)
return;
@@ -6038,7 +6037,7 @@ INKHttpTxnTransformedRespCache(INKHttpTx
class INKHttpSMCallback:public Continuation
{
public:
- INKHttpSMCallback(HttpSM * sm, INKEvent event)
+ INKHttpSMCallback(HttpSM *sm, INKEvent event)
:Continuation(sm->mutex), m_sm(sm), m_event(event)
{
SET_HANDLER(&INKHttpSMCallback::event_handler);
@@ -6052,7 +6051,7 @@ public:
}
private:
- HttpSM * m_sm;
+ HttpSM *m_sm;
INKEvent m_event;
};
@@ -6071,7 +6070,7 @@ INKCacheBufferReaderGet(INKCacheTxn txnp
//INKReturnCode
//INKCacheBufferInfoGet(INKHttpTxn txnp, void **buffer, INKU64 *length, INKU64 *offset)
INKReturnCode
-INKCacheBufferInfoGet(INKCacheTxn txnp, INKU64 * length, INKU64 * offset)
+INKCacheBufferInfoGet(INKCacheTxn txnp, INKU64 *length, INKU64 *offset)
{
NewCacheVC *vc = (NewCacheVC *) txnp;
@@ -6270,7 +6269,7 @@ INKHttpTxnSetHttpRetBody(INKHttpTxn txnp
{
if (sdk_sanity_check_txn(txnp) == INK_SUCCESS) {
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
s->return_xbuf_size = 0;
s->return_xbuf[0] = 0;
s->return_xbuf_plain = false;
@@ -6359,7 +6358,7 @@ INKHttpTxnServerStateGet(INKHttpTxn txnp
if (sdk_sanity_check_txn(txnp) != INK_SUCCESS)
return INK_SRVSTATE_STATE_UNDEFINED;
- HttpTransact::State * s = &(((HttpSM *) txnp)->t_state);
+ HttpTransact::State *s = &(((HttpSM *) txnp)->t_state);
return (INKServerState) s->current.state;
}
@@ -6445,7 +6444,7 @@ INKHttpTxnPushedRespBodyBytesGet(INKHttp
}
int
-INKHttpTxnStartTimeGet(INKHttpTxn txnp, INK64 * start_time)
+INKHttpTxnStartTimeGet(INKHttpTxn txnp, INK64 *start_time)
{
HttpSM *sm = (HttpSM *) txnp;
if (sm->milestones.ua_begin == 0)
@@ -6457,7 +6456,7 @@ INKHttpTxnStartTimeGet(INKHttpTxn txnp,
}
int
-INKHttpTxnEndTimeGet(INKHttpTxn txnp, INK64 * end_time)
+INKHttpTxnEndTimeGet(INKHttpTxn txnp, INK64 *end_time)
{
HttpSM *sm = (HttpSM *) txnp;
if (sm->milestones.ua_close == 0)
@@ -6511,7 +6510,7 @@ int
INKHttpTxnLookingUpTypeGet(INKHttpTxn txnp)
{
HttpSM *sm = (HttpSM *) txnp;
- HttpTransact::State * s = &(sm->t_state);
+ HttpTransact::State *s = &(sm->t_state);
return (int) (s->current.request_to);
}
@@ -6575,7 +6574,7 @@ INKHttpCurrentServerConnectionsGet(int *
/* HTTP alternate selection */
INKReturnCode
-INKHttpAltInfoClientReqGet(INKHttpAltInfo infop, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpAltInfoClientReqGet(INKHttpAltInfo infop, INKMBuffer *bufp, INKMLoc *obj)
{
HttpAltInfo *info = (HttpAltInfo *) infop;
@@ -6591,7 +6590,7 @@ INKHttpAltInfoClientReqGet(INKHttpAltInf
}
INKReturnCode
-INKHttpAltInfoCachedReqGet(INKHttpAltInfo infop, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpAltInfoCachedReqGet(INKHttpAltInfo infop, INKMBuffer *bufp, INKMLoc *obj)
{
HttpAltInfo *info = (HttpAltInfo *) infop;
if (sdk_sanity_check_alt_info(infop) != INK_SUCCESS) {
@@ -6606,7 +6605,7 @@ INKHttpAltInfoCachedReqGet(INKHttpAltInf
}
INKReturnCode
-INKHttpAltInfoCachedRespGet(INKHttpAltInfo infop, INKMBuffer * bufp, INKMLoc * obj)
+INKHttpAltInfoCachedRespGet(INKHttpAltInfo infop, INKMBuffer *bufp, INKMLoc *obj)
{
HttpAltInfo *info = (HttpAltInfo *) infop;
if (sdk_sanity_check_alt_info(infop) != INK_SUCCESS) {
@@ -6634,7 +6633,7 @@ INKHttpAltInfoQualitySet(INKHttpAltInfo
extern HttpAccept *plugin_http_accept;
INKReturnCode
-INKHttpConnect(unsigned int log_ip, int log_port, INKVConn * vc)
+INKHttpConnect(unsigned int log_ip, int log_port, INKVConn *vc)
{
#ifdef DEBUG
if (vc == NULL) {
@@ -7199,6 +7198,9 @@ TSRegisterStat(const char *the_name, TSS
int volatile ix = ink_atomic_increment(&top_stat, 1);
RecRawStatSyncCb syncer = RecRawStatSyncCount;
+ if (sdk_sanity_check_null_ptr((void *)the_name) != INK_SUCCESS)
+ return INK_ERROR;
+
switch (sync) {
case TS_STAT_SYNC_SUM:
syncer = RecRawStatSyncSum;
@@ -7209,61 +7211,56 @@ TSRegisterStat(const char *the_name, TSS
case TS_STAT_SYNC_TIMEAVG:
syncer = RecRawStatSyncHrTimeAvg;
break;
- case TS_STAT_SYNC_MSECS_TO_SECONDS:
- syncer = RecRawStatSyncIntMsecsToFloatSeconds;
- break;
- case TS_STAT_SYNC_MHR_TIMEAVG:
- syncer = RecRawStatSyncMHrTimeAvg;
- break;
default:
syncer = RecRawStatSyncCount;
break;
}
- RecRegisterRawStat(api_rsb, RECT_PROCESS, the_name, (RecDataT)the_type, RecPersistT(persist), ix, syncer);
+ RecRegisterRawStat(api_rsb, RECT_PLUGIN, the_name, (RecDataT)the_type, RecPersistT(persist), ix, syncer);
return ix;
}
INKReturnCode
-TSStatIntIncrement(int the_stat, INK64 amount)
+TSStatIntIncrement(int the_stat, INKMgmtInt amount)
{
RecIncrRawStat(api_rsb, NULL, the_stat, amount);
return INK_SUCCESS;
}
INKReturnCode
-TSStatIntDecrement(int the_stat, INK64 amount)
+TSStatIntDecrement(int the_stat, INKMgmtInt amount)
{
RecDecrRawStat(api_rsb, NULL, the_stat, amount);
return INK_SUCCESS;
}
INKReturnCode
-TSStatIntGet(int the_stat, INK64* value)
+TSStatIntGet(int the_stat, INKMgmtInt* value)
{
RecGetGlobalRawStatSum(api_rsb, the_stat, value);
return INK_SUCCESS;
}
INKReturnCode
-TSStatIntSet(int the_stat, INK64 value)
+TSStatIntSet(int the_stat, INKMgmtInt value)
{
RecSetGlobalRawStatSum(api_rsb, the_stat, value);
return INK_SUCCESS;
}
-INKReturnCode
-TSStatCountGet(int the_stat, INK64* value)
+int
+TSStatsFindName(const char* name)
{
- RecGetGlobalRawStatCount(api_rsb, the_stat, value);
- return INK_SUCCESS;
-}
+ int order;
-INKReturnCode
-TSStatCountSet(int the_stat, INK64 value)
-{
- RecSetGlobalRawStatCount(api_rsb, the_stat, value);
- return INK_SUCCESS;
+ if (sdk_sanity_check_null_ptr((void *)name) != INK_SUCCESS ||
+ sdk_sanity_check_null_ptr((void *)order) != INK_SUCCESS)
+ return INK_ERROR;
+
+ if (RecGetRecordRelativeOrder(name, &order) == REC_ERR_OKAY)
+ return order;
+
+ return -1;
}
@@ -7442,7 +7439,7 @@ INKStatGetByNameV2(
#endif
INKReturnCode
-INKStatIntGet(INKStat the_stat, INK64 * value)
+INKStatIntGet(INKStat the_stat, INK64 *value)
{
if (ink_sanity_check_stat_structure(the_stat) != INK_SUCCESS)
return INK_ERROR;
@@ -7627,7 +7624,7 @@ INKDebug(const char *tag, const char *fo
/************************** Logging API ****************************/
INKReturnCode
-INKTextLogObjectCreate(const char *filename, int mode, INKTextLogObject * new_object)
+INKTextLogObjectCreate(const char *filename, int mode, INKTextLogObject *new_object)
{
#ifdef DEBUG
if (filename == NULL) {
@@ -7864,7 +7861,7 @@ INKMatcherTokLine(char *buffer, char **l
}
char *
-INKMatcherExtractIPRange(char *match_str, INKU32 * addr1, INKU32 * addr2)
+INKMatcherExtractIPRange(char *match_str, INKU32 *addr1, INKU32 *addr2)
{
return (char*)ExtractIpRange(match_str, (ip_addr_t *) addr1, (ip_addr_t *) addr2);
}
@@ -7944,7 +7941,7 @@ INKICPFreshnessFuncSet(INKPluginFreshnes
}
int
-INKICPCachedReqGet(INKCont contp, INKMBuffer * bufp, INKMLoc * obj)
+INKICPCachedReqGet(INKCont contp, INKMBuffer *bufp, INKMLoc *obj)
{
ICPPeerReadCont *sm = (ICPPeerReadCont *) contp;
HTTPInfo *cached_obj;
@@ -7977,7 +7974,7 @@ INKICPCachedReqGet(INKCont contp, INKMBu
}
int
-INKICPCachedRespGet(INKCont contp, INKMBuffer * bufp, INKMLoc * obj)
+INKICPCachedRespGet(INKCont contp, INKMBuffer *bufp, INKMLoc *obj)
{
ICPPeerReadCont *sm = (ICPPeerReadCont *) contp;
HTTPInfo *cached_obj;
@@ -8126,7 +8123,7 @@ INKFetchPageRespGet (INKHttpTxn txnp, IN
}
extern ClassAllocator<FetchSM> FetchSMAllocator;
-INKReturnCode INKFetchPages(INKFetchUrlParams_t * params)
+INKReturnCode INKFetchPages(INKFetchUrlParams_t *params)
{
INKFetchUrlParams_t *myparams = params;
while(myparams!=NULL) {
Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h Wed Sep 22 20:30:04 2010
@@ -2389,16 +2389,17 @@ extern "C"
inkapi int TSRegisterStat(const char *the_name, TSStatDataType the_type, TSStatPersistence persist, TSStatSync sync);
- inkapi INKReturnCode TSStatIntIncrement(int the_stat, INK64 amount);
- inkapi INKReturnCode TSStatIntDecrement(int the_stat, INK64 amount);
+ inkapi INKReturnCode TSStatIntIncrement(int the_stat, INKMgmtInt amount);
+ inkapi INKReturnCode TSStatIntDecrement(int the_stat, INKMgmtInt amount);
inkapi INKReturnCode TSStatFloatIncrement(int the_stat, float amount);
inkapi INKReturnCode TSStatFloatDecrement(int the_stat, float amount);
- inkapi INKReturnCode TSStatIntGet(int the_stat, INK64* value);
- inkapi INKReturnCode TSStatIntSet(int the_stat, INK64 value);
+ inkapi INKReturnCode TSStatIntGet(int the_stat, INKMgmtInt* value);
+ inkapi INKReturnCode TSStatIntSet(int the_stat, INKMgmtInt value);
inkapi INKReturnCode TSStatFloatGet(int the_stat, float* value);
inkapi INKReturnCode TSStatFloatSet(int the_stat, float value);
+ inkapi int TSStatsFindName(const char* name);
/* --------------------------------------------------------------------------
This is the old stats system, it's completely deprecated, and should not
Modified: trafficserver/traffic/trunk/proxy/stats/Stats.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/stats/Stats.cc?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/stats/Stats.cc (original)
+++ trafficserver/traffic/trunk/proxy/stats/Stats.cc Wed Sep 22 20:30:04 2010
@@ -20,9 +20,6 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-
-
-
#define _s_impl
#include "ink_config.h"
#include "Stats.h"
@@ -51,7 +48,8 @@ StatDescriptor::initialize()
// ink_release_assert (g_stat_block);
}
-RecData StatDescriptor::update_value()
+RecData
+StatDescriptor::update_value()
{
RecData retv;
@@ -148,16 +146,12 @@ StatDescriptor::CreateDescriptor(const c
Warning("Plugin stat space exhausted");
// return &G_NULL_STAT;
return NULL;
- }
-
- else if (RecGetRecordDataType((char *) name, &dt) == REC_ERR_OKAY) {
+ } else if (RecGetRecordDataType((char *) name, &dt) == REC_ERR_OKAY) {
Debug("sdk_stats", "Attempt to re-register statistic '%s'", name);
// return &G_NULL_STAT;
return NULL;
- }
-
- else {
- StatDescriptor & ref = all_stats[n_stat];
+ } else {
+ StatDescriptor &ref = all_stats[n_stat];
ref.m_id = n_stat;
ink_assert(ref.m_name == NULL);
size_t len = strlen(name) + 1;
@@ -167,17 +161,14 @@ StatDescriptor::CreateDescriptor(const c
ref.m_value.rec_int = init_value;
ref.m_magic = ALIVE;
- int rc = RecRegisterStatInt(RECT_PLUGIN, ref.m_name,
- init_value, RECP_NON_PERSISTENT);
-
- if (rc == REC_ERR_FAIL) {
+ if (RecRegisterStatInt(RECT_PLUGIN, ref.m_name, init_value, RECP_NON_PERSISTENT) == REC_ERR_FAIL) {
ref.m_magic = IN_ERROR;
}
return &all_stats[n_stat];
}
}
-StatDescriptor *
+StatDescriptor*
StatDescriptor::CreateDescriptor(const char *name, float init_value)
{
int n_stat = ink_atomic_increment(&top_stat, 1);
@@ -185,17 +176,12 @@ StatDescriptor::CreateDescriptor(const c
if (n_stat >= StatDescriptor::MAX_NUM_STATS) {
Warning("Plugin stat space exhausted");
- // return &G_NULL_STAT;
return NULL;
- }
-
- else if (RecGetRecordDataType((char *) name, &dt) == REC_ERR_OKAY) {
+ } else if (RecGetRecordDataType((char *) name, &dt) == REC_ERR_OKAY) {
Debug("sdk_stats", "Attempt to re-register statistic '%s'", name);
// return &G_NULL_STAT;
return NULL;
- }
-
- else {
+ } else {
StatDescriptor & ref = all_stats[n_stat];
ref.m_id = n_stat;
ink_assert(ref.m_name == NULL);
@@ -206,10 +192,7 @@ StatDescriptor::CreateDescriptor(const c
ref.m_value.rec_float = init_value;
ref.m_magic = ALIVE;
- int rc = RecRegisterStatFloat(RECT_PLUGIN, ref.m_name,
- init_value, RECP_NON_PERSISTENT);
-
- if (rc == REC_ERR_FAIL) {
+ if (RecRegisterStatFloat(RECT_PLUGIN, ref.m_name, init_value, RECP_NON_PERSISTENT) == REC_ERR_FAIL) {
ref.m_magic = IN_ERROR;
}
return &all_stats[n_stat];
@@ -224,8 +207,7 @@ StatDescriptor::set(int64 val)
} else if (m_magic == NULL_VALUE || m_magic == IN_ERROR) {
m_magic = IN_ERROR;
} else {
- int rc = RecSetRecordInt(m_name, val);
- if (rc == REC_ERR_FAIL) {
+ if (RecSetRecordInt(m_name, val) == REC_ERR_FAIL) {
m_magic = IN_ERROR;
}
}
@@ -241,8 +223,7 @@ StatDescriptor::set(float val)
} else if (m_magic == NULL_VALUE || m_magic == IN_ERROR) {
m_magic = IN_ERROR;
} else {
- int rc = RecSetRecordFloat(m_name, val);
- if (rc == REC_ERR_FAIL) {
+ if (RecSetRecordFloat(m_name, val) == REC_ERR_FAIL) {
m_magic = IN_ERROR;
}
}
@@ -258,6 +239,7 @@ StatDescriptor::add(int64 val)
} else {
RecInt v;
ink_mutex_acquire(&g_flt_mux);
+
int rc = RecGetRecordInt(m_name, &v);
if (rc == REC_ERR_OKAY) {
rc = RecSetRecordInt(m_name, v + val);
@@ -281,6 +263,7 @@ StatDescriptor::add(float val)
} else {
RecFloat v;
ink_mutex_acquire(&g_flt_mux);
+
int rc = RecGetRecordFloat(m_name, &v);
if (rc == REC_ERR_OKAY) {
rc = RecSetRecordFloat(m_name, v + val);
@@ -297,13 +280,11 @@ StatDescriptor::commit()
{
if (m_magic == SHALLOW_COPY) {
if (m_type == RECD_INT) {
- int rc = RecSetRecordInt(m_name, m_value.rec_int);
- if (rc == REC_ERR_FAIL) {
+ if (RecSetRecordInt(m_name, m_value.rec_int) == REC_ERR_FAIL) {
m_magic = IN_ERROR;
}
} else {
- int rc = RecSetRecordFloat(m_name, m_value.rec_float);
- if (rc == REC_ERR_FAIL) {
+ if (RecSetRecordFloat(m_name, m_value.rec_float) == REC_ERR_FAIL) {
m_magic = IN_ERROR;
}
}
Modified: trafficserver/traffic/trunk/proxy/stats/Stats.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/stats/Stats.h?rev=1000195&r1=1000194&r2=1000195&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/stats/Stats.h (original)
+++ trafficserver/traffic/trunk/proxy/stats/Stats.h Wed Sep 22 20:30:04 2010
@@ -64,40 +64,20 @@ private:
static volatile int top_stat;
public:
-
static StatDescriptor *CreateDescriptor(const char *category, char *name, size_t name_len, int64 init_value);
-
static StatDescriptor *CreateDescriptor(const char *category, char *name, size_t name_len, float init_value);
-
static StatDescriptor *CreateDescriptor(const char *name, int64 init_value);
-
static StatDescriptor *CreateDescriptor(const char *name, float init_value);
-
static void initialize();
+ const char *name() const { return m_name; }
- const char *name() const
- {
- return m_name;
- }
int64 int_value() const;
float flt_value() const;
- bool int_type() const
- {
- return m_type == RECD_INT;
- }
- bool copy() const
- {
- return m_magic == SHALLOW_COPY;
- }
- bool dead() const
- {
- return (m_magic == NULL_VALUE || m_magic == IN_ERROR);
- }
- bool live() const
- {
- return (m_magic == ALIVE && m_id >= 0);
- }
+ bool int_type() const { return m_type == RECD_INT; }
+ bool copy() const { return m_magic == SHALLOW_COPY; }
+ bool dead() const { return (m_magic == NULL_VALUE || m_magic == IN_ERROR); }
+ bool live() const { return (m_magic == ALIVE && m_id >= 0); }
void increment()
{
@@ -130,15 +110,15 @@ public:
void commit();
// to support coupled-stat local copies
-StatDescriptor():m_magic(NULL_VALUE), m_id(0), m_name(NULL) {
- m_type = RECD_NULL;
- }
+ StatDescriptor()
+ : m_magic(NULL_VALUE), m_id(0), m_name(NULL), m_type(RECD_NULL)
+ { }
~StatDescriptor() {
} // [footnote]
+
StatDescriptor & operator=(const StatDescriptor & rhs);
private:
-
RecData update_value();
int m_id;
@@ -202,8 +182,7 @@ StatDescriptor::int_value() const
return 0;
}
- RecData tmp = (m_magic == SHALLOW_COPY)
- ? m_value : const_cast<StatDescriptor *>(this)->update_value();
+ RecData tmp = (m_magic == SHALLOW_COPY) ? m_value : const_cast<StatDescriptor *>(this)->update_value();
return m_type == RECD_INT ? tmp.rec_int : (int64) tmp.rec_float;
}
@@ -218,8 +197,7 @@ StatDescriptor::flt_value() const
return 0.0;
}
- RecData tmp = (m_magic == SHALLOW_COPY)
- ? m_value : const_cast<StatDescriptor *>(this)->update_value();
+ RecData tmp = (m_magic == SHALLOW_COPY) ? m_value : const_cast<StatDescriptor *>(this)->update_value();
return m_type == RECD_INT ? (float) tmp.rec_int : tmp.rec_float;
}