Hi, all
there a thread safe problem to scope variable:
for example:
<%session
int a
/%session>
allocate a integer, and put it in session scope, but when a request is
touching it, another thread would delete it, and free the momery, so
cause Segmentfault.
modified version define a SmartPtr to hold the reference, to avoid it to
be recovery.
lin
Index: ecpp.h
===================================================================
--- ecpp.h (revision 1095)
+++ ecpp.h (working copy)
@@ -230,23 +230,21 @@
}
#define TNT_VAR(scope, type, varname, key, construct) \
- type* varname##_pointer; \
+ tnt::Scope::pointer_type varname##_ptr; #SmartPtr to hold reference \
{ \
const std::string varname##_scopekey = key; \
tnt::Scope& _scope = scope; \
- tnt::Scope::pointer_type _ptr = _scope.get(varname##_scopekey); \
- if (_ptr.getPointer()) \
- varname##_pointer = static_cast<tnt::PointerObject< type >*>( \
- _ptr.getPointer())->get(); \
- else \
+ varname##_ptr = _scope.get(varname##_scopekey); \
+ if (!varname##_ptr.getPointer()) \
{ \
tnt::PointerObject< type >* _poptr = new tnt::PointerObject< type >(); \
- _ptr = _poptr; \
- _poptr->set(varname##_pointer = new type construct); \
- _scope.put(varname##_scopekey, _ptr); \
+ varname##_ptr = _poptr; \
+ _poptr->set(new type construct); \
+ _scope.put(varname##_scopekey, varname##_ptr); \
} \
} \
- type& varname = *varname##_pointer;
+ type& varname = *static_cast<tnt::PointerObject< type >*>( \
+ varname##_ptr.getPointer())->get();
#define TNT_SESSION_COMPONENT_VAR(type, varname, key, construct) \
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general