MTA with thread pool API

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi group,

I have a C/C++ multi-threaded socket server app that uses OLE DB for it's
SQL activity. The app uses a completion port for socket I/O, but doesn't
properly implement connection pooling with OLE DB. Each thread of the
process holds on to it's own IDBInitialize, which I know is wrong.

So I'm rewriting this app to maintain one IDataInitialize object, and create
the IDBInitialize objects on the fly, using the same connection string.
Hopefully, this won't add too much overhead, but it's what Microsoft says to
do for proper connection pooling.

Anyway, my question is related to CoInitializeEx(MTA) / CoUninitialize() in
regards to the thread pool API. I really like using this API -
QueueUserWorkItem(), BindIoCompletionCallback(),
RegisterWaitForSingleObject(), etc.

The problem is that Windows manages these threads, so I don't have the
opportunity to call CoInitializeEx / CoUninitialize. Using Thread Local
Storage, I can flag whether or not the thread has called CoInitializeEx, but
I still have no opportunity to call CoUninitialize.

Microsoft is very clear that you must call these functions once per thread
that uses COM. I thought about moving all the code into a DLL, and using
THREAD_ATTACH and THREAD_DETACH, but the SDK also says not to call the
CoInit functions from DLLMain().

Does this mean that I'm stuck with my own completion ports, or is there some
way that I can use the thread pool API?

I know this all sounds like a bunch of mumbo jumbo, so please ask and I'll
clarify any points above.

Thanks for your time.

--Sarge


.



Relevant Pages

  • MTA with Thread Pool API
    ... The app uses a completion port for socket I/O, ... technical article says to do for proper connection pooling. ... The SDK is very clear that you must call the CoInit functions once per ...
    (microsoft.public.win32.programmer.kernel)
  • Re: [JDBC] Connection pooling
    ... of course you should only use a tomcat when your app is a webapp. ... > Here are a few things I don't understand about connection pooling. ...
    (comp.lang.java.databases)
  • Re: MTA with Thread Pool API
    ... Microsoft technical article says to do for proper connection pooling. ... my question is related to CoInitializeEx/ CoUninitialize() ... Storage, I can flag whether or not the thread has called CoInitializeEx, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Primary Key with a datetime datatype
    ... Perhaps the app passes appropriate SET DATEFORMAT command, ... thinking things like connection pooling etc. ... I'd strongly suggest to the app vendor to use a "safe" format. ...
    (microsoft.public.sqlserver.server)
  • Re: Connection Pooling
    ... the app. ... Since all connections have to be killed anyway, ... > Part of the app is a 'Restore from Backup' form which uses SQLDMO code. ... > I'm starting to think it's to do with connection pooling because the open ...
    (microsoft.public.dotnet.framework.adonet)