Allow the time remaining parameter to nanosleep to be null
authorChristopher Dykes <cdykes@fb.com>
Tue, 9 Aug 2016 23:47:40 +0000 (16:47 -0700)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Tue, 9 Aug 2016 23:53:31 +0000 (16:53 -0700)
Summary: Pah! This definitely wasn't causing the lock tests to segfault. Nope, not at all <_>.

Reviewed By: yfeldblum

Differential Revision: D3691120

fbshipit-source-id: 6601db637f22c7b0bc326907a2a7976f6df7c159

folly/portability/Time.cpp

index bf165f419fbb50d3b6a680c96c9f313365618bfa..79c71b7a462fe0d0f8a5cb2feeb3f138978ec932 100755 (executable)
@@ -320,8 +320,10 @@ tm* localtime_r(const time_t* t, tm* o) {
 
 int nanosleep(const struct timespec* request, struct timespec* remain) {
   Sleep((DWORD)((request->tv_sec * 1000) + (request->tv_nsec / 1000000)));
-  remain->tv_nsec = 0;
-  remain->tv_sec = 0;
+  if (remain != nullptr) {
+    remain->tv_nsec = 0;
+    remain->tv_sec = 0;
+  }
   return 0;
 }