On 05/16/11 20:33, Vlad Khorsun wrote: >> Could you explain, please, semantics of addRef/release on public >> provider interfaces? >> >> The issue was discussed on this list with two possibilities: >> - when refCount = 1, release does things like detach, rollback, free, >> etc. It's what was implemented so far. >> - sometime mentioned also that detach/rollback/etc would not release, >> and user would need to explicit call it. >> >> But now Vlad says we can't call release when refCount = 1, and it's just >> there to decrement addRefs. >> >> This broke code I wrote based on discussed ideas, and I don't feel it's >> correct. >> >> (Also note Alex code in jrd.cpp and is clear he wrote code not using >> this new assumption.) > I assume there must be a kind of symmetry : attach\detach, startTx\commit, > startTx\rollback, allocateStmt\freeStmt, addRef\release. From semantic POV > attach\detach is like constructor\destructor pair while addRef\release should > be > used for additional references only (i.e. not instead of destructor). > > So, if code calls attach\release - this is bug, as for me, and i see no > reasons > to write code in this way intentionally. I consider at as very bad practice > as it > could lead to the inexpected side effects (such as implicit rollback).
Unfortunately release() is also a kind of dtor, and we can't report about an error that happened inside release(). Therefore the question is - what to do if one called release() for an object with refCount == 1? I assume that for us this is a kind of broken network connection, i.e. attachment is closed, transactions rolled back, etc. Bad style - but we must do something here... Certainly, nothing prevents us from adding error reporting to our release. Should we do it? ------------------------------------------------------------------------------ Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel