5
我的印象是boost :: asio會默認使用epoll設置,而不是選擇實現,但在運行一些測試後,它看起來像我的設置使用select。在不使用Epoll的Linux上增強Asio
OS:RHEL 4
內核:2.6
GCC:3.4.6
我寫了一個小的測試程序,以驗證正在使用哪個反應器頭部,並且它象使用選擇反應器,而不是它看起來epoll反應堆。
#include <boost/asio.hpp>
#include <string>
#include <iostream>
std::string output;
#if defined(BOOST_ASIO_EPOLL_REACTOR_HPP)
int main(void)
{
std::cout << "you have epoll enabled." << std::endl;
}
#elif defined(BOOST_ASIO_DETAIL_SELECT_REACTOR_HPP)
int main(void)
{
std::cout << "you have select enabled." << std::endl;
}
#else
int main(void)
{
std::cout << "this shit is confusing." << std::endl;
}
#endif
我能做什麼錯?
此代碼印有 「選擇」 對我來說。 在epoll_reactor_fwd.hpp進行了一些挖掘以及更多測試之後,LINUX_VERSION_CODE返回的版本小於2.4.45(這顯然是使用epoll所必需的)。 使用uname -r返回如下: $使用uname -r 2.6.9-78.0.13.ELsmp 如果傻瓜在epoll_reactor_fwd.hpp我可以讓你的程序輸出「epoll的」所需的內核。這是某種服務器配置錯誤? – 2010-06-24 00:44:28
確實如此。我的開發系統輸出LINUX_VERSION_CODE爲132639或KERNEL_VERSION(2,6,31)(並且與2.6.31.5一起發貨 - 這是一個OpenSUSE)。如果你從源碼重建boost,會發生什麼? – Cubbi 2010-06-24 01:55:04
Boost.Asio只是頭部,我懷疑重建助力會有幫助。 – 2010-06-24 03:01:42