Skip to content

Commit 117ba9f

Browse files
neerajsi-msftdscho
authored andcommitted
bulk-checkin: rename 'state' variable and separate 'plugged' boolean
Preparation for adding bulk-fsync to the bulk-checkin.c infrastructure. * Rename 'state' variable to 'bulk_checkin_state', since we will later be adding 'bulk_fsync_state'. This also makes the variable easier to find in the debugger, since the name is more unique. * Move the 'plugged' data member of 'bulk_checkin_state' into a separate static variable. Doing this avoids resetting the variable in finish_bulk_checkin when zeroing the 'bulk_checkin_state'. As-is, we seem to unintentionally disable the plugging functionality the first time a new packfile must be created due to packfile size limits. While disabling the plugging state only results in suboptimal behavior for the current code, it would be fatal for the bulk-fsync functionality later in this patch series. Signed-off-by: Neeraj Singh <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 40ecf35 commit 117ba9f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

bulk-checkin.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#include "packfile.h"
1111
#include "object-store.h"
1212

13-
static struct bulk_checkin_state {
14-
unsigned plugged:1;
13+
static int bulk_checkin_plugged;
1514

15+
static struct bulk_checkin_state {
1616
char *pack_tmp_name;
1717
struct hashfile *f;
1818
off_t offset;
@@ -21,7 +21,7 @@ static struct bulk_checkin_state {
2121
struct pack_idx_entry **written;
2222
uint32_t alloc_written;
2323
uint32_t nr_written;
24-
} state;
24+
} bulk_checkin_state;
2525

2626
static void finish_tmp_packfile(struct strbuf *basename,
2727
const char *pack_tmp_name,
@@ -277,21 +277,23 @@ int index_bulk_checkin(struct object_id *oid,
277277
int fd, size_t size, enum object_type type,
278278
const char *path, unsigned flags)
279279
{
280-
int status = deflate_to_pack(&state, oid, fd, size, type,
280+
int status = deflate_to_pack(&bulk_checkin_state, oid, fd, size, type,
281281
path, flags);
282-
if (!state.plugged)
283-
finish_bulk_checkin(&state);
282+
if (!bulk_checkin_plugged)
283+
finish_bulk_checkin(&bulk_checkin_state);
284284
return status;
285285
}
286286

287287
void plug_bulk_checkin(void)
288288
{
289-
state.plugged = 1;
289+
assert(!bulk_checkin_plugged);
290+
bulk_checkin_plugged = 1;
290291
}
291292

292293
void unplug_bulk_checkin(void)
293294
{
294-
state.plugged = 0;
295-
if (state.f)
296-
finish_bulk_checkin(&state);
295+
assert(bulk_checkin_plugged);
296+
bulk_checkin_plugged = 0;
297+
if (bulk_checkin_state.f)
298+
finish_bulk_checkin(&bulk_checkin_state);
297299
}

0 commit comments

Comments
 (0)