mordor icon indicating copy to clipboard operation
mordor copied to clipboard

calling Mordor::BaseRequestBroker::request with a bodyDg provided from a native thread segfaults

Open jtolio opened this issue 12 years ago • 3 comments

request() assumes it is being called from a fiber, which is not necessarily the case.

    Future<> future;
    boost::exception_ptr exception;
    bool exceptionWasHttp = false;
    if (bodyDg)
        Scheduler::getThis()->schedule(boost::bind(&doBody,
            request, bodyDg, boost::ref(future), boost::ref(exception),
            boost::ref(exceptionWasHttp)));

the last line segfaults, since getThis() returns NULL

jtolio avatar Jul 07 '12 00:07 jtolio

Are you ok with non-simultaneous reading and writing of the request and response? In practice this means a server that sends an error response and then hangs up before reading the full request would cause your client to only receive the write error, and not the actual response.

On Jul 6, 2012, at 6:40 PM, JT [email protected] wrote:

request() assumes it is being called from a fiber, which is not necessarily the case.

   Future<> future;
   boost::exception_ptr exception;
   bool exceptionWasHttp = false;
   if (bodyDg)
       Scheduler::getThis()->schedule(boost::bind(&doBody,
           request, bodyDg, boost::ref(future), boost::ref(exception),
           boost::ref(exceptionWasHttp)));

the last line segfaults, since getThis() returns NULL


Reply to this email directly or view it on GitHub: https://github.com/ccutrer/mordor/issues/14

ccutrer avatar Jul 07 '12 01:07 ccutrer

That sounds like an appropriate tradeoff. That's obviously lighter weight than doing something like spinning up a throwaway thread for doing them synchronously and covers almost all of the use cases. If you want something else set up a scheduler.

Yeah I'm cool with that.

jtolio avatar Jul 07 '12 03:07 jtolio

hmm, how hard would it be to get the network/http library tests running both with a scheduler and with no scheduler? i fixed this issue only to find a few more places where an iomanager is assumed (Socket::cancelIo for example)

jtolio avatar Jul 08 '12 18:07 jtolio