fixup AsWritePvt to be non-copyable
Avoids double free via asTrapWriteAfterWrite() with c++98
This commit is contained in:
@ -74,13 +74,20 @@ struct QSRV_API PDBProvider : public epics::pvAccess::ChannelProvider,
|
||||
QSRV_API
|
||||
void QSRVRegistrar_counters();
|
||||
|
||||
class QSRV_API AsWritePvt {
|
||||
class AsWritePvt {
|
||||
void * pvt;
|
||||
public:
|
||||
AsWritePvt() :pvt(NULL) {}
|
||||
explicit AsWritePvt(void * pvt): pvt(pvt) {}
|
||||
~AsWritePvt() {
|
||||
asTrapWriteAfterWrite(pvt);
|
||||
}
|
||||
void swap(AsWritePvt& o) {
|
||||
std::swap(pvt, o.pvt);
|
||||
}
|
||||
private:
|
||||
AsWritePvt(const AsWritePvt&);
|
||||
AsWritePvt& operator=(const AsWritePvt&);
|
||||
};
|
||||
|
||||
#endif // PDB_H
|
||||
|
@ -350,22 +350,23 @@ void PDBGroupPut::put(pvd::PVStructure::shared_pointer const & value,
|
||||
// assume value may be a different struct each time... lot of wasted prep work
|
||||
const size_t npvs = channel->pv->members.size();
|
||||
std::vector<std::tr1::shared_ptr<PVIF> > putpvif(npvs);
|
||||
std::vector<AsWritePvt> asWritePvt;
|
||||
pvd::shared_vector<AsWritePvt> asWritePvt(npvs);
|
||||
|
||||
for(size_t i=0; i<npvs; i++)
|
||||
{
|
||||
PDBGroupPV::Info& info = channel->pv->members[i];
|
||||
|
||||
asWritePvt.push_back(AsWritePvt(
|
||||
asTrapWriteWithData(channel->aspvt.at(i).aspvt,
|
||||
std::string(channel->cred.user.begin(), channel->cred.user.end()).c_str(),
|
||||
std::string(channel->cred.host.begin(), channel->cred.host.end()).c_str(),
|
||||
info.chan,
|
||||
AsWritePvt wrt(asTrapWriteWithData(
|
||||
channel->aspvt.at(i).aspvt,
|
||||
&channel->cred.user[0],
|
||||
&channel->cred.host[0],
|
||||
info.chan.chan,
|
||||
info.chan->final_type,
|
||||
info.chan->final_no_elements,
|
||||
NULL
|
||||
)
|
||||
));
|
||||
);
|
||||
asWritePvt[i].swap(wrt);
|
||||
|
||||
if(!info.allowProc) continue;
|
||||
putpvif[i].reset(info.builder->attach(value, info.attachment));
|
||||
|
Reference in New Issue
Block a user