static void wsl(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) { char *p; unsigned n, mlen; txt t; AN(fmt); mlen = cache_param->shm_reclen; if (strchr(fmt, '%') == NULL) { t.b = TRUST_ME(fmt); t.e = strchr(t.b, '\0'); wslr(vsl, tag, id, t); } else { assert(vsl->wlp < vsl->wle); /* Wrap if we cannot fit a full size record */ if (VSL_END(vsl->wlp, mlen) >= vsl->wle) VSL_Flush(vsl, 1); p = VSL_DATA(vsl->wlp); n = vsnprintf(p, mlen, fmt, ap); if (n > mlen) n = mlen; /* we truncate long fields */ vsl_hdr(tag, vsl->wlp, n, id); vsl->wlp = VSL_END(vsl->wlp, n); assert(vsl->wlp < vsl->wle); vsl->wlr++; } if (cache_param->diag_bitmap & 0x10000) VSL_Flush(vsl, 0); }
static void wslr(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) { unsigned l, mlen; Tcheck(t); if (id == -1) id = vsl->wid; mlen = cache_param->shm_reclen; /* Truncate */ l = Tlen(t); if (l > mlen) { l = mlen; t.e = t.b + l; } assert(vsl->wlp < vsl->wle); /* Wrap if necessary */ if (VSL_END(vsl->wlp, l) >= vsl->wle) VSL_Flush(vsl, 1); assert(VSL_END(vsl->wlp, l) < vsl->wle); memcpy(VSL_DATA(vsl->wlp), t.b, l); vsl_hdr(tag, vsl->wlp, l, id); vsl->wlp = VSL_END(vsl->wlp, l); assert(vsl->wlp < vsl->wle); vsl->wlr++; if (cache_param->diag_bitmap & 0x10000) VSL_Flush(vsl, 0); }
void WSLR(struct worker *wrk, enum VSL_tag_e tag, int id, txt t) { unsigned l, mlen; Tcheck(t); mlen = cache_param->shm_reclen; /* Truncate */ l = Tlen(t); if (l > mlen) { l = mlen; t.e = t.b + l; } assert(wrk->wlp < wrk->wle); /* Wrap if necessary */ if (VSL_END(wrk->wlp, l) >= wrk->wle) WSL_Flush(wrk, 1); assert (VSL_END(wrk->wlp, l) < wrk->wle); memcpy(VSL_DATA(wrk->wlp), t.b, l); vsl_hdr(tag, wrk->wlp, l, id); wrk->wlp = VSL_END(wrk->wlp, l); assert(wrk->wlp < wrk->wle); wrk->wlr++; if (cache_param->diag_bitmap & 0x10000) WSL_Flush(wrk, 0); }
static void vslr(enum VSL_tag_e tag, uint32_t vxid, const char *b, unsigned len) { uint32_t *p; unsigned mlen; mlen = cache_param->shm_reclen; /* Truncate */ if (len > mlen) len = mlen; p = vsl_get(len, 1, 0); memcpy(p + 2, b, len); vsl_hdr(tag, p, len, vxid); }