Skip to content

Commit

Permalink
POSIX.xs env locks, check file for more
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed May 5, 2021
1 parent 24950bc commit 287ebe8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ext/POSIX/POSIX.xs
Expand Up @@ -1762,7 +1762,12 @@ my_tzset(pTHX)
#endif
fix_win32_tzenv();
#endif
TZSET_LOCK;
tzset();
TZSET_UNLOCK;
/* After the unlock, another thread could change things, but this is a
* problem with the Posix API generally, not Perl; and the result will be
* self-consistent */
}

MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
Expand Down Expand Up @@ -3478,15 +3483,20 @@ asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1)
mytm.tm_yday = yday;
mytm.tm_isdst = isdst;
if (ix) {
const time_t result = mktime(&mytm);
time_t result;
MKTIME_LOCK;
result = mktime(&mytm);
MKTIME_UNLOCK;
if (result == (time_t)-1)
SvOK_off(TARG);
else if (result == 0)
sv_setpvs(TARG, "0 but true");
else
sv_setiv(TARG, (IV)result);
} else {
ASCTIME_LOCK;
sv_setpv(TARG, asctime(&mytm));
ASCTIME_UNLOCK;
}
ST(0) = TARG;
XSRETURN(1);
Expand Down Expand Up @@ -3573,8 +3583,12 @@ void
tzname()
PPCODE:
EXTEND(SP,2);
/* It is undefined behavior if another thread is changing this while
* its being read */
ENVr_LOCALEr_LOCK;
PUSHs(newSVpvn_flags(tzname[0], strlen(tzname[0]), SVs_TEMP));
PUSHs(newSVpvn_flags(tzname[1], strlen(tzname[1]), SVs_TEMP));
ENVr_LOCALEr_UNLOCK;

char *
ctermid(s = 0)
Expand Down

0 comments on commit 287ebe8

Please sign in to comment.