dbTalk Databases Forums  

MYSQL connection persistence through an execve() syscall

comp.databases.mysql comp.databases.mysql


Discuss MYSQL connection persistence through an execve() syscall in the comp.databases.mysql forum.



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

Default MYSQL connection persistence through an execve() syscall - 09-26-2006 , 04:34 PM






Hi everybody,
I migrate some C programs from a legacy isam to mysql. I can not change the
program logic,
because there are over than 300.000 lines of C code !
So I'm rewriting only the legacy I/O isam calls (like open_isam, add_key,
del_key,
read_record, write_record, close_isam and so on..).

I have a problem: these programs recall each other trough execve() system
calls
maintaining the connection to the ISAM files opened (and record locks also
!).
For example:

progr1
...
open_isam(fd,name)
...
recnum=....;
read_record_and_lock(fd,recnum,rec); /* READ AND LOCK record rec */
...
save_var_to_shared_memory() /* save all variables on shared memory */
...
execve("prog2",....) /* execute prog2 instead of prog1 with the same PID:
this call DOES NOT close any files/sockets */

return;

prog2

....
load_var_from_shared_memory(); /* the files are already OPENED and the
record
is LOCKED */
...
rec.field1=...; /* change some value on record */
...
write_record(fd,recnum,rec); /* update record and release LOCK */
...
isam_close(fd);

return;

If I close and open the connection to MYSQL, i lose the record lock, the id
connection and
so on.

How can I to pass a MYSQL structure to another process through an execve()
call ?

The socket remains opened through this call, but I think I must recreate
the MYSQL object after reading from shared memory (there is also the MYSQL
statement data
structure). Probabily, I need a function that clone a MYSQL connection ...

I have look into libmysql source code but it's not so simple to find the
correct
solution to this problem.

Can you help me?

Thanks
Federico



Reply With Quote
  #2  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: MYSQL connection persistence through an execve() syscall - 09-26-2006 , 09:02 PM






cuffiette wrote:
Quote:
Hi everybody,
I migrate some C programs from a legacy isam to mysql. I can not change the
program logic,
because there are over than 300.000 lines of C code !
So I'm rewriting only the legacy I/O isam calls (like open_isam, add_key,
del_key,
read_record, write_record, close_isam and so on..).

I have a problem: these programs recall each other trough execve() system
calls
maintaining the connection to the ISAM files opened (and record locks also
!).
For example:

progr1
..
open_isam(fd,name)
..
recnum=....;
read_record_and_lock(fd,recnum,rec); /* READ AND LOCK record rec */
..
save_var_to_shared_memory() /* save all variables on shared memory */
..
execve("prog2",....) /* execute prog2 instead of prog1 with the same PID:
this call DOES NOT close any files/sockets */

return;

prog2

...
load_var_from_shared_memory(); /* the files are already OPENED and the
record
is LOCKED */
..
rec.field1=...; /* change some value on record */
..
write_record(fd,recnum,rec); /* update record and release LOCK */
..
isam_close(fd);

return;

If I close and open the connection to MYSQL, i lose the record lock, the id
connection and
so on.

How can I to pass a MYSQL structure to another process through an execve()
call ?

The socket remains opened through this call, but I think I must recreate
the MYSQL object after reading from shared memory (there is also the MYSQL
statement data
structure). Probabily, I need a function that clone a MYSQL connection ...

I have look into libmysql source code but it's not so simple to find the
correct
solution to this problem.

Can you help me?

Thanks
Federico


Federico,

I don't think you'll be able to do it. When you call execve() the
system starts a new process, with a new process id. MySQL, like all
relational databases I know of, requires a different connection for each
process. And there is no way to clone a connection.

I'm afraid if you have to convert it to MySQL (or any other RDB), you're
going to have to change the logic here. Maybe the easiest way would be
to have another process handle all the connections for both prog1 and
prog2. But not knowing your code, I can't say.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================


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.