Always se long poll() timeout
Many init systems do their own backgrounding so use long timeout unconditionally. Change suggested by Manuel Domke.
This commit is contained in:
@@ -53,7 +53,7 @@ static void outputBytes(uint8_t *bytes, uint32_t length, uint32_t entropy, struc
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inmWaitForPoolToHaveRoom(opts);
|
inmWaitForPoolToHaveRoom();
|
||||||
inmWriteEntropyToPool(bytes, length, entropy);
|
inmWriteEntropyToPool(bytes, length, entropy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ void inmClearEntropyLevel(void);
|
|||||||
bool inmEntropyOnTarget(uint32_t entropy, uint32_t bits);
|
bool inmEntropyOnTarget(uint32_t entropy, uint32_t bits);
|
||||||
void inmWriteEntropyStart(uint32_t bufLen, struct opt_struct *opts);
|
void inmWriteEntropyStart(uint32_t bufLen, struct opt_struct *opts);
|
||||||
void inmWriteEntropyToPool(uint8_t *bytes, uint32_t length, uint32_t entropy);
|
void inmWriteEntropyToPool(uint8_t *bytes, uint32_t length, uint32_t entropy);
|
||||||
void inmWaitForPoolToHaveRoom(struct opt_struct *opts);
|
void inmWaitForPoolToHaveRoom(void);
|
||||||
void inmDumpStats(void);
|
void inmDumpStats(void);
|
||||||
void startDaemon(struct opt_struct *opts);
|
void startDaemon(struct opt_struct *opts);
|
||||||
bool isSuperUser(void);
|
bool isSuperUser(void);
|
||||||
|
|||||||
@@ -60,21 +60,17 @@ void inmWriteEntropyStart(uint32_t bufLen, struct opt_struct* opts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block until either the entropy pool has room, or 1 second has passed.
|
// Block until either the entropy pool has room, or 1 minute has passed.
|
||||||
void inmWaitForPoolToHaveRoom(struct opt_struct *opts) {
|
void inmWaitForPoolToHaveRoom() {
|
||||||
int ent_count;
|
int ent_count;
|
||||||
struct pollfd pfd = {
|
struct pollfd pfd = {
|
||||||
.fd = inmDevRandomFD,
|
.fd = inmDevRandomFD,
|
||||||
.events = POLLOUT,
|
.events = POLLOUT,
|
||||||
};
|
};
|
||||||
int64_t timeout_msec;
|
|
||||||
if (ioctl(inmDevRandomFD, RNDGETENTCNT, &ent_count) == 0 && (uint32_t)ent_count < inmFillWatermark) {
|
if (ioctl(inmDevRandomFD, RNDGETENTCNT, &ent_count) == 0 && (uint32_t)ent_count < inmFillWatermark) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timeout_msec = 1000u; // One second
|
poll(&pfd, 1, 1000u * 60u); // One minute
|
||||||
if (opts->daemon)
|
|
||||||
timeout_msec *= 60u; // Do not poll aggressively when in the background
|
|
||||||
poll(&pfd, 1, timeout_msec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the bytes to the entropy pool. This can be unwhitenened, but the estimated bits of
|
// Add the bytes to the entropy pool. This can be unwhitenened, but the estimated bits of
|
||||||
|
|||||||
Reference in New Issue
Block a user