#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");
}
|