Fix clock offset for looms with the same host
The offset is applied to all looms matching the host in the form "loom.${host}.${suffix}", where the suffix is ignored.
This commit is contained in:
parent
121030537d
commit
598aea7dc9
41
emu.c
41
emu.c
@ -826,21 +826,28 @@ parse_args(struct ovni_emu *emu, int argc, char *argv[])
|
|||||||
emu->tracedir = argv[optind];
|
emu->tracedir = argv[optind];
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ovni_loom *
|
static void
|
||||||
find_loom_by_hostname(struct ovni_emu *emu, char *host)
|
set_clock_offsets(struct ovni_emu *emu, const char *host, size_t offset)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t matches = 0;
|
||||||
struct ovni_loom *loom;
|
|
||||||
|
|
||||||
for(i=0; i<emu->trace.nlooms; i++)
|
for(size_t i = 0; i < emu->trace.nlooms; i++)
|
||||||
{
|
{
|
||||||
loom = &emu->trace.loom[i];
|
struct ovni_loom *loom = &emu->trace.loom[i];
|
||||||
|
|
||||||
if(strcmp(loom->hostname, host) == 0)
|
/* Match the hostname exactly */
|
||||||
return loom;
|
if(strcmp(loom->hostname, host) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(loom->clock_offset != 0)
|
||||||
|
die("loom %s already has a clock offset\n", loom->dname);
|
||||||
|
|
||||||
|
loom->clock_offset = offset;
|
||||||
|
matches++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
if(matches == 0)
|
||||||
|
die("no loom has hostname %s\n", host);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -896,21 +903,7 @@ load_clock_offsets(struct ovni_emu *emu)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
loom = find_loom_by_hostname(emu, host);
|
set_clock_offsets(emu, host, (int64_t) offset);
|
||||||
|
|
||||||
if(loom == NULL)
|
|
||||||
{
|
|
||||||
err("No loom has hostname %s\n", host);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(loom->clock_offset != 0)
|
|
||||||
{
|
|
||||||
err("warning: loom at host %s already has a clock offset\n",
|
|
||||||
host);
|
|
||||||
}
|
|
||||||
|
|
||||||
loom->clock_offset = (int64_t) offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then populate the stream offsets */
|
/* Then populate the stream offsets */
|
||||||
|
Loading…
Reference in New Issue
Block a user