Professional Web Applications Themes

MYSQL connection persistence through an execve() syscall - MySQL

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

  1. #1

    Default MYSQL connection persistence through an execve() syscall

    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


    cuffiette Guest

  2. #2

    Default Re: MYSQL connection persistence through an execve() syscall

    cuffiette wrote: 

    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.
    net
    ==================
    Jerry Guest

Similar Threads

  1. Replies: 2
    Last Post: March 19th, 09:28 AM
  2. Replies: 1
    Last Post: January 23rd, 12:06 PM
  3. MYSQL 5.0 connection
    By utardylan in forum Coldfusion Database Access
    Replies: 2
    Last Post: July 3rd, 03:31 PM
  4. MySQL Connection with SSL or TLS
    By Patrick T. in forum Macromedia Director Basics
    Replies: 3
    Last Post: October 17th, 06:13 AM
  5. syscall question/example
    By Robert in forum PERL Miscellaneous
    Replies: 2
    Last Post: August 15th, 11:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139