OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <asm/prctl.h> | 5 #include <asm/prctl.h> |
6 #include <asm/unistd.h> | 6 #include <asm/unistd.h> |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <poll.h> | 9 #include <poll.h> |
10 #include <pthread.h> | 10 #include <pthread.h> |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 // This tests that blocking on recvmsg() in one thread does not | 1252 // This tests that blocking on recvmsg() in one thread does not |
1253 // produce a deadlock if another thread attempts to do sendmsg() to | 1253 // produce a deadlock if another thread attempts to do sendmsg() to |
1254 // send a message that the first thread is waiting for. The trusted | 1254 // send a message that the first thread is waiting for. The trusted |
1255 // process should not wait for recvmsg() to finish before processing | 1255 // process should not wait for recvmsg() to finish before processing |
1256 // more system calls. | 1256 // more system calls. |
1257 StartSeccompSandbox(); | 1257 StartSeccompSandbox(); |
1258 | 1258 |
1259 int sock_pair[2]; | 1259 int sock_pair[2]; |
1260 CHECK_SUCCEEDS(socketpair(AF_UNIX, SOCK_STREAM, 0, sock_pair) == 0); | 1260 CHECK_SUCCEEDS(socketpair(AF_UNIX, SOCK_STREAM, 0, sock_pair) == 0); |
1261 pthread_t tid; | 1261 pthread_t tid; |
1262 int err = pthread_create(&tid, NULL, recvmsg_thread, (void *) sock_pair[0]); | 1262 int err = pthread_create(&tid, NULL, recvmsg_thread, |
| 1263 reinterpret_cast<void*>(sock_pair[0])); |
1263 CHECK(err == 0); | 1264 CHECK(err == 0); |
1264 | 1265 |
1265 // In order to test for the deadlock, we need to wait for the child | 1266 // In order to test for the deadlock, we need to wait for the child |
1266 // thread to run long enough to block in recvmsg(). Unfortunately, | 1267 // thread to run long enough to block in recvmsg(). Unfortunately, |
1267 // there is no way to wait until another thread is blocked, so we | 1268 // there is no way to wait until another thread is blocked, so we |
1268 // need to use a sleep. No value is correct here: On a heavily | 1269 // need to use a sleep. No value is correct here: On a heavily |
1269 // loaded machine, the child thread might not get scheduled in time. | 1270 // loaded machine, the child thread might not get scheduled in time. |
1270 // We pick a sleep time that is respectably large without slowing | 1271 // We pick a sleep time that is respectably large without slowing |
1271 // the tests down too much. | 1272 // the tests down too much. |
1272 CHECK_SUCCEEDS(poll(NULL, 0, 200) == 0); | 1273 CHECK_SUCCEEDS(poll(NULL, 0, 200) == 0); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 if (failures == 0) { | 1532 if (failures == 0) { |
1532 printf("OK\n"); | 1533 printf("OK\n"); |
1533 return 0; | 1534 return 0; |
1534 } | 1535 } |
1535 else { | 1536 else { |
1536 printf("%i FAILURE(S)\n", failures); | 1537 printf("%i FAILURE(S)\n", failures); |
1537 return 1; | 1538 return 1; |
1538 } | 1539 } |
1539 } | 1540 } |
1540 } | 1541 } |
OLD | NEW |