You should always design your server to be multithreaded. It should not
fork processes. Forking is too expensive.
In your multithreaded server, you should also employ a Connection Manager.
When each thread wants to connect, the thread should ask the global
Connection Manager to hand it an available connection. The connection
manager creates a connection if it needs to, or hands an open-unused
connection to the thread. The thread uses it, then releases it back to the
connection manager. This is how it must be done or else your application
will be too slow to be practical. Forking processes is too expensive, and
opening a connection for each request is also too expensive an operation.
Also, FYI, Windows' equivalent of fork() is CreateProcess().
To see the proper coding of a connection manager and underlying Sybase
connections, see the "Documents->API" link at http://www.dbpowersuite.com.
Brian
http://www.dbpowersuite.com
"captain biceps" <spe (AT) x-media (DOT) fr> wrote
Quote:
Hi,
I have to use an sybase driver into a C program.
It's a little serveur which wait incoming connection then fork each client
and create a db connection.
classic...
But now, I must develop under Linux AND Windows, and -of course- win32
doesn't support fork()
So, Thread seems to be a cool solution...
but -it was to easy - the version of sybase isn't thread-safe.
So I was thinking...
In my thread function, If I load dynamically all the .so to instance
them...
eg:
// each thread for each client
fct_threaded(void *...)
{
hdl = dlopen( db_syb.so... );
ptr1 = dlsym(hdl, ....);
ptr2 = dlsym(hdl, ...);
//
ptr1(...)
etc...
}
Do you think it's a good solution ?
Better idea ?
thanx guys... |