diff options
author | Simon Rowe <simon.rowe@eu.citrix.com> | 2012-06-07 18:23:00 +0100 |
---|---|---|
committer | Simon Rowe <simon.rowe@eu.citrix.com> | 2012-06-07 18:23:00 +0100 |
commit | 1d00c73b983b09fbee4d9dc0f58f6663c361c345 (patch) | |
tree | 253891f5444a0e68d080d78c4b17a30467d6cbd9 /tools/xenstore | |
parent | 6d0f60577a9af65ab32a026483cb6c7189aaf842 (diff) | |
download | xen-1d00c73b983b09fbee4d9dc0f58f6663c361c345.tar.gz xen-1d00c73b983b09fbee4d9dc0f58f6663c361c345.tar.bz2 xen-1d00c73b983b09fbee4d9dc0f58f6663c361c345.zip |
xenstore: set read_thread stacksize
xs_watch() creates a thread to wake watchers using default attributes. The
stacksize can be quite large (8 MB on Linux), applications that link against
xenstore end up having a larger memory footprint than necessary.
Signed-off-by: Simon Rowe <simon.rowe@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/xenstore')
-rw-r--r-- | tools/xenstore/xs.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c index e12a4a3ca0..b756f8402a 100644 --- a/tools/xenstore/xs.c +++ b/tools/xenstore/xs.c @@ -702,21 +702,36 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token) struct iovec iov[2]; #ifdef USE_PTHREAD +#define READ_THREAD_STACKSIZE (16 * 1024) + /* We dynamically create a reader thread on demand. */ mutex_lock(&h->request_mutex); if (!h->read_thr_exists) { sigset_t set, old_set; + pthread_attr_t attr; + + if (pthread_attr_init(&attr) != 0) { + mutex_unlock(&h->request_mutex); + return false; + } + if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) { + pthread_attr_destroy(&attr); + mutex_unlock(&h->request_mutex); + return false; + } sigfillset(&set); pthread_sigmask(SIG_SETMASK, &set, &old_set); - if (pthread_create(&h->read_thr, NULL, read_thread, h) != 0) { + if (pthread_create(&h->read_thr, &attr, read_thread, h) != 0) { pthread_sigmask(SIG_SETMASK, &old_set, NULL); + pthread_attr_destroy(&attr); mutex_unlock(&h->request_mutex); return false; } h->read_thr_exists = 1; pthread_sigmask(SIG_SETMASK, &old_set, NULL); + pthread_attr_destroy(&attr); } mutex_unlock(&h->request_mutex); #endif |