From: Eric Wong <normalperson@yhbt.net>
To: ruby.posix.mq@librelist.org
Subject: [PATCH 1/5] notify: set lower bound for notify stack size
Date: Thu, 12 Jul 2012 12:45:37 -0700 [thread overview]
Message-ID: <1342122341-24646-2-git-send-email-normalperson@yhbt.net> (raw)
In-Reply-To: 1342122341-24646-1-git-send-email-normalperson@yhbt.net
Some OSes have ridiculously low boundaries and we don't
want mysterious failures on them
---
ext/posix_mq/posix_mq.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c
index df667e3..66f3f99 100644
--- a/ext/posix_mq/posix_mq.c
+++ b/ext/posix_mq/posix_mq.c
@@ -850,6 +850,19 @@ static void my_mq_notify(mqd_t des, struct sigevent *not)
}
}
+static void lower_stack_size(pthread_attr_t *attr)
+{
+/* some OSes have ridiculously small stack sizes */
+#ifdef PTHREAD_STACK_MIN
+ size_t stack_size = PTHREAD_STACK_MIN;
+ size_t min_size = 4096;
+
+ if (stack_size < min_size)
+ stack_size = min_size;
+ pthread_attr_setstacksize(attr, stack_size);
+#endif
+}
+
/* :nodoc: */
static VALUE setnotify_exec(VALUE self, VALUE io, VALUE thr)
{
@@ -864,10 +877,7 @@ static VALUE setnotify_exec(VALUE self, VALUE io, VALUE thr)
errno = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (errno) rb_sys_fail("pthread_attr_setdetachstate");
-#ifdef PTHREAD_STACK_MIN
- (void)pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
-#endif
-
+ lower_stack_size(&attr);
not.sigev_notify = SIGEV_THREAD;
not.sigev_notify_function = thread_notify_fd;
not.sigev_notify_attributes = &attr;
--
1.7.11.rc0.55.gb2478aa
next prev parent reply other threads:[~2012-07-12 19:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-12 19:45 [PATCH 0/5] some FreeBSD9 fixes pushed to master Eric Wong
2012-07-12 19:45 ` Eric Wong [this message]
2012-07-12 19:45 ` [PATCH 2/5] ext: fix type inconsistencies for int vs mqd_t retvals Eric Wong
2012-07-12 19:45 ` [PATCH 3/5] test: disable IO.select test if #to_io is missing Eric Wong
2012-07-12 19:45 ` [PATCH 4/5] extconf: fix __mq_oshandle() detection on FreeBSD Eric Wong
2012-07-12 19:45 ` [PATCH 5/5] test: relax test timings for timed* tests Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/ruby_posix_mq/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342122341-24646-2-git-send-email-normalperson@yhbt.net \
--to=normalperson@yhbt.net \
--cc=ruby.posix.mq@librelist.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/ruby_posix_mq.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).