diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-24 22:12:10 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-24 22:12:10 +0200 |
commit | dcfda3176f6f04c399d09b1e8666c8319f555995 (patch) | |
tree | e016ef2a8142cbee6e778b5e4ef4bc895507b161 /debian/patches/introspection0009-fixup_libports.patch | |
parent | 6fe95b3abd62ef9dd39a03af845ff0e9b306e0f0 (diff) |
add patch series
Diffstat (limited to 'debian/patches/introspection0009-fixup_libports.patch')
-rw-r--r-- | debian/patches/introspection0009-fixup_libports.patch | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/debian/patches/introspection0009-fixup_libports.patch b/debian/patches/introspection0009-fixup_libports.patch new file mode 100644 index 00000000..4334c489 --- /dev/null +++ b/debian/patches/introspection0009-fixup_libports.patch @@ -0,0 +1,122 @@ +From c899d36cf0358036428e0f545da0ea1bff812022 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Thu, 24 Sep 2015 18:23:28 +0200 +Subject: [PATCH hurd 09/10] fixup_libports + +--- + libports/introspection.c | 35 ++++++++++++++++++++--------------- + libports/manage-multithread.c | 6 ++++-- + libports/manage-one-thread.c | 6 ++++-- + libports/ports.h | 1 + + 4 files changed, 29 insertions(+), 19 deletions(-) + +diff --git a/libports/introspection.c b/libports/introspection.c +index 912c768..07f8624 100644 +--- a/libports/introspection.c ++++ b/libports/introspection.c +@@ -71,24 +71,29 @@ service_introspection_requests (void *arg) + return NULL; + } + +-/* Start the introspection server before main is called. */ +-static void __attribute__ ((constructor)) +-init (void) ++/* Start the introspection server if it is not already running. */ ++void ++_ports_start_introspection_server (void) + { ++ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; ++ static int initialized = 0; + error_t err; +- + pthread_t thread; +- pthread_attr_t attr; +-#define STACK_SIZE (64 * 1024) +- pthread_attr_init (&attr); +- pthread_attr_setstacksize (&attr, STACK_SIZE); +-#undef STACK_SIZE +- +- err = pthread_create (&thread, &attr, +- service_introspection_requests, NULL); +- if (err) +- error (1, err, "pthread_create"); +- pthread_detach (thread); ++ ++ pthread_mutex_lock (&lock); ++ if (! initialized) ++ { ++ err = pthread_create (&thread, NULL, ++ service_introspection_requests, NULL); ++ if (err) ++ error (0, err, "Error starting introspection server"); ++ else ++ { ++ pthread_detach (thread); ++ initialized = 1; ++ } ++ } ++ pthread_mutex_unlock (&lock); + } + + /* Return the number of hard and weak references of the object +diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c +index 8707d98..d2e7dbe 100644 +--- a/libports/manage-multithread.c ++++ b/libports/manage-multithread.c +@@ -214,8 +214,7 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, + } + ports_port_deref (pi); + +- if (__builtin_expect (MACH_PORT_VALID (trace_port), 0) +- && outp->RetCode != MIG_NO_REPLY) ++ if (__builtin_expect (MACH_PORT_VALID (trace_port), 0)) + introspection_trace_message (trace_port, outp, trace_id); + } + else +@@ -291,5 +290,8 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, + master thread from going away. */ + global_timeout = 0; + ++ /* Make sure the introspection server is running. */ ++ _ports_start_introspection_server (); ++ + thread_function ((void *) 1); + } +diff --git a/libports/manage-one-thread.c b/libports/manage-one-thread.c +index 55aa378..86d575e 100644 +--- a/libports/manage-one-thread.c ++++ b/libports/manage-one-thread.c +@@ -104,8 +104,7 @@ ports_manage_port_operations_one_thread (struct port_bucket *bucket, + } + ports_port_deref (pi); + +- if (__builtin_expect (MACH_PORT_VALID (trace_port), 0) +- && outp->RetCode != MIG_NO_REPLY) ++ if (__builtin_expect (MACH_PORT_VALID (trace_port), 0)) + introspection_trace_message (trace_port, outp, trace_id); + } + else +@@ -125,6 +124,9 @@ ports_manage_port_operations_one_thread (struct port_bucket *bucket, + zero. */ + timeout = 0; + ++ /* Make sure the introspection server is running. */ ++ _ports_start_introspection_server (); ++ + _ports_thread_online (&bucket->threadpool, &thread); + do + err = mach_msg_server_timeout (internal_demuxer, 0, bucket->portset, +diff --git a/libports/ports.h b/libports/ports.h +index a31b894..e61b38c 100644 +--- a/libports/ports.h ++++ b/libports/ports.h +@@ -496,5 +496,6 @@ void _ports_complete_deallocate (struct port_info *); + error_t _ports_create_port_internal (struct port_class *, struct port_bucket *, + size_t, void *, int); + error_t _ports_trace_message (mach_port_t, const mach_msg_header_t *); ++void _ports_start_introspection_server (void); + + #endif +-- +2.1.4 + |