当前位置: 首页>>代码示例>>C++>>正文


C++ TSContDataGet函数代码示例

本文整理汇总了C++中TSContDataGet函数的典型用法代码示例。如果您正苦于以下问题:C++ TSContDataGet函数的具体用法?C++ TSContDataGet怎么用?C++ TSContDataGet使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TSContDataGet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_config

static config_t* get_config(TSCont cont) {
	config_holder_t* configh = (config_holder_t *) TSContDataGet(cont);
	if(!configh) {
		return 0;
	}
	return configh->config;
}
开发者ID:G4m30v3r,项目名称:traffic_control,代码行数:7,代码来源:astats_over_http.c

示例2: hdr_handler

static int
hdr_handler(TSCont contp, TSHttpTxn txnp)
{
	TSMBuffer  	bufp;
	TSMLoc		hdr_loc, field_loc; 
	hdr_list 	*hdr;

	hdr = TSContDataGet(contp);
	if (hdr == NULL) {
		goto done;
	} 

	if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
		TSError("couldn't retrieve client response header\n");
		goto done;
	}


	for (; hdr; hdr = hdr->next) {
		TSMimeHdrFieldCreate(bufp, hdr_loc, &field_loc);
		TSMimeHdrFieldNameSet(bufp, hdr_loc, field_loc, hdr->name, strlen(hdr->name));
		TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, field_loc, -1, hdr->val, strlen(hdr->val));
		TSMimeHdrFieldAppend(bufp, hdr_loc, field_loc);

		TSHandleMLocRelease(bufp, hdr_loc, field_loc);
		TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
	}


done:
	TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
	
	return 0;
}
开发者ID:scw00,项目名称:traffic-server-test,代码行数:34,代码来源:add_header.c

示例3: wake_up_streams

/*-------------------------------------------------------------------------
  wake_up_streams
  Send an event to the upstream vconnection to either
    - ask for more data
    - let it know we're done
  Reenable the downstream vconnection
  Input:
    contp      continuation for the current transaction
  Output :
  Return Value:
   0 if failure
   1 if success
  -------------------------------------------------------------------------*/
static int
wake_up_streams(TSCont contp)
{
  TSVIO input_vio;
  ContData *data;
  int ntodo;

  data = TSContDataGet(contp);
  TSAssert(data->magic == MAGIC_ALIVE);

  input_vio = TSVConnWriteVIOGet(contp);
  ntodo = TSVIONTodoGet(input_vio);

  if (ntodo > 0) {
    TSVIOReenable(data->output_vio);
    TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_READY, input_vio);
  } else {
    TSDebug(DBG_TAG, "Total bytes produced by transform = %d", data->transform_bytes);
    TSVIONBytesSet(data->output_vio, data->transform_bytes);
    TSVIOReenable(data->output_vio);
    TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_COMPLETE, input_vio);
  }

  return 1;
}
开发者ID:arnyunplugged,项目名称:trafficserver,代码行数:38,代码来源:psi.c

示例4: transform_destroy

static void
transform_destroy(TSCont contp)
{
  TransformData *data;

  data = TSContDataGet(contp);
  if (data != NULL) {
    if (data->input_buf) {
      TSIOBufferDestroy(data->input_buf);
    }

    if (data->output_buf) {
      TSIOBufferDestroy(data->output_buf);
    }

    if (data->pending_action) {
      TSActionCancel(data->pending_action);
    }

    if (data->server_vc) {
      TSVConnAbort(data->server_vc, 1);
    }

    TSfree(data);
  } else {
    TSError("[%s] Unable to get Continuation's Data. TSContDataGet returns NULL", PLUGIN_NAME);
  }

  TSContDestroy(contp);
}
开发者ID:We-Amp,项目名称:trafficserver,代码行数:30,代码来源:server_transform.c

示例5: handle_transform

static void
handle_transform(TSCont contp)
{
  MyData *data;
  int done;

  /* Get our data structure for this operation. The private data
     structure contains the output VIO and output buffer. If the
     private data structure pointer is NULL, then we'll create it
     and initialize its internals. */

  data = TSContDataGet(contp);
  if (!data) {
    data = my_data_alloc();
    TSContDataSet(contp, data);
  }

  do {
    switch (data->state) {
    case STATE_BUFFER_DATA:
      done = handle_buffering(contp, data);
      break;
    case STATE_OUTPUT_DATA:
      done = handle_output(contp, data);
      break;
    default:
      done = 1;
      break;
    }
  } while (!done);
}
开发者ID:chenglongwei,项目名称:trafficserver,代码行数:31,代码来源:bnull_transform.c

示例6: ts_dechunk_transform_entry

