本文整理汇总了C++中TSDebug函数的典型用法代码示例。如果您正苦于以下问题:C++ TSDebug函数的具体用法?C++ TSDebug怎么用?C++ TSDebug使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TSDebug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cont_data_destroy
/*-------------------------------------------------------------------------
cont_data_destroy
Deallocate ContData structure associated to a transaction
Input:
data structure to deallocate
Output:
Return Value:
none
-------------------------------------------------------------------------*/
static void
cont_data_destroy(ContData * data)
{
TSDebug(DBG_TAG, "Destroying continuation data");
if (data) {
TSAssert(data->magic == MAGIC_ALIVE);
if (data->output_reader) {
TSIOBufferReaderFree(data->output_reader);
data->output_reader = NULL;
}
if (data->output_buffer) {
TSIOBufferDestroy(data->output_buffer);
data->output_buffer = NULL;
}
if (data->psi_reader) {
TSIOBufferReaderFree(data->psi_reader);
data->psi_reader = NULL;
}
if (data->psi_buffer) {
TSIOBufferDestroy(data->psi_buffer);
data->psi_buffer = NULL;
}
data->magic = MAGIC_DEAD;
TSfree(data);
}
}
示例2: ts_lua_http_set_cache_lookup_url
static int
ts_lua_http_set_cache_lookup_url(lua_State *L)
{
const char *url;
size_t url_len;
ts_lua_http_ctx *http_ctx;
GET_HTTP_CONTEXT(http_ctx, L);
url = luaL_checklstring(L, 1, &url_len);
if (url && url_len) {
const char *start = url;
const char *end = url + url_len;
TSMLoc new_url_loc;
if (TSUrlCreate(http_ctx->client_request_bufp, &new_url_loc) == TS_SUCCESS &&
TSUrlParse(http_ctx->client_request_bufp, new_url_loc, &start, end) == TS_PARSE_DONE &&
TSHttpTxnCacheLookupUrlSet(http_ctx->txnp, http_ctx->client_request_bufp, new_url_loc) == TS_SUCCESS) {
TSDebug(TS_LUA_DEBUG_TAG, "Set cache lookup URL");
} else {
TSError("[ts_lua] Failed to set cache lookup URL");
}
}
return 0;
}
示例3: prune_config
static bool
prune_config(invalidate_t **i)
{
invalidate_t *iptr, *ilast;
time_t now;
bool pruned = false;
now = time(NULL);
if (*i) {
iptr = *i;
ilast = NULL;
while (iptr) {
if (difftime(iptr->expiry, now) < 0) {
TSDebug(LOG_PREFIX, "Removing %s expiry: %d now: %d", iptr->regex_text, (int)iptr->expiry, (int)now);
if (ilast) {
ilast->next = iptr->next;
free_invalidate_t(iptr);
iptr = ilast->next;
} else {
*i = iptr->next;
free_invalidate_t(iptr);
iptr = *i;
}
pruned = true;
} else {
ilast = iptr;
iptr = iptr->next;
}
}
}
return pruned;
}
示例4: parse_response
static void
parse_response(StateInfo *state)
{
TSIOBufferBlock block;
TSParseResult pr = TS_PARSE_CONT;
int64_t avail;
char *start;
block = TSIOBufferReaderStart(state->resp_io_buf_reader);
while ((pr == TS_PARSE_CONT) && (block != NULL))
{
start = (char *) TSIOBufferBlockReadStart(block, state->resp_io_buf_reader, &avail);
if (avail > 0)
{
pr = TSHttpHdrParseResp(state->resp_info->parser, state->resp_info->buf, state->resp_info->http_hdr_loc, (const char **) &start, (const char *) (start + avail));
}
block = TSIOBufferBlockNext(block);
}
if (pr != TS_PARSE_CONT)
{
state->resp_info->status = TSHttpHdrStatusGet(state->resp_info->buf, state->resp_info->http_hdr_loc);
state->resp_info->parsed = true;
TSDebug(PLUGIN_NAME, "HTTP Status: %d", state->resp_info->status);
}
}
示例5: ssn_handler
static int
ssn_handler(TSCont contp, TSEvent event, void *edata)
{
TSHttpSsn ssnp;
TSHttpTxn txnp;
switch (event) {
case TS_EVENT_HTTP_SSN_START:
ssnp = (TSHttpSsn)edata;
handle_session(ssnp, contp);
TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE);
return 0;
case TS_EVENT_HTTP_TXN_START:
txnp = (TSHttpTxn)edata;
txn_handler(txnp, contp);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
return 0;
default:
TSDebug("tag_session", "In the default case: event = %d", event);
break;
}
return 0;
}
示例6: transform_handler
static int
transform_handler(TSCont contp, TSEvent event, void *edata)
{
/* Check to see if the transformation has been closed by a call to
TSVConnClose. */
if (TSVConnClosedGet(contp)) {
TSDebug("strans", "transformation closed");
transform_destroy(contp);
return 0;
} else {
TransformData *data;
int val = 0;
data = (TransformData *)TSContDataGet(contp);
if (data == NULL) {
TSError("Didn't get Continuation's Data. Ignoring Event..");
return 0;
}
TSDebug("strans", "transform handler event [%d], data->state = [%d]",
event, data->state);
do {
switch (data->state) {
case STATE_BUFFER:
val = transform_buffer_event(contp, data, event, edata);
break;
case STATE_CONNECT:
val = transform_connect_event(contp, data, event, edata);
break;
case STATE_WRITE:
val = transform_write_event(contp, data, event, edata);
break;
case STATE_READ_STATUS:
val = transform_read_status_event(contp, data, event, edata);
break;
case STATE_READ:
val = transform_read_event(contp, data, event, edata);
break;
case STATE_BYPASS:
val = transform_bypass_event(contp, data, event, edata);
break;
}
} while (val);
}
return 0;
}
示例7: for
/*-------------------------------------------------------------------------
strsearch_ioreader
Looks for string pattern in an iobuffer
Input:
reader reader on a iobuffer
pattern string to look for (nul terminated)
Output:
nparse number of chars scanned, excluding the matching pattern
Return Value:
STR_SUCCESS if pattern found
STR_PARTIAL if pattern found partially
STR_FAIL if pattern not found
-------------------------------------------------------------------------*/
static StrOperationResult
strsearch_ioreader(TSIOBufferReader reader, const char *pattern, int *nparse)
{
int index = 0;
TSIOBufferBlock block = TSIOBufferReaderStart(reader);
int slen = strlen(pattern);
if (slen <= 0) {
return STR_FAIL;
}
*nparse = 0;
/* Loop thru each block while we've not yet found the pattern */
while ((block != NULL) && (index < slen)) {
int64_t blocklen;
const char *blockptr = TSIOBufferBlockReadStart(block, reader, &blocklen);
const char *ptr;
for (ptr = blockptr; ptr < blockptr + blocklen; ptr++) {
(*nparse)++;
if (*ptr == pattern[index]) {
index++;
if (index == slen) {
break;
}
} else {
index = 0;
}
}
/* Parse next block */
block = TSIOBufferBlockNext(block);
}
*nparse -= index; /* Adjust nparse so it doesn't include matching chars */
if (index == slen) {
TSDebug(DBG_TAG, "strfind: match for %s at position %d", pattern, *nparse);
return STR_SUCCESS;
} else if (index > 0) {
TSDebug(DBG_TAG, "strfind: partial match for %s at position %d", pattern, *nparse);
return STR_PARTIAL;
} else {
TSDebug(DBG_TAG, "strfind no match for %s", pattern);
return STR_FAIL;
}
}
示例8: TSPluginInit
void
TSPluginInit(int argc, const char *argv[])
{
TSPluginRegistrationInfo info;
char *end;
int tmp;
info.plugin_name = PLUGIN_NAME;
info.vendor_name = "Apache Software Foundation";
info.support_email = "[email protected]";
if (TSPluginRegister(&info) != TS_SUCCESS) {
TSError("[%s] Plugin registration failed", PLUGIN_NAME);
goto error;
}
/* default value */
accept_port = 4666;
server_port = 4666;
if (argc < 3) {
TSDebug(PLUGIN_NAME, "Usage: protocol.so <accept_port> <server_port>. Using default ports accept=%d server=%d", accept_port,
server_port);
} else {
tmp = strtol(argv[1], &end, 10);
if (*end == '\0') {
accept_port = tmp;
TSDebug(PLUGIN_NAME, "using accept_port %d", accept_port);
} else {
TSError("[%s] Wrong argument for accept_port, using default port %d", PLUGIN_NAME, accept_port);
}
tmp = strtol(argv[2], &end, 10);
if (*end == '\0') {
server_port = tmp;
TSDebug(PLUGIN_NAME, "using server_port %d", server_port);
} else {
TSError("[%s] Wrong argument for server_port, using default port %d", PLUGIN_NAME, server_port);
}
}
protocol_init(accept_port, server_port);
error:
TSError("[%s] Plugin not initialized", PLUGIN_NAME);
}
示例9: tsib_pre_init
/** Create and return top-level cont with no transient data
* Sets up engine manager and kill-or-continue txn hook before launching
* potentially-slow mainconfiguration in separate thread.
*/
static ib_status_t tsib_pre_init(TSCont *contp)
{
int rv;
ib_status_t rc;
TSCont cont;
assert(contp != NULL);
/* create a cont to fend off traffic while we read config */
*contp = cont = TSContCreate(ironbee_plugin, NULL);
if (cont == NULL) {
TSError("[ironbee] failed to create initial continuation: disabled");
return IB_EUNKNOWN;
}
if (module_data.allow_at_startup) {
/* SSN_START doesn't use contdata; READ_REQUEST_HDR only needs non-null flag.
* Using &module_data might let us clean up some tsib_api stuff in future.
*/
TSContDataSet(cont, &module_data);
}
else {
/* NULL contdata signals the READ_REQUEST_HDR hook to reject requests */
TSContDataSet(cont, NULL);
}
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont);
if (!module_data.log_disable) {
/* success is documented as TS_LOG_ERROR_NO_ERROR but that's undefined.
* It's actually a TS_SUCCESS (proxy/InkAPI.cc line 6641).
*/
printf("Logging to \"%s\"\n", module_data.log_file);
rv = TSTextLogObjectCreate(module_data.log_file,
TS_LOG_MODE_ADD_TIMESTAMP,
&module_data.logger);
if (rv != TS_SUCCESS) {
TSError("[ironbee] Error creating log file.");
return IB_EUNKNOWN;
}
}
/* Initialize IronBee (including util) */
rc = ib_initialize();
if (rc != IB_OK) {
TSError("[ironbee] Error initializing IronBee: %s",
ib_status_to_string(rc));
return rc;
}
/* Create the IronBee engine manager */
TSDebug("ironbee", "Creating IronBee engine manager");
rc = ib_manager_create(&(module_data.manager), /* Engine Manager */
&ibplugin, /* Server object */
module_data.max_engines); /* Default max */
if (rc != IB_OK) {
TSError("[ironbee] Error creating IronBee engine manager: %s",
ib_status_to_string(rc));
}
return rc;
}
示例10: parseIps6
static void parseIps6(config_t* config, char* ipStr) {
char buffer[STR_BUFFER_SIZE];
char *p, *tok1, *tok2, *ip;
int i, mask;
char ip_port_text_buffer[INET6_ADDRSTRLEN];
if(!ipStr) {
config->ip6Count = 1;
ip = config->allowIps6 = TSmalloc(5);
inet_pton(AF_INET, DEFAULT_IP6, ip);
ip[8] = 64;
return;
}
strcpy(buffer, ipStr);
p = buffer;
while(strtok_r(p, ", \n", &p)) {
config->ip6Count++;
}
if(!config->ip6Count) {
return;
}
config->allowIps6 = TSmalloc(9*config->ip6Count); // 4 bytes for ip + 1 for bit mask
strcpy(buffer, ipStr);
p = buffer;
i = 0;
while((tok1 = strtok_r(p, ", \n", &p))) {
TSDebug(PLUGIN_TAG, "%d) parsing: %s", i+1,tok1);
tok2 = strtok_r(tok1, "/", &tok1);
ip = config->allowIps6+(9*i);
if(!inet_pton(AF_INET, tok2, ip)) {
TSDebug(PLUGIN_TAG, "%d) skipping: %s", i+1,tok1);
continue;
}
tok2 = strtok_r(tok1, "/", &tok1);
if(!tok2) {
mask = 64;
} else {
mask = atoi(tok2);
}
ip[8] = mask;
TSDebug(PLUGIN_TAG, "%d) adding netmask: %s/%d", i+1,
inet_ntop(AF_INET6,ip,ip_port_text_buffer,INET6_ADDRSTRLEN),ip[8]);
i++;
}
}
示例11: acme_hook
/* Read-request header continuation, used to kick off the server intercept if necessary */
static int
acme_hook(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata)
{
TSMBuffer reqp;
TSMLoc hdr_loc = NULL, url_loc = NULL;
TSCont icontp;
AcmeState *my_state;
TSHttpTxn txnp = (TSHttpTxn)edata;
TSDebug(PLUGIN_NAME, "kicking off ACME hook");
if ((TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc)) && (TS_SUCCESS == TSHttpHdrUrlGet(reqp, hdr_loc, &url_loc))) {
int path_len = 0;
const char *path = TSUrlPathGet(reqp, url_loc, &path_len);
/* Short circuit the / path, common case */
if (!path || path_len < (int)(strlen(ACME_WK_PATH) + 2) || *path != '.' || memcmp(path, ACME_WK_PATH, strlen(ACME_WK_PATH))) {
TSDebug(PLUGIN_NAME, "skipping URL path = %.*s", path_len, path);
goto cleanup;
}
TSSkipRemappingSet(txnp, 1); /* not strictly necessary, but speed is everything these days */
/* This request is for us -- register our intercept */
icontp = TSContCreate(acme_intercept, TSMutexCreate());
my_state = make_acme_state();
open_acme_file(my_state, path + strlen(ACME_WK_PATH), path_len - strlen(ACME_WK_PATH));
TSContDataSet(icontp, my_state);
TSHttpTxnIntercept(icontp, txnp);
TSDebug(PLUGIN_NAME, "created intercept hook");
}
cleanup:
if (url_loc) {
TSHandleMLocRelease(reqp, hdr_loc, url_loc);
}
if (hdr_loc) {
TSHandleMLocRelease(reqp, TS_NULL_MLOC, hdr_loc);
}
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
return 0;
}
示例12: request_buffer_plugin
static int
request_buffer_plugin(TSCont contp, TSEvent event, void *edata)
{
TSDebug(PLUGIN_NAME, "request_buffer_plugin starting, event[%d]", event);
TSHttpTxn txnp = (TSHttpTxn)(edata);
if (event == TS_EVENT_HTTP_REQUEST_BUFFER_COMPLETE) {
int len = 0;
char *body = request_body_get(txnp, &len);
TSDebug(PLUGIN_NAME, "request_buffer_plugin gets the request body with length[%d]", len);
TSfree(body);
TSContDestroy(contp);
} else {
ink_assert(0);
}
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
return 0;
}
示例13: config_handler
static int config_handler(TSCont cont, TSEvent event, void *edata) {
config_holder_t *config_holder;
TSDebug(PLUGIN_TAG, "In config Handler");
config_holder = (config_holder_t *) TSContDataGet(cont);
load_config_file(config_holder);
return 0;
}
示例14: stat_add
static void
stat_add(char *name, TSMgmtInt amount, TSStatPersistence persist_type, TSMutex create_mutex)
{
int stat_id = -1;
ENTRY search, *result = NULL;
static __thread struct hsearch_data stat_cache;
static __thread bool hash_init = false;
if (unlikely(!hash_init)) {
hcreate_r(TS_MAX_API_STATS << 1, &stat_cache);
hash_init = true;
TSDebug(DEBUG_TAG, "stat cache hash init");
}
search.key = name;
search.data = 0;
hsearch_r(search, FIND, &result, &stat_cache);
if (unlikely(result == NULL)) {
// This is an unlikely path because we most likely have the stat cached
// so this mutex won't be much overhead and it fixes a race condition
// in the RecCore. Hopefully this can be removed in the future.
TSMutexLock(create_mutex);
if (TS_ERROR == TSStatFindName((const char *) name, &stat_id)) {
stat_id = TSStatCreate((const char *) name, TS_RECORDDATATYPE_INT, persist_type, TS_STAT_SYNC_SUM);
if (stat_id == TS_ERROR)
TSDebug(DEBUG_TAG, "Error creating stat_name: %s", name);
else
TSDebug(DEBUG_TAG, "Created stat_name: %s stat_id: %d", name, stat_id);
}
TSMutexUnlock(create_mutex);
if (stat_id >= 0) {
search.key = TSstrdup(name);
search.data = (void *) ((intptr_t) stat_id);
hsearch_r(search, ENTER, &result, &stat_cache);
TSDebug(DEBUG_TAG, "Cached stat_name: %s stat_id: %d", name, stat_id);
}
} else
stat_id = (int) ((intptr_t) result->data);
if (likely(stat_id >= 0))
TSStatIntIncrement(stat_id, amount);
else
TSDebug(DEBUG_TAG, "stat error! stat_name: %s stat_id: %d", name, stat_id);
}
示例15: ironbee_plugin_ssn_close
static void ironbee_plugin_ssn_close(TSCont contp, TSHttpSsn ssnp)
{
assert(contp != NULL);
TSDebug("ironbee", "SSN Close: %p", (void *)contp);
tsib_ssn_ctx_destroy(TSContDataGet(contp));
tsib_manager_engine_cleanup();
TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE);
}