- 论坛徽章:
- 0
|
据我所知多进程下是没有问题的,至少在比较新的平台,你的模型和apache的event mpm类似 据闻nginx也是这样使用 熟悉的可以证实下 有两点
可能会对此有影响:1,epoll_wait 的句柄需要在父进程中调用listen
2, epoll_wait的fd_set 是在你的子进程中创建
根据目前的测试 没有发现问题
再说下这样的好处 还是多进程的好处 即使一个进程挂掉 服务不会有影响 再结合一个执行简单维护子进程工作的父进程,稳定,高效。
Hi,
If multiple threads are parked on epoll_wait (on a single epoll fd) and
events become available, epoll performs a wake up of all threads of the
poll wait list, causing a thundering herd of processes trying to grab
the eventpoll lock.
This patch addresses this by using exclusive waiters (wake one). Once
the exclusive thread finishes transferring it's events, a new thread
is woken if there are more events available.
Makes sense?
Signed-off-by: Davi E. M. Arnaut <davi@haxent.com.br>
---
fs/eventpoll.c | 7 +++++++
1 file changed, 7 insertions(+)
Index: linux-2.6/fs/eventpoll.c
===================================================================
--- linux-2.6.orig/fs/eventpoll.c
+++ linux-2.6/fs/eventpoll.c
@@ -1491,6 +1491,12 @@ static void ep_reinject_items(struct eve
}
}
+ /*
+ * If there is events available, wake up the next waiter, if any.
+ */
+ if (!ricnt)
+ ricnt = !list_empty(&ep->rdllist);
+
if (ricnt) {
/*
* Wake up ( if active ) both the eventpoll wait list and the ->poll()
@@ -1570,6 +1576,7 @@ retry:
* ep_poll_callback() when events will become available.
*/
init_waitqueue_entry(&wait, current);
+ wait.flags |= WQ_FLAG_EXCLUSIVE;
__add_wait_queue(&ep->wq, &wait);
for (; {
wait.flags |= WQ_FLAG_EXCLUSIVE;
这句是后来加进去的 至少2.6.24后的内核是有的 也就是说这个补丁是被打上拉 设置了互斥进程的标志
[ 本帖最后由 zhoubug 于 2009-5-6 21:08 编辑 ] |
|