static int
ts_dechunk_transform_entry(TSCont contp, TSEvent event, void *edata)
{
    TSVIO       input_vio;

    ts_dechunk_transform_ctx *transform_ctx = (ts_dechunk_transform_ctx*)TSContDataGet(contp);

    if (TSVConnClosedGet(contp)) {
        TSContDestroy(contp);
        ts_dechunk_destroy_transform_ctx(transform_ctx);
        return 0;
    }

    switch (event) {

        case TS_EVENT_ERROR:
            input_vio = TSVConnWriteVIOGet(contp);
            TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
            break;

        case TS_EVENT_VCONN_WRITE_COMPLETE:
            TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
            break;

        case TS_EVENT_VCONN_WRITE_READY:
        default:
            ts_dechunk_transform_handler(contp, transform_ctx);
            break;
    }

    return 0;
}
开发者ID:portl4t,项目名称:ts-chunked,代码行数:32,代码来源:ts_chunked.c

示例7: client_reader

// This serves to consume all the data that arrives. If it's not consumed the tunnel gets stalled
// and the transaction doesn't complete. Other things could be done with the data, accessible via
// the IO buffer @a reader, such as writing it to disk to make an externally accessible copy.
static int
client_reader(TSCont contp, TSEvent event, void *edata)
{
  SinkData *data = TSContDataGet(contp);

  // If we got closed, we're done.
  if (TSVConnClosedGet(contp)) {
    TSfree(data);
    TSContDestroy(contp);
    return 0;
  }

  TSVIO input_vio = TSVConnWriteVIOGet(contp);

  if (!data) {
    data        = TSmalloc(sizeof(SinkData));
    data->total = 0;
    TSContDataSet(contp, data);
  }

  switch (event) {
  case TS_EVENT_ERROR:
    TSDebug(PLUGIN_NAME, "Error event");
    TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
    break;
  case TS_EVENT_VCONN_READ_COMPLETE:
    TSDebug(PLUGIN_NAME, "READ_COMPLETE");
    break;
  case TS_EVENT_VCONN_READ_READY:
  case TS_EVENT_IMMEDIATE:
    TSDebug(PLUGIN_NAME, "Data event - %s", event == TS_EVENT_IMMEDIATE ? "IMMEDIATE" : "READ_READY");
    // Look for data and if we find any, consume.
    if (TSVIOBufferGet(input_vio)) {
      TSIOBufferReader reader = TSVIOReaderGet(input_vio);
      int64_t n               = TSIOBufferReaderAvail(reader);
      if (n > 0) {
        TSIOBufferReaderConsume(reader, n);
        TSVIONDoneSet(input_vio, TSVIONDoneGet(input_vio) + n);
        data->total += n; // internal accounting so we can print the value at the end.
        TSDebug(PLUGIN_NAME, "Consumed %" PRId64 " bytes", n);
      }
      if (TSVIONTodoGet(input_vio) > 0) {
        // signal that we can accept more data.
        TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_READY, input_vio);
      } else {
        TSDebug(PLUGIN_NAME, "send WRITE_COMPLETE");
        TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_COMPLETE, input_vio);
      }
    } else { // buffer gone, we're done.
      TSDebug(PLUGIN_NAME, "upstream buffer disappeared - %" PRId64 " bytes", data->total);
    }
    break;
  default:
    TSDebug(PLUGIN_NAME, "unhandled event %d", event);
    break;
  }

  return 0;
}
开发者ID:EmAndrews,项目名称:trafficserver,代码行数:62,代码来源:txn-data-sink.c

示例8: in_data_event

static int in_data_event(TSCont contp, TSEvent event, void *edata)
{
  ib_txn_ctx *data = TSContDataGet(contp);
  ibd_ctx direction;
  direction.ibd = &ironbee_direction_req;
  direction.data = &data->in;
  return data_event(contp, event, &direction);
}
开发者ID:igalic,项目名称:ironbee,代码行数:8,代码来源:ironbee.c

示例9: 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;
}
开发者ID:G4m30v3r,项目名称:traffic_control,代码行数:8,代码来源:astats_over_http.c

示例10: 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);
}
开发者ID:riverans,项目名称:ironbee,代码行数:9,代码来源:ts_event.c

示例11: ironbee_conn_init

