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
|
QSRV_API
|
||||||
void QSRVRegistrar_counters();
|
void QSRVRegistrar_counters();
|
||||||
|
|
||||||
class QSRV_API AsWritePvt {
|
class AsWritePvt {
|
||||||
void * pvt;
|
void * pvt;
|
||||||
public:
|
public:
|
||||||
|
AsWritePvt() :pvt(NULL) {}
|
||||||
explicit AsWritePvt(void * pvt): pvt(pvt) {}
|
explicit AsWritePvt(void * pvt): pvt(pvt) {}
|
||||||
~AsWritePvt() {
|
~AsWritePvt() {
|
||||||
asTrapWriteAfterWrite(pvt);
|
asTrapWriteAfterWrite(pvt);
|
||||||
}
|
}
|
||||||
|
void swap(AsWritePvt& o) {
|
||||||
|
std::swap(pvt, o.pvt);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
AsWritePvt(const AsWritePvt&);
|
||||||
|
AsWritePvt& operator=(const AsWritePvt&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PDB_H
|
#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
|
// assume value may be a different struct each time... lot of wasted prep work
|
||||||
const size_t npvs = channel->pv->members.size();
|
const size_t npvs = channel->pv->members.size();
|
||||||
std::vector<std::tr1::shared_ptr<PVIF> > putpvif(npvs);
|
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++)
|
for(size_t i=0; i<npvs; i++)
|
||||||
{
|
{
|
||||||
PDBGroupPV::Info& info = channel->pv->members[i];
|
PDBGroupPV::Info& info = channel->pv->members[i];
|
||||||
|
|
||||||
asWritePvt.push_back(AsWritePvt(
|
AsWritePvt wrt(asTrapWriteWithData(
|
||||||
asTrapWriteWithData(channel->aspvt.at(i).aspvt,
|
channel->aspvt.at(i).aspvt,
|
||||||
std::string(channel->cred.user.begin(), channel->cred.user.end()).c_str(),
|
&channel->cred.user[0],
|
||||||
std::string(channel->cred.host.begin(), channel->cred.host.end()).c_str(),
|
&channel->cred.host[0],
|
||||||
info.chan,
|
info.chan.chan,
|
||||||
info.chan->final_type,
|
info.chan->final_type,
|
||||||
info.chan->final_no_elements,
|
info.chan->final_no_elements,
|
||||||
NULL
|
NULL
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
|
asWritePvt[i].swap(wrt);
|
||||||
|
|
||||||
if(!info.allowProc) continue;
|
if(!info.allowProc) continue;
|
||||||
putpvif[i].reset(info.builder->attach(value, info.attachment));
|
putpvif[i].reset(info.builder->attach(value, info.attachment));
|
||||||
|
Reference in New Issue
Block a user