dbTalk Databases Forums  

syb thread

comp.databases.sybase comp.databases.sybase


Discuss syb thread in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
captain biceps
 
Posts: n/a

Default syb thread - 08-16-2004 , 02:21 PM






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...



Reply With Quote
  #2  
Old   
Brian Ceccarelli
 
Posts: n/a

Default Re: syb thread - 08-17-2004 , 07:32 PM






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...





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.