GithubHelp home page GithubHelp logo

Comments (6)

akinggw avatar akinggw commented on June 29, 2024

经测试,QFuture 不起作用,现修改成如下:
volatile int m_isSafeExit;

增加一个函数:
void JQHttpServer::Session::waitWorkingForFinished()
{
while(m_isSafeExit == 2)
{
QApplication::processEvents(QEventLoop::AllEvents, 200);
}
m_isSafeExit = 3;
}

void JQHttpServer::AbstractManage::handleAccepted(const QPointer< Session > &session)
{
if(session->m_isSafeExit == 3) return;

QtConcurrent::run( handleThreadPool_.data(), [ this, session]() {
    //emit onRedReady(session);

    if ( !this->httpAcceptedCallback_ ||
         session == NULL)
    {
        qDebug() << "JQHttpServer::Manage::handleAccepted: error, httpAcceptedCallback_ is nullptr";
        return;
    }

    session->m_isSafeExit = 2;
    this->httpAcceptedCallback_( session , this->getMainObject());
    session->m_isSafeExit = 1;
} );

}

经测试,系统已经不在崩溃,但连接多了以后,会出现主动关闭的情况

from jqhttpserver.

188080501 avatar 188080501 commented on June 29, 2024

连接多了是多到多少,目前Qt select模型下并发能力有限,短时间内超过1000个请求就可能会漏

from jqhttpserver.

akinggw avatar akinggw commented on June 29, 2024

就一个连接,每秒发送一次请求,服务器就会崩溃

from jqhttpserver.

188080501 avatar 188080501 commented on June 29, 2024

不修改源码的话,也会崩溃吗?

from jqhttpserver.

akinggw avatar akinggw commented on June 29, 2024

不修改源码的话就会崩溃,修改后,经过测试,就不崩溃了,但存在偶尔服务器拒绝服务,直接关闭连接

from jqhttpserver.

188080501 avatar 188080501 commented on June 29, 2024

感谢反馈
因为session会在多线程使用,所以可能发生session被先删除的问题。因为我这里使用场景,session会被继续跨线程传递,因此没有做wait等待处理完成。而是使用智能指针做了null判断。但是这个判断不是100%稳妥

from jqhttpserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.