ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

How to share file access between two applications?

<< < (2/2)

f0dder:
Yep, I think the app would have to be re-engineered such that it only reads the file in memory and then leaves it alone (like e.g. notepad). Additionally, the app would have to read the file again first before actually writing to it (in case the other instance would have written to it in the meantime).-David.P (December 09, 2008, 04:44 AM)
--- End quote ---
That would still leave it vulnerable to a race condition, though...

Why oh why is there no software (hardware?) solution to that problem? I think that this problem occurs very often. Well of course it could cause all kinds of trouble if used without caution.-David.P (December 09, 2008, 04:44 AM)
--- End quote ---
The solution is the use of databases, going through a database server instead of directly accessing the files. But of course that is pretty overkill for configuration data :)

David.P:
Hmm, actually that adress book seems to be some sort of SQL database...

It consists of the following several files:

phonebook.db
phonebook.db.lck
phonebook.db.log
phonebook.db.script
phonebook.db.properties

of which "phonebook.db.script" contains the lines below:


--- ---#HSQL Database Engine 1.8.0.9
#Tue Dec 09 20:51:59 CET 2008
hsqldb.script_format=0
runtime.gc_interval=0
sql.enforce_strict_size=false
hsqldb.cache_size_scale=8
readonly=false
hsqldb.nio_data_file=true
hsqldb.cache_scale=14
version=1.8.0
hsqldb.default_table_type=memory
hsqldb.cache_file_scale=1
hsqldb.log_size=200
modified=yes
hsqldb.cache_version=1.7.0
hsqldb.original_version=1.8.0
hsqldb.compatible_version=1.8.0
Would that make any difference to the original question?

David.P

f0dder:
Does seem like the author tries to keep from having multiple processes accessing the file and causing havok (ie, the .lock file) - but he still keeps the database open during the entire run of the program, which is quite a normal thing to do. To have smooth and painless multiple-processes (especially across networks) accessing a database, you really do need to access it through a database server process, which would be the only process keeping the file open.

David.P:
Thanks!

Cheers David.P

Navigation

[0] Message Index

[*] Previous page

Go to full version