/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "squid.h"
#include "client_side_request.h"
#include "clientStream.h"
+#include "http/Stream.h"
#include "HttpReply.h"
#include "HttpRequest.h"
\par
* Each node including the HEAD of the clientStream has a cbdataReference
* held by the stream. Freeing the stream then removes that reference
- * and cbdataFree()'s every node.
+ * and delete's every node.
* Any node with other References, and all nodes downstream will only
* free when those references are released.
* Stream nodes MAY hold references to the data member of the node.
\code
mycontext = thisObject->data;
thisObject->data = NULL;
- clientStreamFree (thisObject->head);
+ delete thisObject->head;
mycontext = NULL;
return;
\endcode
\todo rather than each node undeleting the next, have a clientStreamDelete that walks the list.
*/
-/// \ingroup ClientStreamInternal
-CBDATA_TYPE(clientStreamNode);
+CBDATA_CLASS_INIT(clientStreamNode);
-/* Local functions */
-static FREE clientStreamFree;
+clientStreamNode::clientStreamNode(CSR * aReadfunc, CSCB * aCallback, CSD * aDetach, CSS * aStatus, ClientStreamData aData) :
+ head(NULL),
+ readfunc(aReadfunc),
+ callback(aCallback),
+ detach(aDetach),
+ status(aStatus),
+ data(aData)
+{}
-/// \ingroup ClientStreamInternal
-clientStreamNode *
-clientStreamNew(CSR * readfunc, CSCB * callback, CSD * detach, CSS * status,
- ClientStreamData data)
+clientStreamNode::~clientStreamNode()
{
- clientStreamNode *temp;
- CBDATA_INIT_TYPE_FREECB(clientStreamNode, clientStreamFree);
- temp = cbdataAlloc(clientStreamNode);
- temp->readfunc = readfunc;
- temp->callback = callback;
- temp->detach = detach;
- temp->status = status;
- temp->data = data;
- return temp;
+ debugs(87, 3, "Freeing clientStreamNode " << this);
+
+ removeFromStream();
+ data = NULL;
}
/**
ClientStreamData readdata, CSCB * callback, CSD * cdetach, ClientStreamData callbackdata,
StoreIOBuffer tailBuffer)
{
- clientStreamNode *temp = clientStreamNew(func, NULL, rdetach, readstatus,
- readdata);
+ clientStreamNode *temp = new clientStreamNode(func, NULL, rdetach, readstatus, readdata);
dlinkAdd(cbdataReference(temp), &temp->node, list);
temp->head = list;
clientStreamInsertHead(list, NULL, callback, cdetach, NULL, callbackdata);
clientStreamInsertHead(dlink_list * list, CSR * func, CSCB * callback,
CSD * detach, CSS * status, ClientStreamData data)
{
-
/* test preconditions */
assert(list != NULL);
assert(list->head);
- clientStreamNode *temp = clientStreamNew(func, callback, detach, status, data);
+ clientStreamNode *temp = new clientStreamNode(func, callback, detach, status, data);
temp->head = list;
debugs(87, 3, "clientStreamInsertHead: Inserted node " << temp <<
" with data " << data.getRaw() << " after head");
cbdataReferenceDone(temp);
- cbdataFree(thisObject);
+ delete thisObject;
- /* and tell the prev that the detach has occured */
+ /* and tell the prev that the detach has occurred */
/*
* We do it in thisObject order so that the detaching node is always
* at the end of the list
return prev->status(prev, http);
}
-/* Local function bodies */
-
void
clientStreamNode::removeFromStream()
{
head = NULL;
}
-/// \ingroup ClientStreamInternal
-void
-clientStreamFree(void *foo)
-{
- clientStreamNode *thisObject = (clientStreamNode *)foo;
-
- debugs(87, 3, "Freeing clientStreamNode " << thisObject);
-
- thisObject->removeFromStream();
- thisObject->data = NULL;
-}
-
clientStreamNode *
clientStreamNode::prev() const
{