Plan 9 from Bell Labs’s /usr/web/sources/contrib/axel/8021x/v215/phases.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <thread.h>
#include "dat.h"
#include "fns.h"

static Phasestate ThePhases[2];

Phasestate*
phasesinit(void)
{
	Phasestate *p;

	p = ThePhases;
	memset(p, 0, sizeof(ThePhases));
	return p;
}


// phases are 1, 2, ...
// s->phase  indices are 0, 1, ...
void
markPhaseStart(int phase, char *type)
{
	Phasestate *s;
	int i;

	if (phase <= 0 || phase > nelem(ThePhases))
		return;

	s = ThePhases;
	i = phase - 1;
	free(s[i].type);
	s[i].type = strdup(type);
	s[i].startTime = nsec();
	logall("auth phase %d starts: %s", phase, type);
}

void
markPhaseDone(int phase, char *type)
{
	Phasestate *s;
	int i;

	if (phase <= 0 || phase > nelem(ThePhases))
		return;

	s = ThePhases;
	i = phase - 1;
	free(s[i].type);
	s[i].type = strdup(type);
	s[i].doneTime = nsec();
	logall("auth phase %d done: %s", phase, type);
}

void
markPhaseResult(int phase, char *type, int success)
{
	Phasestate *s;
	int i;

	if (phase <= 0 || phase > nelem(ThePhases))
		return;

	s = ThePhases;
	i = phase - 1;
	free(s[i].type);
	s[i].type = strdup(type);
	s[i].success = success;
	s[i].doneTime = nsec();
	logall("auth phase %d done: %s: %s", phase, type, success ? "success" : "fail");
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.