#if USE_AUTH
auth_user_request = NULL;
#endif
- pinned_connection = NULL;
port = 0;
canonical = NULL;
memset(&flags, '\0', sizeof(flags));
range = NULL;
}
- if (pinned_connection)
- cbdataReferenceDone(pinned_connection);
-
myportname.clean();
tag.clean();
#if USE_AUTH
auth_user_request = aReq->auth_user_request;
#endif
- if (aReq->pinned_connection) {
- pinned_connection = cbdataReference(aReq->pinned_connection);
- }
+ clientConnectionManager = aReq->clientConnectionManager;
return true;
}
char host[SQUIDHOSTNAMELEN];
int host_is_numeric;
- /***
- * The client side connection data of pinned connections for the client side
- * request related objects
- */
- ConnStateData *pinned_connection;
-
#if USE_ADAPTATION
mutable Adaptation::History::Pointer adaptHistory_; ///< per-HTTP transaction info
#endif
static HttpRequest * CreateFromUrl(char * url);
- void setPinnedConnection(ConnStateData *conn) {
- pinned_connection = cbdataReference(conn);
- }
-
ConnStateData *pinnedConnection() {
- return pinned_connection;
+ if (clientConnectionManager.valid() && clientConnectionManager->pinning.pinned)
+ return clientConnectionManager.get();
+ return NULL;
}
- void releasePinnedConnection() {
- cbdataReferenceDone(pinned_connection);
- }
-
- /// client-side conn manager, if known; used for 1xx response forwarding
- CbcPointer<ConnStateData> clientConnection;
+ /**
+ * The client connection manager, if known;
+ * Used for any response actions needed directly to the client.
+ * ie 1xx forwarding or connection pinning state changes
+ */
+ CbcPointer<ConnStateData> clientConnectionManager;
int64_t getRangeOffsetLimit(); /* the result of this function gets cached in rangeOffsetLimit */
* connection has gone away */
}
-void ConnStateData::pinConnection(int pinning_fd, HttpRequest *request, struct peer *aPeer, bool auth)
+void
+ConnStateData::pinConnection(int pinning_fd, HttpRequest *request, struct peer *aPeer, bool auth)
{
fde *f;
char desc[FD_DESC_SZ];
}
-int ConnStateData::validatePinnedConnection(HttpRequest *request, const struct peer *aPeer)
+int
+ConnStateData::validatePinnedConnection(HttpRequest *request, const struct peer *aPeer)
{
bool valid = true;
if (pinning.fd < 0)
}
if (!valid) {
- int pinning_fd=pinning.fd;
- /* The pinning info is not safe, remove any pinning info*/
+ /* The pinning info is not safe, remove any pinning info */
unpinConnection();
-
- /* also close the server side socket, we should not use it for invalid/unauthenticated
- requests...
- */
- comm_close(pinning_fd);
- return -1;
}
return pinning.fd;
}
-void ConnStateData::unpinConnection()
+void
+ConnStateData::unpinConnection()
{
if (pinning.peer)
cbdataReferenceDone(pinning.peer);
comm_remove_close_handler(pinning.fd, pinning.closeHandler);
pinning.closeHandler = NULL;
}
+ /// also close the server side socket, we should not use it for any future requests...
+ comm_close(pinning.fd);
pinning.fd = -1;
safe_free(pinning.host);
}
http->storeEntry(entry);
assert(http->out.offset == 0);
- http->request->clientConnection = http->getConn();
+ http->request->clientConnectionManager = http->getConn();
/*
* A refcounted pointer so that FwdState stays around as long as
if (http->flags.internal)
r->protocol = AnyP::PROTO_INTERNAL;
- r->clientConnection = http->getConn();
+ r->clientConnectionManager = http->getConn();
/** Start forwarding to get the new object from network */
FwdState::fwdStart(http->getConn() != NULL ? http->getConn()->fd : -1,
} else {
request->flags.connection_proxy_auth = 1;
}
- request->setPinnedConnection(http_conn);
+ // These should already be linked correctly.
+ assert(request->clientConnectionManager == http_conn);
}
}
}
}
if (may_pin && !request->pinnedConnection()) {
- request->setPinnedConnection(http->getConn());
+ // These should already be linked correctly. Just need the ServerConnection to pinn.
+ assert(request->clientConnectionManager == http_conn);
}
}
}
assert(pinned_connection);
fd = pinned_connection->validatePinnedConnection(request, fs->_peer);
if (fd >= 0) {
- pinned_connection->unpinConnection();
#if 0
if (!fs->_peer)
fs->code = HIER_DIRECT;
return;
}
/* Failure. Fall back on next path */
- debugs(17,2,HERE << " Pinned connection " << pinned_connection << " not valid. Releasing.");
- request->releasePinnedConnection();
+ debugs(17,2,HERE << " Pinned connection " << pinned_connection << " not valid.");
servers = fs->next;
fwdServerFree(fs);
connectStart();
typedef NullaryMemFunT<HttpStateData> CbDialer;
const AsyncCall::Pointer cb = JobCallback(11, 3, CbDialer, this,
HttpStateData::proceedAfter1xx);
- CallJobHere1(11, 4, orig_request->clientConnection, ConnStateData,
+ CallJobHere1(11, 4, orig_request->clientConnectionManager, ConnStateData,
ConnStateData::sendControlMsg, HttpControlMsg(msg, cb));
// If the call is not fired, then the Sink is gone, and HttpStateData
// will terminate due to an aborted store entry or another similar error.