本文整理汇总了C++中VSB_delete函数的典型用法代码示例。如果您正苦于以下问题:C++ VSB_delete函数的具体用法?C++ VSB_delete怎么用?C++ VSB_delete使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VSB_delete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cnt_synth
static enum req_fsm_nxt
cnt_synth(struct worker *wrk, struct req *req)
{
char date[40];
struct http *h;
double now;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
wrk->stats.s_synth++;
now = W_TIM_real(wrk);
VSLb_ts_req(req, "Process", now);
if (req->err_code < 100 || req->err_code > 999)
req->err_code = 501;
HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod);
h = req->resp;
VTIM_format(now, date);
http_PrintfHeader(h, "Date: %s", date);
http_SetHeader(h, "Server: Varnish");
http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid));
http_PutResponse(h, "HTTP/1.1", req->err_code, req->err_reason);
AZ(req->synth_body);
req->synth_body = VSB_new_auto();
AN(req->synth_body);
VCL_synth_method(req->vcl, wrk, req, NULL, req->http->ws);
http_Unset(h, H_Content_Length);
AZ(VSB_finish(req->synth_body));
if (wrk->handling == VCL_RET_RESTART) {
HTTP_Setup(h, req->ws, req->vsl, SLT_RespMethod);
VSB_delete(req->synth_body);
req->synth_body = NULL;
req->req_step = R_STP_RESTART;
return (REQ_FSM_MORE);
}
assert(wrk->handling == VCL_RET_DELIVER);
if (http_HdrIs(req->resp, H_Connection, "close"))
req->doclose = SC_RESP_CLOSE;
V1D_Deliver_Synth(req);
VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
VSB_delete(req->synth_body);
req->synth_body = NULL;
req->err_code = 0;
req->err_reason = NULL;
return (REQ_FSM_DONE);
}
示例2: mcf_askchild
static void
mcf_askchild(struct cli *cli, const char * const *av, void *priv)
{
int i;
char *q;
unsigned u;
struct vsb *vsb;
(void)priv;
/*
* Command not recognized in master, try cacher if it is
* running.
*/
if (cli_o <= 0) {
if (!strcmp(av[1], "help")) {
if (av[2] == NULL || strcmp(av[2], "-j"))
VCLI_Out(cli,
"No help from child, (not running).\n");
return;
}
VCLI_SetResult(cli, CLIS_UNKNOWN);
VCLI_Out(cli,
"Unknown request in manager process "
"(child not running).\n"
"Type 'help' for more info.");
return;
}
vsb = VSB_new_auto();
for (i = 1; av[i] != NULL; i++) {
VSB_quote(vsb, av[i], strlen(av[i]), 0);
VSB_putc(vsb, ' ');
}
VSB_putc(vsb, '\n');
AZ(VSB_finish(vsb));
i = write(cli_o, VSB_data(vsb), VSB_len(vsb));
if (i != VSB_len(vsb)) {
VSB_delete(vsb);
VCLI_SetResult(cli, CLIS_COMMS);
VCLI_Out(cli, "CLI communication error");
MGT_Child_Cli_Fail();
return;
}
VSB_delete(vsb);
if (VCLI_ReadResult(cli_i, &u, &q, mgt_param.cli_timeout))
MGT_Child_Cli_Fail();
VCLI_SetResult(cli, u);
VCLI_Out(cli, "%s", q);
free(q);
}
示例3: VEP_Finish
struct vsb *
VEP_Finish(const struct sess *sp)
{
struct vep_state *vep;
ssize_t l, lcb;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
vep = sp->wrk->vep;
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
if (vep->o_pending)
vep_mark_common(vep, vep->ver_p, vep->last_mark);
if (vep->o_wait > 0) {
lcb = vep->cb(vep->sp, 0, VGZ_ALIGN);
vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
}
(void)vep->cb(vep->sp, 0, VGZ_FINISH);
sp->wrk->vep = NULL;
AZ(VSB_finish(vep->vsb));
l = VSB_len(vep->vsb);
if (vep->esi_found && l > 0)
return (vep->vsb);
VSB_delete(vep->vsb);
return (NULL);
}
示例4: vfp_esi_end
vfp_esi_end(struct sess *sp)
{
struct vsb *vsb;
struct vef_priv *vef;
ssize_t l;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(sp->wrk->vep);
vsb = VEP_Finish(sp);
if (vsb != NULL) {
l = VSB_len(vsb);
assert(l > 0);
/* XXX: This is a huge waste of storage... */
sp->obj->esidata = STV_alloc(sp, l);
XXXAN(sp->obj->esidata);
memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l);
sp->obj->esidata->len = l;
VSB_delete(vsb);
}
if (sp->wrk->vgz_rx != NULL)
VGZ_Destroy(&sp->wrk->vgz_rx);
if (sp->wrk->vef_priv != NULL) {
vef = sp->wrk->vef_priv;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
sp->wrk->vef_priv = NULL;
VGZ_UpdateObj(vef->vgz, sp->obj);
VGZ_Destroy(&vef->vgz);
XXXAZ(vef->error);
FREE_OBJ(vef);
}
return (0);
}
示例5: Marg_connect
Marg_connect(const struct vev *e, int what)
{
struct vsb *vsb;
struct m_addr *ma;
assert(e == M_conn);
(void)what;
M_fd = VTCP_connected(M_fd);
if (M_fd < 0) {
MGT_complain(C_INFO, "Could not connect to CLI-master: %m");
ma = VTAILQ_FIRST(&m_addr_list);
AN(ma);
VTAILQ_REMOVE(&m_addr_list, ma, list);
VTAILQ_INSERT_TAIL(&m_addr_list, ma, list);
if (M_poll < 10)
M_poll++;
return (1);
}
vsb = sock_id("master", M_fd);
mgt_cli_setup(M_fd, M_fd, 0, VSB_data(vsb), Marg_closer, NULL);
VSB_delete(vsb);
M_poll = 1;
return (1);
}
示例6: http_process
int
http_process(struct vtclog *vl, const char *spec, int sock, int *sfd)
{
struct http *hp;
char *s, *q;
int retval;
(void)sfd;
ALLOC_OBJ(hp, HTTP_MAGIC);
AN(hp);
hp->fd = sock;
hp->timeout = 15000;
hp->nrxbuf = 2048*1024;
hp->vsb = VSB_new_auto();
hp->rxbuf = malloc(hp->nrxbuf); /* XXX */
hp->sfd = sfd;
hp->vl = vl;
hp->gziplevel = 0;
hp->gzipresidual = -1;
AN(hp->rxbuf);
AN(hp->vsb);
s = strdup(spec);
q = strchr(s, '\0');
assert(q > s);
AN(s);
parse_string(s, http_cmds, hp, vl);
retval = hp->fd;
VSB_delete(hp->vsb);
free(hp->rxbuf);
free(hp);
return (retval);
}
示例7: VEP_Finish
struct vsb *
VEP_Finish(const struct worker *wrk)
{
struct vep_state *vep;
ssize_t l, lcb;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
vep = wrk->busyobj->vep;
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
if (vep->o_pending)
vep_mark_common(vep, vep->ver_p, vep->last_mark);
if (vep->o_wait > 0) {
lcb = vep->cb(vep->wrk, 0, VGZ_ALIGN);
vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
}
(void)vep->cb(vep->wrk, 0, VGZ_FINISH);
wrk->busyobj->vep = NULL;
AZ(VSB_finish(vep->vsb));
l = VSB_len(vep->vsb);
if (vep->esi_found && l > 0)
return (vep->vsb);
VSB_delete(vep->vsb);
return (NULL);
}
示例8: VEP_Finish
struct vsb *
VEP_Finish(struct busyobj *bo)
{
struct vep_state *vep;
ssize_t l, lcb;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vep = bo->vep;
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
assert(vep->bo == bo);
if (vep->o_pending)
vep_mark_common(vep, vep->ver_p, vep->last_mark);
if (vep->o_wait > 0) {
lcb = vep->cb(vep->bo, 0, VGZ_ALIGN);
vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
}
(void)vep->cb(vep->bo, 0, VGZ_FINISH);
bo->vep = NULL;
AZ(VSB_finish(vep->vsb));
l = VSB_len(vep->vsb);
if (vep->esi_found && l > 0)
return (vep->vsb);
VSB_delete(vep->vsb);
return (NULL);
}
示例9: mgt_sandbox_init
void
mgt_sandbox_init(void)
{
struct passwd *pwd;
struct group *grp;
struct vsb *sb;
unsigned subs;
/* Pick a sandbox */
#ifdef HAVE_SETPPRIV
mgt_sandbox = mgt_sandbox_solaris;
#else
mgt_sandbox = mgt_sandbox_unix;
#endif
/* Test it */
sb = VSB_new_auto();
subs = VSUB_run(sb, run_sandbox_test, NULL, "SANDBOX-test", 10);
VSB_delete(sb);
if (subs) {
MGT_complain(C_SECURITY,
"Platform-specific sandbox failed - sandboxing disabled");
MGT_complain(C_SECURITY,
"Varnish runs with elevated privileges");
mgt_sandbox = mgt_sandbox_null;
}
MCF_AddParams(mgt_parspec_sandbox);
/*
* If we have nobody/nogroup, use them as defaults for sandboxes,
* else fall back to whoever we run as.
*/
if (getpwnam("nobody") != NULL) {
MCF_SetDefault("user", "nobody");
} else {
pwd = getpwuid(getuid());
if (pwd == NULL)
ARGV_ERR("Neither user 'nobody' or my uid (%jd)"
" found in password database.\n",
(intmax_t)getuid());
MCF_SetDefault("user", pwd->pw_name);
}
endpwent();
if (getgrnam("nogroup") != NULL) {
MCF_SetDefault("group", "nogroup");
} else {
grp = getgrgid(getgid());
if (grp == NULL)
ARGV_ERR("Neither group 'nogroup' or my gid (%jd)"
" found in password database.\n",
(intmax_t)getgid());
MCF_SetDefault("group", grp->gr_name);
}
endgrent();
}
示例10: BAN_Abandon
void
BAN_Abandon(struct ban_proto *bp)
{
CHECK_OBJ_NOTNULL(bp, BAN_PROTO_MAGIC);
VSB_delete(bp->vsb);
FREE_OBJ(bp);
}
示例11: vcc_delete_expr
static void
vcc_delete_expr(struct expr *e)
{
if (e == NULL)
return;
CHECK_OBJ_NOTNULL(e, EXPR_MAGIC);
VSB_delete(e->vsb);
FREE_OBJ(e);
}
示例12: vtc_send_proxy
int
vtc_send_proxy(int fd, int version, const struct suckaddr *sac,
const struct suckaddr *sas)
{
struct vsb *vsb;
char hc[VTCP_ADDRBUFSIZE];
char pc[VTCP_PORTBUFSIZE];
char hs[VTCP_ADDRBUFSIZE];
char ps[VTCP_PORTBUFSIZE];
int i, len;
int proto;
AN(sac);
AN(sas);
assert(version == 1 || version == 2);
vsb = VSB_new_auto();
AN(vsb);
proto = VSA_Get_Proto(sas);
assert(proto == PF_INET6 || proto == PF_INET);
if (version == 1) {
VSB_bcat(vsb, vpx1_sig, sizeof(vpx1_sig));
if (proto == PF_INET6)
VSB_printf(vsb, " TCP6 ");
else if (proto == PF_INET)
VSB_printf(vsb, " TCP4 ");
VTCP_name(sac, hc, sizeof(hc), pc, sizeof(pc));
VTCP_name(sas, hs, sizeof(hs), ps, sizeof(ps));
VSB_printf(vsb, "%s %s %s %s\r\n", hc, hs, pc, ps);
} else if (version == 2) {
VSB_bcat(vsb, vpx2_sig, sizeof(vpx2_sig));
VSB_putc(vsb, 0x21);
if (proto == PF_INET6) {
VSB_putc(vsb, 0x21);
VSB_putc(vsb, 0x00);
VSB_putc(vsb, 0x24);
} else if (proto == PF_INET) {
VSB_putc(vsb, 0x11);
VSB_putc(vsb, 0x00);
VSB_putc(vsb, 0x0c);
}
vpx_enc_addr(vsb, proto, sac);
vpx_enc_addr(vsb, proto, sas);
vpx_enc_port(vsb, sac);
vpx_enc_port(vsb, sas);
} else
WRONG("Wrong proxy version");
AZ(VSB_finish(vsb));
len = VSB_len(vsb);
i = write(fd, VSB_data(vsb), len);
VSB_delete(vsb);
return (i != len);
}
示例13: Marg_poker
static int
Marg_poker(const struct vev *e, int what)
{
struct vsb *vsb;
int s, k;
socklen_t l;
(void)what; /* XXX: ??? */
if (e == M_conn) {
/* Our connect(2) returned, check result */
l = sizeof k;
AZ(getsockopt(M_fd, SOL_SOCKET, SO_ERROR, &k, &l));
if (k) {
errno = k;
syslog(LOG_INFO, "Could not connect to CLI-master: %m");
(void)close(M_fd);
M_fd = -1;
/* Try next address */
if (++M_nxt >= M_nta) {
M_nxt = 0;
if (M_poll < 10)
M_poll *= 2;
}
return (1);
}
vsb = sock_id("master", M_fd);
mgt_cli_setup(M_fd, M_fd, 0, VSB_data(vsb), Marg_closer, NULL);
VSB_delete(vsb);
M_poll = 1;
return (1);
}
assert(e == M_poker);
M_poker->timeout = M_poll; /* XXX nasty ? */
if (M_fd >= 0)
return (0);
/* Try to connect asynchronously */
s = VSS_connect(M_ta[M_nxt], 1);
if (s < 0)
return (0);
mgt_got_fd(s);
M_conn = vev_new();
AN(M_conn);
M_conn->callback = Marg_poker;
M_conn->name = "-M connector";
M_conn->fd_flags = EV_WR;
M_conn->fd = s;
M_fd = s;
AZ(vev_add(mgt_evb, M_conn));
return (0);
}
示例14: vtc_logclose
void
vtc_logclose(struct vtclog *vl)
{
CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC);
if (pthread_getspecific(log_key) == vl)
AZ(pthread_setspecific(log_key, NULL));
VSB_delete(vl->vsb);
AZ(pthread_mutex_destroy(&vl->mtx));
FREE_OBJ(vl);
}
示例15: VSL_ResetError
void
VSL_ResetError(struct VSL_data *vsl)
{
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
if (vsl->diag == NULL)
return;
VSB_delete(vsl->diag);
vsl->diag = NULL;
}