{
public:
- Connection() : len (0), buf(), size_ptr(NULL) { buf.init(SQUID_TCP_SO_RCVBUF,SQUID_TCP_SO_RCVBUF); }
- ~Connection() {};
+ Connection() : len (0), buf ((char *)xmalloc(SQUID_TCP_SO_RCVBUF)), size_ptr(NULL) {}
- int bytesWanted() const;
+ ~Connection();
+
+ int bytesWanted(int lower=0, int upper = INT_MAX) const;
void bytesIn(int const &);
#if USE_DELAY_POOLS
void error(int const xerrno);
int debugLevelForError(int const xerrno) const;
void closeIfOpen();
- void dataSent(size_t amount);
+ void dataSent (size_t amount);
int len;
- MemBuf buf;
+ char *buf;
int64_t *size_ptr; /* pointer to size in an ConnStateData for logging */
Comm::ConnectionPointer conn; ///< The currently connected connection.
private:
CBDATA_CLASS(TunnelStateData);
- void copy(size_t len, comm_err_t errcode, int xerrno, Connection &from, Connection &to, AsyncCall::Pointer &);
+ void copy (size_t len, comm_err_t errcode, int xerrno, Connection &from, Connection &to, IOCB *);
void readServer(char *buf, size_t len, comm_err_t errcode, int xerrno);
void readClient(char *buf, size_t len, comm_err_t errcode, int xerrno);
void writeClientDone(char *buf, size_t len, comm_err_t flag, int xerrno);
delete tunnelState;
}
+TunnelStateData::Connection::~Connection()
+{
+ safe_free(buf);
+}
+
int
-TunnelStateData::Connection::bytesWanted() const
+TunnelStateData::Connection::bytesWanted(int lowerbound, int upperbound) const
{
#if USE_DELAY_POOLS
- return delayId.bytesWanted(1, buf.spaceSize());
+ return delayId.bytesWanted(lowerbound, upperbound);
#else
- return buf.spaceSize();
+
+ return upperbound;
#endif
}
kb_incr(&statCounter.server.other.kbytes_in, len);
}
- AsyncCall::Pointer call = commCbCall(5,5, "TunnelStateData::WriteClientDone",
- CommIoCbPtrFun(WriteClientDone, this));
-
- copy (len, errcode, xerrno, server, client, call);
+ copy (len, errcode, xerrno, server, client, WriteClientDone);
}
void
kb_incr(&statCounter.client_http.kbytes_in, len);
}
- AsyncCall::Pointer call = commCbCall(5,5, "TunnelStateData::WriteServerDone",
- CommIoCbPtrFun(WriteServerDone, this));
-
- copy (len, errcode, xerrno, client, server, call);
+ copy (len, errcode, xerrno, client, server, WriteServerDone);
}
void
-TunnelStateData::copy(size_t len, comm_err_t errcode, int xerrno, Connection &from, Connection &to, AsyncCall::Pointer &call)
+TunnelStateData::copy (size_t len, comm_err_t errcode, int xerrno, Connection &from, Connection &to, IOCB *completion)
{
debugs(26, 3, HERE << "from={" << from.conn << "}, to={" << to.conn << "}");
}
} else if (cbdataReferenceValid(this)) {
debugs(26, 3, HERE << "Schedule Write");
- Comm::Write(to.conn, &from.buf, call);
+ AsyncCall::Pointer call = commCbCall(5,5, "TunnelBlindCopyWriteHandler",
+ CommIoCbPtrFun(completion, this));
+ Comm::Write(to.conn, from.buf, len, call, NULL);
}
cbdataInternalUnlock(this); /* ??? */
assert(from.len == 0);
AsyncCall::Pointer call = commCbCall(5,4, "TunnelBlindCopyReadHandler",
CommIoCbPtrFun(completion, this));
- comm_read(from.conn, from.buf.space(), from.bytesWanted(), call);
+ comm_read(from.conn, from.buf, from.bytesWanted(1, SQUID_TCP_SO_RCVBUF), call);
}
/**