Skip to content

Commit a6832a6

Browse files
author
Зишан Мирза
committed
fix: file read
1 parent 3f63e6f commit a6832a6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libc/src/time/time_utils.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ static int64_t computeRemainingYears(int64_t daysPerYears,
2727
return years;
2828
}
2929

30-
volatile int lock = 0;
30+
volatile int file_usage = 0;
3131

3232
void release_file(FILE *fp) {
33-
lock = 0;
33+
file_usage = 0;
3434
fclose(fp);
3535
}
3636

3737
void acquire_file(FILE *fp, char *timezone) {
3838
while (1) {
39-
if (lock == 0) {
40-
lock = 1;
39+
if (file_usage == 0) {
40+
file_usage = 1;
4141
break;
4242
}
4343
}
@@ -161,7 +161,8 @@ int64_t update_from_seconds(int64_t total_seconds, struct tm *tm) {
161161
acquire_file(fp, timezone);
162162
}
163163

164-
if (lock == 0) {
164+
if (file_usage == 0) {
165+
release_file(fp);
165166
return time_utils::out_of_range();
166167
}
167168

0 commit comments

Comments
 (0)