{
}
+bool
+CommConnectCbParams::syncWithComm()
+{
+ // drop the call if the call was scheduled before comm_close but
+ // is being fired after comm_close
+ if (fd >= 0 && fd_table[fd].closing()) {
+ debugs(5, 3, HERE << "droppin late connect call: FD " << fd);
+ return false;
+ }
+ return true; // now we are in sync and can handle the call
+}
/* CommIoCbParams */
{
}
-void
+bool
CommIoCbParams::syncWithComm()
{
// change parameters if the call was scheduled before comm_close but
flag = COMM_ERR_CLOSING;
size = 0;
}
+ return true; // now we are in sync and can handle the call
}
CommCommonCbParams(const CommCommonCbParams ¶ms);
~CommCommonCbParams();
- /// last chance to adjust based on the current Comm state
- void syncWithComm() {} // not virtual because fire() knows dialer type
+ /// adjust using the current Comm state; returns false to cancel the call
+ // not virtual because callers know dialer type
+ bool syncWithComm() { return true; }
void print(std::ostream &os) const;
class CommConnectCbParams: public CommCommonCbParams {
public:
CommConnectCbParams(void *aData);
+
+ bool syncWithComm(); // see CommCommonCbParams::syncWithComm
};
// read/write (I/O) parameters
CommIoCbParams(void *aData);
void print(std::ostream &os) const;
- void syncWithComm();
+ bool syncWithComm(); // see CommCommonCbParams::syncWithComm
public:
char *buf;
CommCbMemFunT(C *obj, Method meth): JobDialer(obj),
CommDialerParamsT<Params>(obj), object(obj), method(meth) {}
+ virtual bool canDial(AsyncCall &c) { return JobDialer::canDial(c) &&
+ this->params.syncWithComm(); }
+
virtual void print(std::ostream &os) const {
os << '('; this->params.print(os); os << ')'; }
Method method;
protected:
- virtual void doDial() { this->params.syncWithComm(); (object->*method)(this->params); }
+ virtual void doDial() { (object->*method)(this->params); }
};
if (!cbdataReferenceValid(dialer.params.data))
return cancel("callee gone");
+ if (!dialer.params.syncWithComm())
+ return cancel("out of sync w/comm");
+
return true;
}
void
CommCbFunPtrCallT<Dialer>::fire()
{
- dialer.params.syncWithComm();
dialer.dial();
}