-#include "config.h"
+#include "squid.h"
#include "ClientInfo.h"
+#include "comm/Connection.h"
#include "comm/IoCallback.h"
#include "comm/Loops.h"
#include "comm/Write.h"
#include "CommCalls.h"
#include "fde.h"
+#include "globals.h"
Comm::CbEntry *Comm::iocb_table;
{
// XXX: convert this to a std::map<> ?
iocb_table = static_cast<CbEntry*>(xcalloc(Squid_MaxFD, sizeof(CbEntry)));
- for (int pos = 0; pos < Squid_MaxFD; pos++) {
+ for (int pos = 0; pos < Squid_MaxFD; ++pos) {
iocb_table[pos].fd = pos;
- iocb_table[pos].readcb.fd = pos;
iocb_table[pos].readcb.type = IOCB_READ;
- iocb_table[pos].writecb.fd = pos;
iocb_table[pos].writecb.type = IOCB_WRITE;
}
}
void
Comm::CallbackTableDestruct()
{
+ // release any Comm::Connections being held.
+ for (int pos = 0; pos < Squid_MaxFD; ++pos) {
+ iocb_table[pos].readcb.conn = NULL;
+ iocb_table[pos].writecb.conn = NULL;
+ }
safe_free(iocb_table);
}
{
#if USE_DELAY_POOLS
// stand in line if there is one
- if (ClientInfo *clientInfo = fd_table[fd].clientInfo) {
+ if (ClientInfo *clientInfo = fd_table[conn->fd].clientInfo) {
if (clientInfo->writeLimitingActive) {
- quotaQueueReserv = clientInfo->quotaEnqueue(fd);
+ quotaQueueReserv = clientInfo->quotaEnqueue(conn->fd);
clientInfo->kickQuotaQueue();
return;
}
}
#endif
- SetSelect(fd, COMM_SELECT_WRITE, Comm::HandleWrite, this, 0);
+ SetSelect(conn->fd, COMM_SELECT_WRITE, Comm::HandleWrite, this, 0);
}
void
void
Comm::IoCallback::reset()
{
+ conn = NULL;
if (freefunc) {
freefunc(buf);
buf = NULL;
void
Comm::IoCallback::finish(comm_err_t code, int xerrn)
{
- debugs(5, 3, HERE << "called for FD " << fd << " (" << code << ", " << xerrno << ")");
+ debugs(5, 3, HERE << "called for " << conn << " (" << code << ", " << xerrno << ")");
assert(active());
/* free data */
if (callback != NULL) {
typedef CommIoCbParams Params;
Params ¶ms = GetCommParams<Params>(callback);
- params.fd = fd;
+ if (conn != NULL) params.fd = conn->fd; // for legacy write handlers...
+ params.conn = conn;
params.buf = buf;
params.size = offset;
params.flag = code;