1 // RUN: %clang_tsan %s -o %t -framework Foundation
2 // RUN: %run %t 2>&1 | FileCheck %s
6 #import <Foundation/Foundation.h>
11 int main(int argc, const char *argv[]) {
12 fprintf(stderr, "Hello world.\n");
14 dispatch_queue_t server_q = dispatch_queue_create("server.queue", DISPATCH_QUEUE_CONCURRENT);
15 xpc_connection_t server_conn = xpc_connection_create(NULL, server_q);
17 xpc_connection_set_event_handler(server_conn, ^(xpc_object_t client) {
18 if (client == XPC_ERROR_CONNECTION_INTERRUPTED || client == XPC_ERROR_CONNECTION_INVALID) {
21 dispatch_async(dispatch_get_main_queue(), ^{
22 CFRunLoopStop(CFRunLoopGetCurrent());
26 xpc_connection_resume(server_conn);
30 xpc_connection_cancel(server_conn);
34 fprintf(stderr, "Done.\n");
37 // CHECK: Hello world.
38 // CHECK-NOT: WARNING: ThreadSanitizer