| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "nacl_io/kernel_proxy.h" | 5 #include "nacl_io/kernel_proxy.h" |
| 6 | 6 |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 int ms_timeout; | 784 int ms_timeout; |
| 785 | 785 |
| 786 // NULL timeout signals wait forever. | 786 // NULL timeout signals wait forever. |
| 787 if (timeout == NULL) { | 787 if (timeout == NULL) { |
| 788 ms_timeout = -1; | 788 ms_timeout = -1; |
| 789 } else { | 789 } else { |
| 790 int64_t ms = timeout->tv_sec * 1000 + ((timeout->tv_usec + 500) / 1000); | 790 int64_t ms = timeout->tv_sec * 1000 + ((timeout->tv_usec + 500) / 1000); |
| 791 | 791 |
| 792 // If the timeout is invalid or too long (larger than signed 32 bit). | 792 // If the timeout is invalid or too long (larger than signed 32 bit). |
| 793 if ((timeout->tv_sec < 0) || (timeout->tv_sec >= (INT_MAX / 1000)) || | 793 if ((timeout->tv_sec < 0) || (timeout->tv_sec >= (INT_MAX / 1000)) || |
| 794 (timeout->tv_usec < 0) || (timeout->tv_usec >= 1000) || | 794 (timeout->tv_usec < 0) || (timeout->tv_usec >= 1000000) || |
| 795 (ms < 0) || (ms >= INT_MAX)) { | 795 (ms < 0) || (ms >= INT_MAX)) { |
| 796 errno = EINVAL; | 796 errno = EINVAL; |
| 797 return -1; | 797 return -1; |
| 798 } | 798 } |
| 799 | 799 |
| 800 ms_timeout = static_cast<int>(ms); | 800 ms_timeout = static_cast<int>(ms); |
| 801 } | 801 } |
| 802 | 802 |
| 803 events.resize(event_track); | 803 events.resize(event_track); |
| 804 listener->Wait(events.data(), event_track, ms_timeout, &ready_cnt); | 804 listener->Wait(events.data(), event_track, ms_timeout, &ready_cnt); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 errno = ENOTSOCK; | 1246 errno = ENOTSOCK; |
| 1247 return -1; | 1247 return -1; |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 return 0; | 1250 return 0; |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 #endif // PROVIDES_SOCKET_API | 1253 #endif // PROVIDES_SOCKET_API |
| 1254 | 1254 |
| 1255 } // namespace_nacl_io | 1255 } // namespace_nacl_io |
| OLD | NEW |