};
void
-FwdState::abort(void* d)
+FwdState::HandleStoreAbort(FwdState *fwd)
{
- FwdState* fwd = (FwdState*)d;
Pointer tmp = fwd; // Grab a temporary pointer to keep the object alive during our scope.
if (Comm::IsConnOpen(fwd->serverConnection())) {
// Ftp::Relay needs to preserve control connection on data aborts
// so it registers its own abort handler that calls ours when needed.
- if (!request->flags.ftpNative)
- entry->registerAbort(FwdState::abort, this);
+ if (!request->flags.ftpNative) {
+ AsyncCall::Pointer call = asyncCall(17, 4, "FwdState::Abort", cbdataDialer(&FwdState::HandleStoreAbort, this));
+ entry->registerAbortCallback(call);
+ }
// just in case; should already be initialized to false
request->flags.pinned = false;
delete err;
- entry->unregisterAbort();
+ entry->unregisterAbortCallback("FwdState object destructed");
entry->unlock("FwdState");
HttpRequest *request;
AccessLogEntryPointer al; ///< info for the future access.log entry
- static void abort(void*);
+ /// called by Store if the entry is no longer usable
+ static void HandleStoreAbort(FwdState *);
private:
Pointer self;
#endif
typedef void STMCB (void *data, StoreIOBuffer wroteBuffer);
-typedef void STABH(void *);
class store_client;
class PeerSelector;
IRCB *ping_reply_callback;
PeerSelector *ircb_data = nullptr;
- struct abort_ {
- abort_() { callback = nullptr; }
- STABH *callback;
- void *data = nullptr;
- } abort;
+ /// used for notifying StoreEntry writers about 3rd-party initiated aborts
+ AsyncCall::Pointer abortCallback;
RemovalPolicyNode repl;
int id = 0;
int64_t object_sz = -1;
void dump(int debug_lvl) const;
void hashDelete();
void hashInsert(const cache_key *);
- void registerAbort(STABH * cb, void *);
+ /// notify the StoreEntry writer of a 3rd-party initiated StoreEntry abort
+ void registerAbortCallback(const AsyncCall::Pointer &);
void reset();
void setMemStatus(mem_status_t);
bool timestampsSet();
- void unregisterAbort();
+ /// Avoid notifying anybody about a 3rd-party initiated StoreEntry abort.
+ /// Calling this method does not cancel the already queued notification.
+ /// TODO: Refactor to represent the end of (shared) ownership by our writer.
+ void unregisterAbortCallback(const char *reason);
void destroyMemObject();
int checkTooSmall();
#include "squid.h"
#include "anyp/PortCfg.h"
+#include "base/AsyncCbdataCalls.h"
#include "client_side.h"
#include "clients/forward.h"
#include "clients/FtpClient.h"
/// Inform Ftp::Server that we are done if originWaitInProgress
void stopOriginWait(int code);
-
- static void abort(void *d); // TODO: Capitalize this and FwdState::abort().
+ /// called by Store if the entry is no longer usable
+ static void HandleStoreAbort(Relay *);
bool forwardingCompleted; ///< completeForwarding() has been called
// Nothing we can do at request creation time can mark the response as
// uncachable, unfortunately. This prevents "found KEY_PRIVATE" WARNINGs.
entry->releaseRequest();
- // TODO: Convert registerAbort() to use AsyncCall
- entry->registerAbort(Ftp::Relay::abort, this);
+ AsyncCall::Pointer call = asyncCall(9, 4, "Ftp::Relay::Abort", cbdataDialer(&Relay::HandleStoreAbort, this));
+ entry->registerAbortCallback(call);
}
Ftp::Relay::~Relay()
{
+ entry->unregisterAbortCallback("Ftp::Relay object destructed");
+ // Client, our parent, calls entry->unlock().
+ // Client does not currently un/registerAbortCallback() because
+ // FwdState does that for other Client kids; \see FwdState::start().
+
closeServer(); // TODO: move to clients/Client.cc?
if (savedReply.message)
wordlistDestroy(&savedReply.message);
}
void
-Ftp::Relay::abort(void *d)
+Ftp::Relay::HandleStoreAbort(Relay *ftpClient)
{
- Ftp::Relay *ftpClient = (Ftp::Relay *)d;
debugs(9, 2, "Client Data connection closed!");
- if (!cbdataReferenceValid(ftpClient))
- return;
if (Comm::IsConnOpen(ftpClient->data.conn))
ftpClient->dataComplete();
}
/* DEBUG: section 16 Cache Manager API */
#include "squid.h"
+#include "base/AsyncCbdataCalls.h"
#include "base/TextException.h"
#include "comm/Connection.h"
#include "comm/Write.h"
debugs(16, 6, HERE);
Must(Comm::IsConnOpen(clientConnection));
Must(entry != NULL);
- entry->registerAbort(&StoreToCommWriter::Abort, this);
+ AsyncCall::Pointer call = asyncCall(16, 4, "StoreToCommWriter::Abort", cbdataDialer(&StoreToCommWriter::HandleStoreAbort, this));
+ entry->registerAbortCallback(call);
sc = storeClientListAdd(entry, this);
Must(sc != NULL);
storeUnregister(sc, entry, this);
sc = NULL;
}
- entry->unregisterAbort();
+ entry->unregisterAbortCallback("StoreToCommWriter done");
entry->unlock("Mgr::StoreToCommWriter::swanSong");
entry = NULL;
}
}
void
-Mgr::StoreToCommWriter::Abort(void* param)
+Mgr::StoreToCommWriter::HandleStoreAbort(StoreToCommWriter *mgrWriter)
{
- StoreToCommWriter* mgrWriter = static_cast<StoreToCommWriter*>(param);
if (Comm::IsConnOpen(mgrWriter->clientConnection))
mgrWriter->clientConnection->close();
}
void noteStoreCopied(StoreIOBuffer ioBuf);
static void NoteStoreCopied(void* data, StoreIOBuffer ioBuf);
/// called by Store if the entry is no longer usable
- static void Abort(void* param);
+ static void HandleStoreAbort(StoreToCommWriter *param);
/// tell Comm to write action results
void scheduleCommWrite(const StoreIOBuffer& ioBuf);
/* DEBUG: section 20 Storage Manager */
#include "squid.h"
+#include "base/AsyncCbdataCalls.h"
#include "base/TextException.h"
#include "CacheDigest.h"
#include "CacheManager.h"
/* Notify the server side */
- /*
- * DPW 2007-05-07
- * Should we check abort.data for validity?
- */
- if (mem_obj->abort.callback) {
- if (!cbdataReferenceValid(mem_obj->abort.data))
- debugs(20, DBG_IMPORTANT,HERE << "queueing event when abort.data is not valid");
- eventAdd("mem_obj->abort.callback",
- mem_obj->abort.callback,
- mem_obj->abort.data,
- 0.0,
- true);
- unregisterAbort();
+ if (mem_obj->abortCallback) {
+ ScheduleCallHere(mem_obj->abortCallback);
+ mem_obj->abortCallback = nullptr;
}
/* XXX Should we reverse these two, so that there is no
}
void
-StoreEntry::registerAbort(STABH * cb, void *data)
+StoreEntry::registerAbortCallback(const AsyncCall::Pointer &handler)
{
assert(mem_obj);
- assert(mem_obj->abort.callback == NULL);
- mem_obj->abort.callback = cb;
- mem_obj->abort.data = cbdataReference(data);
+ assert(!mem_obj->abortCallback);
+ mem_obj->abortCallback = handler;
}
void
-StoreEntry::unregisterAbort()
+StoreEntry::unregisterAbortCallback(const char *reason)
{
assert(mem_obj);
- if (mem_obj->abort.callback) {
- mem_obj->abort.callback = NULL;
- cbdataReferenceDone(mem_obj->abort.data);
+ if (mem_obj->abortCallback) {
+ mem_obj->abortCallback->cancel(reason);
+ mem_obj->abortCallback = nullptr;
}
}
void Mgr::StoreToCommWriter::scheduleStoreCopy() STUB
void Mgr::StoreToCommWriter::noteStoreCopied(StoreIOBuffer ioBuf) STUB
void Mgr::StoreToCommWriter::NoteStoreCopied(void* data, StoreIOBuffer ioBuf) STUB
-void Mgr::StoreToCommWriter::Abort(void* param) STUB
+void Mgr::StoreToCommWriter::HandleStoreAbort(StoreToCommWriter *) STUB
void Mgr::StoreToCommWriter::scheduleCommWrite(const StoreIOBuffer& ioBuf) STUB
void Mgr::StoreToCommWriter::noteCommWrote(const CommIoCbParams& params) STUB
void Mgr::StoreToCommWriter::noteCommClosed(const CommCloseCbParams& params) STUB
void StoreEntry::dump(int debug_lvl) const STUB
void StoreEntry::hashDelete() STUB
void StoreEntry::hashInsert(const cache_key *) STUB
-void StoreEntry::registerAbort(STABH * cb, void *) STUB
+void StoreEntry::registerAbortCallback(const AsyncCall::Pointer &) STUB
void StoreEntry::reset() STUB
void StoreEntry::setMemStatus(mem_status_t) STUB
bool StoreEntry::timestampsSet() STUB_RETVAL(false)
-void StoreEntry::unregisterAbort() STUB
+void StoreEntry::unregisterAbortCallback(const char *) STUB
void StoreEntry::destroyMemObject() STUB
int StoreEntry::checkTooSmall() STUB_RETVAL(0)
void StoreEntry::delayAwareRead(const Comm::ConnectionPointer&, char *buf, int len, AsyncCall::Pointer callback) STUB