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


C++ CAST_OBJ_NOTNULL函数代码示例

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


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

示例1: exp_thread

exp_thread(struct worker *wrk, void *priv)
{
	struct objcore *oc;
	double t = 0, tnext = 0;
	struct exp_priv *ep;
	unsigned flags = 0;

	CAST_OBJ_NOTNULL(ep, priv, EXP_PRIV_MAGIC);
	ep->wrk = wrk;
	VSL_Setup(&ep->vsl, NULL, 0);
	ep->heap = binheap_new(NULL, object_cmp, object_update);
	AN(ep->heap);
	while (1) {

		Lck_Lock(&ep->mtx);
		oc = VSTAILQ_FIRST(&ep->inbox);
		CHECK_OBJ_ORNULL(oc, OBJCORE_MAGIC);
		if (oc != NULL) {
			assert(oc->refcnt >= 1);
			VSTAILQ_REMOVE(&ep->inbox, oc, objcore, exp_list);
			VSC_C_main->exp_received++;
			tnext = 0;
			flags = oc->exp_flags;
			if (flags & OC_EF_REMOVE)
				oc->exp_flags = 0;
			else
				oc->exp_flags &= OC_EF_REFD;
		} else if (tnext > t) {
			VSL_Flush(&ep->vsl, 0);
			Pool_Sumstat(wrk);
			(void)Lck_CondWait(&ep->condvar, &ep->mtx, tnext);
		}
		Lck_Unlock(&ep->mtx);

		t = VTIM_real();

		if (oc != NULL)
			exp_inbox(ep, oc, flags);
		else
			tnext = exp_expire(ep, t);
	}
	NEEDLESS(return NULL);
}
开发者ID:slimhazard,项目名称:varnish-cache,代码行数:43,代码来源:cache_expire.c

示例2: cmd_http_rxchunk

static void
cmd_http_rxchunk(CMD_ARGS)
{
	struct http *hp;
	int ll, i;

	(void)cmd;
	(void)vl;
	CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
	ONLY_CLIENT(hp, av);

	i = http_rxchunk(hp);
	if (i == 0) {
		ll = hp->rxbuf + hp->prxbuf - hp->body;
		hp->bodyl = ll;
		sprintf(hp->bodylen, "%d", ll);
		vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen);
	}
}
开发者ID:daghf,项目名称:varnish-cache-oldfork,代码行数:19,代码来源:vtc_http.c

示例3: Lck__Trylock

int
Lck__Trylock(struct lock *lck, const char *p, const char *f, int l)
{
	struct ilck *ilck;
	int r;

	CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
	r = pthread_mutex_lock(&ilck->mtx);
	assert(r == 0 || errno == EBUSY);
	if (params->diag_bitmap & 0x8)
		VSL(SLT_Debug, 0,
		    "MTX_TRYLOCK(%s,%s,%d,%s) = %d", p, f, l, ilck->w);
	if (r == 0) {
		AZ(ilck->held);
		ilck->held = 1;
		ilck->owner = pthread_self();
	}
	return (r);
}
开发者ID:akrito,项目名称:Varnish-Least-Busy-Director,代码行数:19,代码来源:cache_lck.c

示例4: vbe_panic

static void
vbe_panic(const struct director *d, struct vsb *vsb)
{
	struct backend *bp;

	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
	CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC);

	VSB_printf(vsb, "      display_name = %s\n", bp->display_name);
	if (bp->ipv4_addr != NULL)
		VSB_printf(vsb, "      ipv4 = %s\n", bp->ipv4_addr);
	if (bp->ipv6_addr != NULL)
		VSB_printf(vsb, "      ipv6 = %s\n", bp->ipv6_addr);
	VSB_printf(vsb, "      port = %s\n", bp->port);
	VSB_printf(vsb, "      hosthdr = %s\n", bp->hosthdr);
	VSB_printf(vsb, "      health=%s, admin_health=%s",
	    bp->healthy ? "healthy" : "sick", bp->admin_health);
	VSB_printf(vsb, ", changed=%.1f\n", bp->health_changed);
}
开发者ID:Drooids,项目名称:Varnish-Cache,代码行数:19,代码来源:cache_backend.c

示例5: cmd_http_accept