static ib_status_t ironbee_conn_init(ib_engine_t *ib,
                                   ib_conn_t *iconn, void *cbdata)
{
  /* when does this happen? */
  ib_status_t rc;
  const struct sockaddr *addr;
  int port;

  TSCont contp = iconn->pctx;
  ib_ssn_ctx* data = TSContDataGet(contp);
//  ib_clog_debug(....);

  /* remote ip */
  addr = TSHttpTxnClientAddrGet(data->txnp);

  addr2str(addr, data->remote_ip, &port);

  iconn->remote_ipstr = data->remote_ip;
  rc = ib_data_add_bytestr(iconn->dpi,
                             "remote_ip",
                             (uint8_t *)iconn->remote_ipstr,
                             strlen(data->remote_ip),
                             NULL);
    if (rc != IB_OK) {
        return rc;
    }

  /* remote port */
  iconn->remote_port = port;
    rc = ib_data_add_num(iconn->dpi, "remote_port", port, NULL);
    if (rc != IB_OK) {
        return rc;
    }

  /* local end */
  addr = TSHttpTxnIncomingAddrGet(data->txnp);

  addr2str(addr, data->local_ip, &port);

    iconn->local_ipstr = data->local_ip;
    rc = ib_data_add_bytestr(iconn->dpi,
                             "local_ip",
                             (uint8_t *)iconn->local_ipstr,
                             strlen(data->local_ip),
                             NULL);
    if (rc != IB_OK) {
        return rc;
    }

    /* local_port */
    iconn->local_port = port;
    rc = ib_data_add_num(iconn->dpi, "local_port", port, NULL);
    if (rc != IB_OK) {
        return rc;
    }
  return IB_OK;
}
开发者ID:igalic,项目名称:ironbee,代码行数:57,代码来源:ironbee.c

示例12: free_handler

static int free_handler(TSCont cont, TSEvent event, void *edata) {
	config_t *config;

	TSDebug(PLUGIN_TAG, "Freeing old config");
	config = (config_t *) TSContDataGet(cont);
	delete_config(config);
	TSContDestroy(cont);
	return 0;
}
开发者ID:G4m30v3r,项目名称:traffic_control,代码行数:9,代码来源:astats_over_http.c

示例13: trylock_handler

/*-------------------------------------------------------------------------
  trylock_handler
  Small handler to handle TSMutexLockTry failures

  Input:
    contp      continuation for the current transaction
    event      event received
    data       pointer on optional data
  Output :
  Return Value:
  -------------------------------------------------------------------------*/
static int
trylock_handler(TSCont contp, TSEvent event, void *edata)
{
  TryLockData *data = TSContDataGet(contp);
  transform_handler(data->contp, data->event, NULL);
  TSfree(data);
  TSContDestroy(contp);
  return 0;
}
开发者ID:arnyunplugged,项目名称:trafficserver,代码行数:20,代码来源:psi.c

示例14: null_transform

static int
null_transform(TSCont contp, TSEvent event, void *edata)
{
  /* Check to see if the transformation has been closed by a call to
   * TSVConnClose.
   */
  TSDebug("null-transform", "Entering null_transform()");

  if (TSVConnClosedGet(contp)) {
    TSDebug("null-transform", "\tVConn is closed");
    my_data_destroy(TSContDataGet(contp));
    TSContDestroy(contp);
    return 0;
  } else {
    switch (event) {
    case TS_EVENT_ERROR:
      {
        TSVIO input_vio;

        TSDebug("null-transform", "\tEvent is TS_EVENT_ERROR");
        /* Get the write VIO for the write operation that was
         * performed on ourself. This VIO contains the continuation of
         * our parent transformation. This is the input VIO.
         */
        input_vio = TSVConnWriteVIOGet(contp);

        /* Call back the write VIO continuation to let it know that we
         * have completed the write operation.
         */
        TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
      }
      break;
    case TS_EVENT_VCONN_WRITE_COMPLETE:
      TSDebug("null-transform", "\tEvent is TS_EVENT_VCONN_WRITE_COMPLETE");
      /* When our output connection says that it has finished
       * reading all the data we've written to it then we should
       * shutdown the write portion of its connection to
       * indicate that we don't want to hear about it anymore.
       */
      TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
      break;
    case TS_EVENT_VCONN_WRITE_READY:
      TSDebug("null-transform", "\tEvent is TS_EVENT_VCONN_WRITE_READY");
    default:
      TSDebug("null-transform", "\t(event is %d)", event);
      /* If we get a WRITE_READY event or any other type of
       * event (sent, perhaps, because we were reenabled) then
       * we'll attempt to transform more data.
       */
      handle_transform(contp);
      break;
    }
  }

  return 0;
}
开发者ID:ericbalsa,项目名称:trafficserver,代码行数:56,代码来源:null-transform.c

示例15: free_handler

static int
free_handler(TSCont cont, TSEvent event, void *edata)
{
  invalidate_t *iptr;

  TSDebug(LOG_PREFIX, "Freeing old config");
  iptr = (invalidate_t *)TSContDataGet(cont);
  free_invalidate_t_list(iptr);
  TSContDestroy(cont);
  return 0;
}
开发者ID:SolidWallOfCode,项目名称:trafficserver,代码行数:11,代码来源:regex_revalidate.c


注:本文中的TSContDataGet函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。