Пример #1
0
void
WRW_Reserve(struct worker *wrk, int *fd, struct vsl_log *vsl, double t0)
{
	struct wrw *wrw;
	unsigned u;

	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
	AZ(wrk->wrw);
	wrw = (void*)WS_Alloc(wrk->aws, sizeof *wrw);
	AN(wrw);
	memset(wrw, 0, sizeof *wrw);
	wrw->magic = WRW_MAGIC;
	u = WS_Reserve(wrk->aws, 0);
	u = PRNDDN(u);
	u /= sizeof(struct iovec);
	if (u > IOV_MAX)
		u = IOV_MAX;
	AN(u);
	wrw->iov = (void*)PRNDUP(wrk->aws->f);
	wrw->siov = u;
	wrw->ciov = u;
	wrw->werr = 0;
	wrw->liov = 0;
	wrw->niov = 0;
	wrw->wfd = fd;
	wrw->t0 = t0;
	wrw->vsl = vsl;
	wrk->wrw = wrw;
}
Пример #2
0
void
WS_Init(struct ws *ws, const char *id, void *space, unsigned len)
{

	DSL(DBG_WORKSPACE, 0,
	    "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len);
	assert(space != NULL);
	INIT_OBJ(ws, WS_MAGIC);
	ws->s = space;
	assert(PAOK(space));
	len = PRNDDN(len - 1);
	ws->e = ws->s + len;
	*ws->e = 0x15;
	ws->f = ws->s;
	assert(id[0] & 0x40);
	assert(strlen(id) < sizeof ws->id);
	strcpy(ws->id, id);
	WS_Assert(ws);
}
Пример #3
0
unsigned
WS_Reserve(struct ws *ws, unsigned bytes)
{
	unsigned b2;

	WS_Assert(ws);
	assert(ws->r == NULL);

	b2 = PRNDDN(ws->e - ws->f);
	if (bytes != 0 && bytes < b2)
		b2 = PRNDUP(bytes);

	xxxassert(ws->f + b2 <= ws->e);
	ws->r = ws->f + b2;
	DSL(DBG_WORKSPACE, 0, "WS_Reserve(%p, %u/%u) = %u",
	    ws, b2, bytes, pdiff(ws->f, ws->r));
	WS_Assert(ws);
	return (pdiff(ws->f, ws->r));
}
Пример #4
0
void
V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
    double t0)
{
	struct v1l *v1l;
	unsigned u;
	void *res;

	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
	AZ(wrk->v1l);

	if (WS_Overflowed(ws))
		return;
	res = WS_Snapshot(ws);
	v1l = WS_Alloc(ws, sizeof *v1l);
	if (v1l == NULL)
		return;
	INIT_OBJ(v1l, V1L_MAGIC);

	v1l->ws = ws;
	v1l->res = res;

	u = WS_Reserve(ws, 0);
	u = PRNDDN(u);
	u /= sizeof(struct iovec);
	if (u == 0) {
		WS_Release(ws, 0);
		WS_MarkOverflow(ws);
		return;
	} else if (u > IOV_MAX)
		u = IOV_MAX;
	v1l->iov = (void*)PRNDUP(ws->f);
	v1l->siov = u;
	v1l->ciov = u;
	v1l->werr = 0;
	v1l->liov = 0;
	v1l->niov = 0;
	v1l->wfd = fd;
	v1l->t0 = t0;
	v1l->vsl = vsl;
	wrk->v1l = v1l;
}
Пример #5
0
unsigned
WS_Reserve(struct ws *ws, unsigned bytes)
{
	unsigned b2;

	WS_Assert(ws);
	assert(ws->r == NULL);
	if (bytes == 0)
		b2 = ws->e - ws->f;
	else if (bytes > ws->e - ws->f)
		b2 = ws->e - ws->f;
	else
		b2 = bytes;
	b2 = PRNDDN(b2);
	xxxassert(ws->f + b2 <= ws->e);
	ws->r = ws->f + b2;
	DSL(0x02, SLT_Debug, 0, "WS_Reserve(%p, %u/%u) = %u",
	    ws, b2, bytes, pdiff(ws->f, ws->r));
	WS_Assert(ws);
	return (pdiff(ws->f, ws->r));
}