Hi all
As a follow up to the thread safety "thread" I would like to request a
cancel operation as a thread "semi safe" operation.
I use the following cancel operation (PostgreSQL only). I have no idea if
this or something similar will work for other backends ?
Also I have no firm knowledge that the implementation is correct, but it
does seem to work when called from another thread. Notice the
soci::session object must exist and be valid for the duration of the call.
But no ongoing SQL operation is required.
void cancel( soci::session & _session )
{
details::session_backend *p = _session.get_backend();
// using dynamic_cast instead of static_cast to allow conversion to
other backends.
postgresql_session_backend *pp =
dynamic_cast<postgresql_session_backend*>(p);
if (pp)
{
PGcancel *pgc = PQgetCancel( pp->conn_ );
if ( pgc )
{
char buffer[257];
memset(buffer,0,257);
int result = PQcancel( pgc, buffer, 256 );
PQfreeCancel(pgc);
if ( result ) {}
}
}
}
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users