-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/01/13 00:22, Eduardo Morras wrote:
> opened before the fork, and after it the childs use the database
connection. I don't want to corrupt the database,

https://sqlite.org/faq.html#q6

You can't use the database across forks.  Parent and child would both
consider themselves owners of open databases and silently corrupt each
other's work and interfere with each other's locks.  You will corrupt the
database. You need to close all databases and then do the fork, and then
open databases in the children.

In APSW I provide a fork checker.  This is done by providing an
alternative mutex implementation that records the process id a mutex was
created in and then checking the mutex is only ever used in the same
process id.  (Each database connection has its own mutex.)

The code that does this:

  https://code.google.com/p/apsw/source/browse/src/apsw.c#704

In my benchmark tests I measured a slowdown of 1%.  ie if your code did
nothing but SQLite calls then you can expect it to be about 1% slower.

I strongly recommend you do something like this to ensure that no
developer accidentally has databases used across forks.

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlDq0REACgkQmOOfHg372QQC6QCfX7wa7eIq4okyJRT74LN8X4xI
xlgAoOSwC5dDzyvfb4S30nivW/rLEYIk
=tlN5
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to