sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [sleepy.penguin] [PATCH 1/2] epoll: use pthread_once properly
@ 2013-01-24  0:47 Eric Wong
  2013-01-24  0:47 ` [sleepy.penguin] [PATCH 2/2] epoll: update documentation for multi-threaded use Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2013-01-24  0:47 UTC (permalink / raw)
  To: sleepy.penguin

pthread_once_t must be static to be effective.  This bug only
affects apps which load sleepy_penguin multiple times.
---
 ext/sleepy_penguin/epoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index 2b7f5c1..7297f70 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -682,7 +682,7 @@ static void epoll_once(void)
 void sleepy_penguin_init_epoll(void)
 {
 	VALUE mSleepyPenguin, cEpoll;
-	pthread_once_t once = PTHREAD_ONCE_INIT;
+	static pthread_once_t once = PTHREAD_ONCE_INIT;
 	int err = pthread_once(&once, epoll_once);
 
 	if (err) {
-- 
1.8.1.46.gcb3a6ab



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [sleepy.penguin] [PATCH 2/2] epoll: update documentation for multi-threaded use
  2013-01-24  0:47 [sleepy.penguin] [PATCH 1/2] epoll: use pthread_once properly Eric Wong
@ 2013-01-24  0:47 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2013-01-24  0:47 UTC (permalink / raw)
  To: sleepy.penguin

We forgot to update this documentation when we released 3.1.0
---
 ext/sleepy_penguin/epoll.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index 7297f70..3dcd357 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -400,8 +400,10 @@ static VALUE real_epwait(struct ep_per_thread *ept)
  *
  * Calls epoll_wait(2) and yields Integer +flags+ and IO objects watched
  * for.  +maxevents+ is the maximum number of events to process at once,
- * lower numbers may prevent starvation when used by dup-ed Epoll objects
- * in multiple threads. +timeout+ is specified in milliseconds, +nil+
+ * lower numbers may prevent starvation when used by Epoll#wait in multiple
+ * threads.  Larger +maxevents+ reduces syscall overhead for
+ * single-threaded applications. +maxevents+ defaults to 64 events.
+ * +timeout+ is specified in milliseconds, +nil+
  * (the default) meaning it will block and wait indefinitely.
  */
 static VALUE epwait(int argc, VALUE *argv, VALUE self)
@@ -547,9 +549,8 @@ static int cloexec_dup(struct rb_epoll *ep)
  *	epoll.dup	-> another Epoll object
  *
  * Duplicates an Epoll object and userspace buffers related to this library.
- * This allows the same epoll object in the Linux kernel to be safely used
- * across multiple native threads as long as there is one SleepyPenguin::Epoll
- * object per-thread.
+ * Since SleepyPenguin 3.1.0, this is no longer needed for multi-threaded
+ * Epoll#wait.
  */
 static VALUE init_copy(VALUE copy, VALUE orig)
 {
-- 
1.8.1.46.gcb3a6ab



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-24  0:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-24  0:47 [sleepy.penguin] [PATCH 1/2] epoll: use pthread_once properly Eric Wong
2013-01-24  0:47 ` [sleepy.penguin] [PATCH 2/2] epoll: update documentation for multi-threaded use Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/sleepy_penguin.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).