Apache OpenOffice (AOO) Bugzilla – Issue 89730
osl_getAbsoluteFileURL() lstat()s too much
Last modified: 2013-07-29 17:55:05 UTC
The implementation of osl_getAbsoluteFileURL_impl_() is done so that it lstat()s O(n^2), instead of n paths (where n is depth of the path). It is because it calls realpath() on each of the components of the path, and realpath() itself does lstat() on each of the components itself. I'll attach a patch that changes it to lstat()ing n paths only - on the price of _not_ absolutizing non-existing paths. To me, it seems like a good deal ;-) - if the path does not exist, who cares what part of it is absolute? In the case it was created later, nobody can expect what part of that path were symlinks etc. anyway, and it should go through the full realpath() process anyway. Here's a part of strace log showing the wrong behavior: 10406 19:41:49.765833 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.765887 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.765936 lstat("/local/inst", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.765993 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766042 lstat("/local/inst", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766092 lstat("/local/inst/OpenOffice.org3.0-m12", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766153 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766202 lstat("/local/inst", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766251 lstat("/local/inst/OpenOffice.org3.0-m12", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766303 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR| 0755, st_size=4096, ...}) = 0 10406 19:41:49.766363 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766412 lstat("/local/inst", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766461 lstat("/local/inst/OpenOffice.org3.0-m12", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766514 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR| 0755, st_size=4096, ...}) = 0 10406 19:41:49.766568 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766628 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766677 lstat("/local/inst", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766726 lstat("/local/inst/OpenOffice.org3.0-m12", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766779 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR| 0755, st_size=4096, ...}) = 0 10406 19:41:49.766833 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766887 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure/bin", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766949 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766997 lstat("/local/inst", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.767047 lstat("/local/inst/OpenOffice.org3.0-m12", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.767099 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR| 0755, st_size=4096, ...}) = 0 10406 19:41:49.767153 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.767208 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 The patch changes it to simple: 10406 19:41:49.766949 lstat("/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.766997 lstat("/local/inst", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.767047 lstat("/local/inst/OpenOffice.org3.0-m12", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.767099 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR| 0755, st_size=4096, ...}) = 0 10406 19:41:49.767153 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 10406 19:41:49.767208 lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
Created attachment 53820 [details] The patch.
hro: Please take over.
.
Retargeted.
hro: We should integrate this patch in 3.1
Good approach but there were ancious reason that it also worked with nonexistant paths. will review it for scheduled release.
Ping
hro: Please, any more info needed from my side?
Back to myself, apparently there are problems with this on MacOS X.
Kendy, in case you are still working on this: Mikhail (mav) is now maintaining the osl_file stuff. As 3.1 obviously is an unrealistic target I changed it to 3.x.
I'm adding this comment to all open issues with Issue Type == PATCH. We have 220 such issues, many of them quite old. I apologize for that. We need your help in prioritizing which patches should be integrated into our next release, Apache OpenOffice 4.0. If you have submitted a patch and think it is applicable for AOO 4.0, please respond with a comment to let us know. On the other hand, if the patch is no longer relevant, please let us know that as well. If you have any general questions or want to discuss this further, please send a note to our dev mailing list: dev@openoffice.apache.org Thanks! -Rob