if (reading())
return;
- reading(true);
-
debugs(33, 4, "clientReadSomeData: FD " << fd << ": reading request...");
makeSpaceAvailable();
typedef CommCbMemFunT<ConnStateData, CommIoCbParams> Dialer;
- AsyncCall::Pointer call = asyncCall(33, 5, "ConnStateData::clientReadRequest",
- Dialer(this, &ConnStateData::clientReadRequest));
- comm_read(fd, in.addressToReadInto(), getAvailableBufferLength(), call);
+ reader = asyncCall(33, 5, "ConnStateData::clientReadRequest",
+ Dialer(this, &ConnStateData::clientReadRequest));
+ comm_read(fd, in.addressToReadInto(), getAvailableBufferLength(), reader);
}
ConnStateData::clientReadRequest(const CommIoCbParams &io)
{
debugs(33,5,HERE << "clientReadRequest FD " << io.fd << " size " << io.size);
- reading(false);
+ Must(reading());
+ reader = NULL;
bool do_next_read = 1; /* the default _is_ to read data! - adrian */
assert (io.fd == fd);
CBDATA_CLASS_INIT(ConnStateData);
-ConnStateData::ConnStateData() :AsyncJob("ConnStateData"), transparent_ (false), reading_ (false), closing_ (false)
+ConnStateData::ConnStateData() :AsyncJob("ConnStateData"), transparent_ (false), closing_ (false)
{
pinning.fd = -1;
pinning.pinned = false;
bool
ConnStateData::reading() const
{
- return reading_;
+ return reader != NULL;
}
void
-ConnStateData::reading(bool const newBool)
+ConnStateData::stopReading()
{
- assert (reading() != newBool);
- reading_ = newBool;
+ if (reading()) {
+ comm_read_cancel(fd, reader);
+ reader = NULL;
+ }
}
bool transparent() const;
void transparent(bool const);
bool reading() const;
- void reading(bool const);
+ void stopReading(); ///< cancels comm_read if it is scheduled
bool closing() const;
void startClosing(const char *reason);
private:
CBDATA_CLASS2(ConnStateData);
bool transparent_;
- bool reading_;
bool closing_;
bool switchedToHttps_;
+ AsyncCall::Pointer reader; ///< set when we are reading
BodyPipe::Pointer bodyPipe; // set when we are reading request body
};
NULL,
tunnelPeerSelectComplete,
tunnelState);
- /*
- * Disable the client read handler until peer selection is complete
- * Take control away from client_side.c.
- */
- commSetSelect(tunnelState->client.fd(), COMM_SELECT_READ, NULL, NULL, 0);
}
static void