本文整理汇总了C++中VSL函数的典型用法代码示例。如果您正苦于以下问题:C++ VSL函数的具体用法?C++ VSL怎么用?C++ VSL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VSL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SES_Delete
void
SES_Delete(struct sess *sp, enum sess_close reason, double now)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (reason != SC_NULL)
SES_Close(sp, reason);
assert(sp->fd < 0);
if (isnan(now))
now = VTIM_real();
AZ(isnan(sp->t_open));
if (now < sp->t_open) {
VSL(SLT_Debug, sp->vxid,
"Clock step (now=%f < t_open=%f)",
now, sp->t_open);
if (now + cache_param->clock_step < sp->t_open)
WRONG("Clock step detected");
now = sp->t_open; /* Do not log negatives */
}
if (reason == SC_NULL)
reason = (enum sess_close)-sp->fd;
VSL(SLT_SessClose, sp->vxid, "%s %.3f",
sess_close_2str(reason, 0), now - sp->t_open);
VSL(SLT_End, sp->vxid, "%s", "");
SES_Rel(sp);
}
示例2: wrk_thread_real
static void *
wrk_thread_real(void *priv, unsigned thread_workspace)
{
struct worker *w, ww;
unsigned char ws[thread_workspace];
THR_SetName("cache-worker");
w = &ww;
memset(w, 0, sizeof *w);
w->magic = WORKER_MAGIC;
w->lastused = NAN;
AZ(pthread_cond_init(&w->cond, NULL));
WS_Init(w->aws, "wrk", ws, thread_workspace);
VSL(SLT_WorkThread, 0, "%p start", w);
Pool_Work_Thread(priv, w);
AZ(w->pool);
VSL(SLT_WorkThread, 0, "%p end", w);
if (w->vcl != NULL)
VCL_Rel(&w->vcl);
AZ(pthread_cond_destroy(&w->cond));
if (w->nvbo != NULL)
VBO_Free(&w->nvbo);
HSH_Cleanup(w);
WRK_SumStat(w);
return (NULL);
}
示例3: Lck__Lock
Lck__Lock(struct lock *lck, const char *p, const char *f, int l)
{
struct ilck *ilck;
int r;
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
if (!(cache_param->diag_bitmap & 0x18)) {
AZ(pthread_mutex_lock(&ilck->mtx));
AZ(ilck->held);
ilck->stat->locks++;
ilck->owner = pthread_self();
ilck->held = 1;
return;
}
r = pthread_mutex_trylock(&ilck->mtx);
assert(r == 0 || r == EBUSY);
if (r) {
ilck->stat->colls++;
if (cache_param->diag_bitmap & 0x8)
VSL(SLT_Debug, 0, "MTX_CONTEST(%s,%s,%d,%s)",
p, f, l, ilck->w);
AZ(pthread_mutex_lock(&ilck->mtx));
} else if (cache_param->diag_bitmap & 0x8) {
VSL(SLT_Debug, 0, "MTX_LOCK(%s,%s,%d,%s)", p, f, l, ilck->w);
}
AZ(ilck->held);
ilck->stat->locks++;
ilck->owner = pthread_self();
ilck->held = 1;
}
示例4: SES_Delete
void
SES_Delete(struct sess *sp, enum sess_close reason, double now)
{
struct sesspool *pp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
pp = sp->sesspool;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
if (reason != SC_NULL)
SES_Close(sp, reason);
assert(sp->fd < 0);
if (isnan(now))
now = VTIM_real();
AZ(isnan(sp->t_open));
VSL(SLT_SessClose, sp->vxid, "%s %.3f",
sess_close_2str(sp->reason, 0), now - sp->t_open);
VSL(SLT_End, sp->vxid, "%s", "");
Lck_Delete(&sp->mtx);
MPL_Free(pp->mpl_sess, sp);
}
示例5: vmod_geoip2__init
vmod_geoip2__init(VRT_CTX, struct vmod_geoip2_geoip2 **vpp,
const char *vcl_name, VCL_STRING filename)
{
struct vmod_geoip2_geoip2 *vp;
MMDB_s mmdb;
int error;
(void)vcl_name;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(vpp);
AZ(*vpp);
VSL(SLT_Debug, 0, "geoip2.geoip2: Using maxminddb %s",
MMDB_lib_version());
error = MMDB_open(filename, MMDB_MODE_MMAP, &mmdb);
if (error != MMDB_SUCCESS) {
VSL(SLT_Error, 0, "geoip2.geoip2: %s",
MMDB_strerror(error));
return;
}
ALLOC_OBJ(vp, VMOD_GEOIP2_MAGIC);
AN(vp);
*vpp = vp;
vp->mmdb = mmdb;
}
示例6: vmod_clientip
int vmod_clientip(struct sess *sp, const char *ipstring) {
struct addrinfo hints;
struct addrinfo *rp;
int s;
AN(sp);
AN(ipstring);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
// Don't attempt DNS resolution.
hints.ai_flags = AI_NUMERICHOST;
s = getaddrinfo(ipstring, NULL, &hints, &rp);
if (s != 0) {
VSL(SLT_VCL_Log, 0, "ipcast: Unable to decode IP address '%s'",
ipstring);
VSL(SLT_VCL_Log, 0, "ipcast: getaddrinfo(): %s", gai_strerror(s));
return(s);
}
AN(rp);
sp->sockaddrlen = rp->ai_addrlen;
memcpy(sp->sockaddr, rp->ai_addr, rp->ai_addrlen);
freeaddrinfo(rp);
return(0);
}
示例7: ses_vsl_socket
static void
ses_vsl_socket(struct sess *sp, const char *lsockname)
{
struct sockaddr_storage ss;
socklen_t sl;
char laddr[ADDR_BUFSIZE];
char lport[PORT_BUFSIZE];
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(lsockname);
AN(sp->addrs);
sl = sizeof ss;
AZ(getsockname(sp->fd, (void*)&ss, &sl));
AN(VSA_Build(sess_local_addr(sp), &ss, sl));
assert(VSA_Sane(sess_local_addr(sp)));
VTCP_name(sess_remote_addr(sp), laddr, sizeof laddr,
lport, sizeof lport);
sp->client_addr_str = WS_Copy(sp->ws, laddr, -1);
sp->client_port_str = WS_Copy(sp->ws, lport, -1);
VTCP_name(sess_local_addr(sp), laddr, sizeof laddr,
lport, sizeof lport);
VSL(SLT_Begin, sp->vxid, "sess 0 HTTP/1");
VSL(SLT_SessOpen, sp->vxid, "%s %s %s %s %s %.6f %d",
sp->client_addr_str, sp->client_port_str, lsockname, laddr, lport,
sp->t_open, sp->fd);
}
示例8: SES_Delete
void
SES_Delete(struct sess *sp, enum sess_close reason, double now)
{
struct acct *b;
struct sesspool *pp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
pp = sp->sesspool;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
if (reason != SC_NULL)
SES_Close(sp, reason);
assert(sp->fd < 0);
if (isnan(now))
now = VTIM_real();
assert(!isnan(sp->t_open));
b = &sp->acct_ses;
VSL(SLT_SessClose, sp->vxid, "%s %.3f %ju %ju %ju %ju %ju %ju",
sess_close_2str(sp->reason, 0), now - sp->t_open, b->req,
b->pipe, b->pass, b->fetch, b->hdrbytes, b->bodybytes);
VSL(SLT_End, sp->vxid, "%s", "");
Lck_Delete(&sp->mtx);
MPL_Free(pp->mpl_sess, sp);
}
示例9: EXP_Rearm
void
EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
{
double when;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
assert(oc->refcnt > 0);
if (!(oc->exp_flags & OC_EF_REFD))
return;
if (!isnan(ttl))
oc->ttl = now + ttl - oc->t_origin;
if (!isnan(grace))
oc->grace = grace;
if (!isnan(keep))
oc->keep = keep;
when = EXP_WHEN(oc);
VSL(SLT_ExpKill, 0, "EXP_Rearm p=%p E=%.9f e=%.9f f=0x%x", oc,
oc->timer_when, when, oc->flags);
if (when < oc->t_origin || when < oc->timer_when)
exp_mail_it(oc, OC_EF_MOVE);
}
示例10: vwp_extend_pollspace
static void
vwp_extend_pollspace(struct vwp *vwp)
{
size_t inc;
if (vwp->npoll < (1<<12))
inc = (1<<10);
else if (vwp->npoll < (1<<14))
inc = (1<<12);
else if (vwp->npoll < (1<<16))
inc = (1<<14);
else
inc = (1<<16);
VSL(SLT_Debug, 0, "Acceptor poll space increased by %zu to %zu",
inc, vwp->npoll + inc);
vwp->pollfd = realloc(vwp->pollfd,
(vwp->npoll + inc) * sizeof(*vwp->pollfd));
AN(vwp->pollfd);
memset(vwp->pollfd + vwp->npoll, 0, inc * sizeof(*vwp->pollfd));
vwp->idx = realloc(vwp->idx, (vwp->npoll + inc) * sizeof(*vwp->idx));
AN(vwp->idx);
memset(vwp->idx + vwp->npoll, 0, inc * sizeof(*vwp->idx));
for (; inc > 0; inc--)
vwp->pollfd[vwp->npoll++].fd = -1;
}
示例11: vwk_sess_ev
static void
vwk_sess_ev(struct vwk *vwk, const struct kevent *kp, double now)
{
struct sess *sp;
AN(kp->udata);
assert(kp->udata != vwk->pipes);
CAST_OBJ_NOTNULL(sp, kp->udata, SESS_MAGIC);
DSL(DBG_WAITER, sp->vxid, "KQ: sp %p kev data %lu flags 0x%x%s",
sp, (unsigned long)kp->data, kp->flags,
(kp->flags & EV_EOF) ? " EOF" : "");
if (kp->data > 0) {
VTAILQ_REMOVE(&vwk->sesshead, sp, list);
SES_Handle(sp, now);
return;
} else if (kp->flags & EV_EOF) {
VTAILQ_REMOVE(&vwk->sesshead, sp, list);
SES_Delete(sp, SC_REM_CLOSE, now);
return;
} else {
VSL(SLT_Debug, sp->vxid,
"KQ: sp %p kev data %lu flags 0x%x%s",
sp, (unsigned long)kp->data, kp->flags,
(kp->flags & EV_EOF) ? " EOF" : "");
}
}
示例12: child_malloc_fail
static void
child_malloc_fail(void *p, const char *s)
{
VSL(SLT_Error, 0, "MALLOC ERROR: %s (%p)", s, p);
fprintf(stderr, "MALLOC ERROR: %s (%p)\n", s, p);
WRONG("Malloc Error");
}
示例13: vmod_log
vmod_log(VRT_CTX, const char *fmt, ...)
{
const char *p;
va_list ap;
uintptr_t sn;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
sn = WS_Snapshot(ctx->ws);
va_start(ap, fmt);
p = VRT_String(ctx->ws, NULL, fmt, ap);
va_end(ap);
if (p == NULL) {
WS_MarkOverflow(ctx->ws);
WS_Reset(ctx->ws, sn);
return;
}
AN(p);
if (ctx->vsl != NULL)
VSLb(ctx->vsl, SLT_VCL_Log, "%s", p);
else
VSL(SLT_VCL_Log, 0, "%s", p);
WS_Reset(ctx->ws, sn);
}
示例14: vbp_has_poked
static void
vbp_has_poked(struct vbp_target *vt)
{
unsigned i, j;
uint64_t u;
const char *logmsg;
char bits[10];
CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC);
/* Calculate exponential average */
if (vt->happy & 1) {
if (vt->rate < AVG_RATE)
vt->rate += 1.0;
vt->avg += (vt->last - vt->avg) / vt->rate;
}
i = 0;
#define BITMAP(n, c, t, b) bits[i++] = (vt->n & 1) ? c : '-';
#include "tbl/backend_poll.h"
#undef BITMAP
bits[i] = '\0';
u = vt->happy;
for (i = j = 0; i < vt->probe.window; i++) {
if (u & 1)
j++;
u >>= 1;
}
vt->good = j;
Lck_Lock(&vt->mtx);
if (vt->backend != NULL) {
if (vt->good >= vt->probe.threshold) {
if (vt->backend->healthy)
logmsg = "Still healthy";
else {
logmsg = "Back healthy";
vt->backend->health_changed = VTIM_real();
}
vt->backend->healthy = 1;
} else {
if (vt->backend->healthy) {
logmsg = "Went sick";
vt->backend->health_changed = VTIM_real();
} else
logmsg = "Still sick";
vt->backend->healthy = 0;
}
VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f %s",
vt->backend->display_name, logmsg, bits,
vt->good, vt->probe.threshold, vt->probe.window,
vt->last, vt->avg, vt->resp_buf);
if (!vt->disable) {
AN(vt->backend->vsc);
vt->backend->vsc->happy = vt->happy;
}
}
Lck_Unlock(&vt->mtx);
}
示例15: VGZ_Gunzip
int
VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen)
{
int i;
ssize_t l;
const uint8_t *before;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
*pptr = NULL;
*plen = 0;
AN(vg->vz.next_out);
AN(vg->vz.avail_out);
before = vg->vz.next_out;
i = inflate(&vg->vz, 0);
if (i == Z_OK || i == Z_STREAM_END) {
*pptr = before;
l = (const uint8_t *)vg->vz.next_out - before;
*plen = l;
if (vg->st_obuf != NULL)
vg->st_obuf->len += l;
}
vg->last_i = i;
if (i == Z_OK)
return (VGZ_OK);
if (i == Z_STREAM_END)
return (VGZ_END);
if (i == Z_BUF_ERROR)
return (VGZ_STUCK);
VSL(SLT_Debug, 0, "Unknown INFLATE=%d (%s)\n", i, vg->vz.msg);
return (VGZ_ERROR);
}