static int
update_cookie(void)
{
+ struct sha1_ctx context;
int i;
- SHA1Context context;
- if (SHA1Reset(&context) != shaSuccess) {
- return -1;
- }
+ sha1_init(&context);
for (i = 0; i < cfg.n; i++) {
- if (SHA1Input(&context, (uint8_t *)cfg.names[i],
- strlen(cfg.names[i])) != shaSuccess) {
- return -1;
- }
- SHA1Input(&context, (uint8_t *)"\n", 1);
- }
- if (SHA1Result(&context, cfg_cookie) != shaSuccess) {
- return -1;
+ sha1_update(&context, cfg.names[i], strlen(cfg.names[i]));
+ sha1_update(&context, "\n", 1);
}
+ sha1_final(&context, cfg_cookie);
return 0;
}
int
cfg_lock(uint8_t *cookie, int timeout)
{
- long long int start = time_msec();
+ long long int start;
long long int elapsed = 0;
int fd;
uint8_t curr_cookie[CFG_COOKIE_LEN];
assert(lock_fd < 0);
COVERAGE_INC(cfg_lock);
+
+ time_refresh();
+ start = time_msec();
for (;;) {
int error;