Skip to content

Conversation

@jscals
Copy link

@jscals jscals commented Jun 2, 2017

macOS supports the thread safegmtime_r so I changed the logic in OPENSSL_gmtime() to make it choose that over gmtime.

Calls to gmtime have been updated to use OPENSSL_gmtime() which makes the right decision on which function to use depending on the system.

Updated calls to localtime to call localtime_r if supported on that system. (Used similar logic as OPENSSL_gmtime() uses to determine which systems support it. If gmtime_r is supported so should localtime_r.)

Checklist
  • documentation is added or updated
  • tests are added or updated

@openssl-machine openssl-machine added the hold: cla required The contributor needs to submit a license agreement label Jun 2, 2017
@jscals jscals force-pushed the threadsafe-fix-1_0_2 branch from 16850de to 40c8403 Compare June 2, 2017 21:32
@openssl-machine openssl-machine added the hold: cla required The contributor needs to submit a license agreement label Jun 2, 2017
@richsalz richsalz removed the hold: cla required The contributor needs to submit a license agreement label Jun 3, 2017
crypto/mem_dbg.c Outdated
Copy link
Contributor

@dot-asm dot-asm Jun 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one takes this approach, one has to fix pointer handling on in 64-bit VMS build, see o_time.c in master.

crypto/o_time.c Outdated
Copy link
Contributor

@dot-asm dot-asm Jun 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Maybe 64-bit VMS is not supported in 1.0.2, in which case one doesn't have to go through pointer trouble mentioned above... @levitte, care to weigh in? BTW, !defined(OPENSSL_SYS_MACOSX) was contributed as "make OpenSSL compilable on MacOS/X". One can argue "oh! that was long time ago". Yes, but then it better be explicitly said, e.g. in commit message, preferably with reference when they implemented it or at least oldest version one verified. On the other hand one can argue that it's not the kind of things that one should do in branch that is in maintenance mode, i.e. make adjustment based on current status of nearby computer...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errr, 64-bit pointers is supported in 1.0.2, so yeah, this is something to consider.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revisiting this... I just realised that under "normal" circumstances, gmtime_r is undefined on VMS, so this section never gets built, which means that either the gmtime implementation will be used, or the much more VMSy implementation further down.

The condition above is incorrect, (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) should really be (!defined(OPENSSL_SYS_VMS) || (__CRTL_VER >= 70000000 && (defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE)))... funny thing is that exactly that condition is used to define VMS_GMTIME_OK

So I suggest that the VMS stuff needs a bit of renovation which is beyond the scope of this PR. Or leave it be, let it keep using gmtime (which is supposedly thread safe on VMS, due to internal thread local storage).

…mtime.

Updated uses of gmtime to now call OPENSSL_gmtime instead.

Used similar preprocessor logic to make sure localtime_r is called instead of localtime when applicable.
@jscals jscals force-pushed the threadsafe-fix-1_0_2 branch from 40c8403 to 8631b64 Compare June 12, 2017 16:14
@richsalz
Copy link
Contributor

richsalz commented Nov 4, 2017

so what do we need to move this forward? VMS 64bit pointer? The original poster was only trying to fix Mac. @levitte any thoughts?

@levitte
Copy link
Member

levitte commented Nov 5, 2017

Considering what I just commented, this should be fine for now.

If we want to do things superbly correct, we might want to consider an internal OPENSSL_localtime to be used instead of localtime / localtime_r. However, I don't think that belongs in this PR, and should really only happen if we find issues on select platforms.

@mattcaswell mattcaswell added this to the 1.0.2 milestone Jan 22, 2018
@mattcaswell mattcaswell added the approval: review pending This pull request needs review by a committer label Jan 24, 2018
@mattcaswell
Copy link
Member

Ping @openssl/committers. First review was done by @levitte - waiting for a second.

levitte pushed a commit that referenced this pull request Jan 24, 2018
…mtime.

Updated uses of gmtime to now call OPENSSL_gmtime instead.

Used similar preprocessor logic to make sure localtime_r is called instead
of localtime when applicable.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #3609)
@levitte
Copy link
Member

levitte commented Jan 24, 2018

Merged. 8552d91

@levitte levitte closed this Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: review pending This pull request needs review by a committer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants