lucklove / ahttpd Goto Github PK
View Code? Open in Web Editor NEW异步网络框架
异步网络框架
在issue里为残疾的gcc4.8维护一个workaround是有多逗逼,不会弄一个patch吗
ThreadPool.hh里面的worker是std::vector<std::thread> workers
ThreadPool::ThreadPool(size_t n, std::function<void()> on_enter, std::function<void()> on_exit)
: workers(n)
{
for(size_t i = 0; i < n; ++i)
workers.emplace_back([=]{
if(on_enter)
on_enter();
while(true)
{
for(auto& worker : workers)
try
{
worker.join();
}
catch(std::system_error&)
{}
有给这个workers指定大小n,但是在函数体里面却是emplace_back
,这样的话:
worker.join()
可能会segmentation fault
注意:gcc4.8.x特指gcc4.8.2,其它gcc4.8.x未测试
这两个问题目测都是gcc4.8.x的bug, 并没有针对其修改shttpd代码的计划,若因为客观原因必须使用gcc4.8.x者可以参考以上
至于clang3.4.x(特指clang3.4.2)...暂不提供解决方案。原因:
使用-std=c++1y选项编译下面代码:
int
main(int argc, char *argv[])
{
}
出现编译错误“/usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/cstdio:120:11: error: no member named 'gets' in the global namespace“
tcmalloc无此现象
原因:存在未释放的connection(异步操作正在进行)
修复方案:
1.在server.cc的do_wait_stop函数中添加退出整个程序的调用,比如exit(0)
2.实现一个Connection Manager,并在do_wait_stop中调用之让所有的connection上的异步操作取消
tcmalloc无此现象
https://github.com/lucklove/shttpd/blob/master/src/client.cc#L36
user:pass 真是亮瞎狗眼。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.