| 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/unistd.h> | 5 #include <asm/unistd.h> |
| 6 #include <dirent.h> | 6 #include <dirent.h> |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <poll.h> | 8 #include <poll.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <pty.h> | 10 #include <pty.h> |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 // This tests that blocking on recvmsg() in one thread does not | 1232 // This tests that blocking on recvmsg() in one thread does not |
| 1233 // produce a deadlock if another thread attempts to do sendmsg() to | 1233 // produce a deadlock if another thread attempts to do sendmsg() to |
| 1234 // send a message that the first thread is waiting for. The trusted | 1234 // send a message that the first thread is waiting for. The trusted |
| 1235 // process should not wait for recvmsg() to finish before processing | 1235 // process should not wait for recvmsg() to finish before processing |
| 1236 // more system calls. | 1236 // more system calls. |
| 1237 StartSeccompSandbox(); | 1237 StartSeccompSandbox(); |
| 1238 | 1238 |
| 1239 int sock_pair[2]; | 1239 int sock_pair[2]; |
| 1240 CHECK_SUCCEEDS(socketpair(AF_UNIX, SOCK_STREAM, 0, sock_pair) == 0); | 1240 CHECK_SUCCEEDS(socketpair(AF_UNIX, SOCK_STREAM, 0, sock_pair) == 0); |
| 1241 pthread_t tid; | 1241 pthread_t tid; |
| 1242 int err = pthread_create(&tid, NULL, recvmsg_thread, (void *) sock_pair[0]); | 1242 int err = pthread_create(&tid, NULL, recvmsg_thread, |
| 1243 reinterpret_cast<void*>(sock_pair[0])); |
| 1243 CHECK(err == 0); | 1244 CHECK(err == 0); |
| 1244 | 1245 |
| 1245 // In order to test for the deadlock, we need to wait for the child | 1246 // In order to test for the deadlock, we need to wait for the child |
| 1246 // thread to run long enough to block in recvmsg(). Unfortunately, | 1247 // thread to run long enough to block in recvmsg(). Unfortunately, |
| 1247 // there is no way to wait until another thread is blocked, so we | 1248 // there is no way to wait until another thread is blocked, so we |
| 1248 // need to use a sleep. No value is correct here: On a heavily | 1249 // need to use a sleep. No value is correct here: On a heavily |
| 1249 // loaded machine, the child thread might not get scheduled in time. | 1250 // loaded machine, the child thread might not get scheduled in time. |
| 1250 // We pick a sleep time that is respectably large without slowing | 1251 // We pick a sleep time that is respectably large without slowing |
| 1251 // the tests down too much. | 1252 // the tests down too much. |
| 1252 CHECK_SUCCEEDS(poll(NULL, 0, 200) == 0); | 1253 CHECK_SUCCEEDS(poll(NULL, 0, 200) == 0); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 if (failures == 0) { | 1384 if (failures == 0) { |
| 1384 printf("OK\n"); | 1385 printf("OK\n"); |
| 1385 return 0; | 1386 return 0; |
| 1386 } | 1387 } |
| 1387 else { | 1388 else { |
| 1388 printf("%i FAILURE(S)\n", failures); | 1389 printf("%i FAILURE(S)\n", failures); |
| 1389 return 1; | 1390 return 1; |
| 1390 } | 1391 } |
| 1391 } | 1392 } |
| 1392 } | 1393 } |
| OLD | NEW |