Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid singleton in storage_write's raisesigs() #312

Merged
merged 1 commit into from
Jul 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tar/storage/storage_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct storage_write_internal {

/* Number of bytes of pending writes. */
size_t nbytespending;

/* Last time we wrote a checkpoint. */
uint64_t lastcheckpoint;
};

struct write_fexist_internal {
Expand Down Expand Up @@ -86,7 +89,6 @@ static handlepacket_callback callback_write_file_response;
static void
raisesigs(struct storage_write_internal * S)
{
static uint64_t lastcheckpoint = 0;
uint64_t in, out, queued;
uint64_t totalout = 0;
size_t i;
Expand All @@ -105,8 +107,8 @@ raisesigs(struct storage_write_internal * S)

/* Send a SIGUSR2 if appropriate. */
if (tarsnap_opt_checkpointbytes != (uint64_t)(-1)) {
if (totalout > lastcheckpoint + tarsnap_opt_checkpointbytes) {
lastcheckpoint = totalout;
if (totalout > S->lastcheckpoint + tarsnap_opt_checkpointbytes) {
S->lastcheckpoint = totalout;
if (raise(SIGUSR2))
warnp("raise(SIGUSR2)");
}
Expand Down Expand Up @@ -143,6 +145,9 @@ storage_write_start(uint64_t machinenum, const uint8_t lastseq[32],
/* No pending writes so far. */
S->nbytespending = 0;

/* No checkpoint yet. */
S->lastcheckpoint = 0;

/* Open netpacket connections. */
for (i = 0; i < S->numconns; i++) {
if ((S->NPC[i] = netpacket_open(USERAGENT)) == NULL)
Expand Down