static void
cmd_http_accept(CMD_ARGS)
{
	struct http *hp;

	(void)cmd;
	(void)vl;
	CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
	AZ(av[1]);
	assert(hp->sfd != NULL);
	assert(*hp->sfd >= 0);
	if (hp->fd >= 0)
		VTCP_close(&hp->fd);
	vtc_log(vl, 4, "Accepting");
	hp->fd = accept(*hp->sfd, NULL, NULL);
	if (hp->fd < 0)
		vtc_log(vl, 0, "Accepted failed: %s", strerror(errno));
	vtc_log(vl, 3, "Accepted socket fd is %d", hp->fd);
}
开发者ID:midnightskinhead,项目名称:Varnish-Cache,代码行数:19,代码来源:vtc_http.c

示例6: cmd_http_rxreqhdrs

static void
cmd_http_rxreqhdrs(CMD_ARGS)
{
	struct http *hp;

	(void)cmd;
	(void)vl;
	CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
	AZ(strcmp(av[0], "rxreqhdrs"));
	av++;

	for(; *av != NULL; av++)
		vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av);
	http_rxhdr(hp);
	http_splitheader(hp, 1);
	if (http_count_header(hp->req, "Content-Length") > 1)
		vtc_log(hp->vl, 0,
		    "Multiple Content-Length headers.\n");
}
开发者ID:daghf,项目名称:varnish-cache-oldfork,代码行数:19,代码来源:vtc_http.c

示例7: cmd_http_loop

static void
cmd_http_loop(CMD_ARGS)
{
    struct http *hp;
    unsigned n, m;
    char *s;

    CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
    AN(av[1]);
    AN(av[2]);
    AZ(av[3]);
    n = strtoul(av[1], NULL, 0);
    for (m = 1 ; m <= n; m++) {
        vtc_log(vl, 4, "Loop #%u", m);
        s = strdup(av[2]);
        AN(s);
        parse_string(s, cmd, hp, vl);
    }
}
开发者ID:rikard0,项目名称:Varnish-Cache,代码行数:19,代码来源:vtc_http.c

示例8: vbe_dir_http1pipe

static enum sess_close
vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo)
{
	int i;
	enum sess_close retval;
	struct backend *bp;
	struct v1p_acct v1a;
	struct vbc *vbc;

	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
	CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC);

	memset(&v1a, 0, sizeof v1a);

	/* This is hackish... */
	v1a.req = req->acct.req_hdrbytes;
	req->acct.req_hdrbytes = 0;

	req->res_mode = RES_PIPE;

	vbc = vbe_dir_getfd(req->wrk, bp, bo);

	if (vbc == NULL) {
		VSLb(bo->vsl, SLT_FetchError, "no backend connection");
		retval = SC_TX_ERROR;
	} else {
		i = V1F_SendReq(req->wrk, bo, &v1a.bereq, 1);
		VSLb_ts_req(req, "Pipe", W_TIM_real(req->wrk));
		if (vbc->state == VBC_STATE_STOLEN)
			VBT_Wait(req->wrk, vbc);
		if (i == 0)
			V1P_Process(req, vbc->fd, &v1a);
		VSLb_ts_req(req, "PipeSess", W_TIM_real(req->wrk));
		bo->htc->doclose = SC_TX_PIPE;
		vbe_dir_finish(d, req->wrk, bo);
		retval = SC_TX_PIPE;
	}
	V1P_Charge(req, &v1a, bp->vsc);
	return (retval);
}
开发者ID:gfraysse,项目名称:Varnish-Cache,代码行数:42,代码来源:cache_backend.c

示例9: Lck__Trylock

Lck__Trylock(struct lock *lck, const char *p, const char *f, int l)
{
	struct ilck *ilck;
	int r;

	(void)p;
	(void)f;
	(void)l;

	CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
	r = pthread_mutex_trylock(&ilck->mtx);
	assert(r == 0 || r == EBUSY);
	if (r == 0) {
		AZ(ilck->held);
		ilck->held = 1;
		ilck->stat->locks++;
		ilck->owner = pthread_self();
	}
	return (r);
}
开发者ID:Matt8109,项目名称:Varnish-Cache,代码行数:20,代码来源:cache_lck.c

示例10: SES_pool_accept_task

void
SES_pool_accept_task(struct worker *wrk, void *arg)
{
	struct sesspool *pp;
	struct sess *sp;

	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
	CAST_OBJ_NOTNULL(pp, arg, SESSPOOL_MAGIC);

	/* Turn accepted socket into a session */
	AN(wrk->aws->r);
	sp = ses_new(pp);
	if (sp == NULL) {
		VCA_FailSess(wrk);
	} else {
		VCA_SetupSess(wrk, sp);
		sp->step = STP_FIRST;
		ses_pool_task(wrk, sp);
	}
}
开发者ID:ambernetas,项目名称:varnish-cache,代码行数:20,代码来源:cache_session.c

示例11: mps_mon

mps_mon(struct ocx *ocx, struct todolist *tdl, void *priv)
{
	char buf[256];
	struct ntp_peer *np;
	int i;

	(void)ocx;
	(void)tdl;
	CAST_OBJ_NOTNULL(np, priv, NTP_PEER_MAGIC);
	i = NTP_Peer_Poll(ocx, usc, np, 0.2);
	if (i == 1) {
		NTP_Tool_Format(buf, sizeof buf, np->rx_pkt);
		Put(ocx, OCX_TRACE,
		    "Monitor %s %s %s\n", np->hostname, np->ip, buf);
	} else {
		Put(ocx, OCX_TRACE,
		    "Monitor_err %s %s %d\n", np->hostname, np->ip, i);
	}
	return(TODO_OK);
}
开发者ID:bsdphk,项目名称:Ntimed,代码行数:20,代码来源:main_poll_server.c

示例12: h_addlog

static int
h_addlog(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
    unsigned spec, const char *ptr, uint64_t bitmap)
{
	struct varnish *v;
	int type;

	(void) bitmap;

	type = (spec & VSL_S_CLIENT) ? 'c' :
	    (spec & VSL_S_BACKEND) ? 'b' : '-';
	CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC);

	v->vsl_tag_count[tag]++;

	vtc_log(v->vl, 4, "vsl| %5u %-12s %c %.*s", fd,
	    VSL_tags[tag], type, len, ptr);
	v->vsl_sleep = 100;
	return (0);
}
开发者ID:UsabilityDynamics,项目名称:node-varnish-service,代码行数:20,代码来源:vtc_varnish.c

示例13: sma_free

sma_free(struct storage *s)
{
	struct sma_sc *sma_sc;
	struct sma *sma;

	CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC);
	CAST_OBJ_NOTNULL(sma, s->priv, SMA_MAGIC);
	sma_sc = sma->sc;
	assert(sma->sz == sma->s.space);
	Lck_Lock(&sma_sc->sma_mtx);
	sma_sc->sma_alloc -= sma->sz;
	sma_sc->stats->g_alloc--;
	sma_sc->stats->g_bytes -= sma->sz;
	sma_sc->stats->c_freed += sma->sz;
	if (sma_sc->sma_max != SIZE_MAX)
		sma_sc->stats->g_space += sma->sz;
	Lck_Unlock(&sma_sc->sma_mtx);
	free(sma->s.ptr);
	free(sma);
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:20,代码来源:storage_malloc.c

示例14: SES_Proto_Req

SES_Proto_Req(struct worker *wrk, void *arg)
{
	struct req *req;

	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
	CAST_OBJ_NOTNULL(req, arg, REQ_MAGIC);

	THR_SetRequest(req);
	AZ(wrk->aws->r);
	if (req->sp->sess_step < S_STP_H1_LAST) {
		HTTP1_Session(wrk, req);
		AZ(wrk->v1l);
	} else {
		WRONG("Wrong session step");
	}
	WS_Assert(wrk->aws);
	if (DO_DEBUG(DBG_VCLREL) && wrk->vcl != NULL)
		VCL_Rel(&wrk->vcl);
	THR_SetRequest(NULL);
}
开发者ID:wskuner,项目名称:Varnish-Cache,代码行数:20,代码来源:cache_session.c

示例15: Lck_CondWait

Lck_CondWait(pthread_cond_t *cond, struct lock *lck, struct timespec *ts)
{
	struct ilck *ilck;
	int retval = 0;

	CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
	AN(ilck->held);
	assert(pthread_equal(ilck->owner, pthread_self()));
	ilck->held = 0;
	if (ts == NULL) {
		AZ(pthread_cond_wait(cond, &ilck->mtx));
	} else {
		retval = pthread_cond_timedwait(cond, &ilck->mtx, ts);
		assert(retval == 0 || retval == ETIMEDOUT);
	}
	AZ(ilck->held);
	ilck->held = 1;
	ilck->owner = pthread_self();
	return (retval);
}
开发者ID:drwilco,项目名称:varnish-cache-drwilco,代码行数:20,代码来源:cache_lck.c


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