Closed GoogleCodeExporter closed 9 years ago
Is it not possible to initialize this during startup? I'm working on a patch to
make
Chrome do this explicitly: http://codereview.chromium.org/579004
since we now need to add a set of our own schemes. This approach should be what
you
need, if the patch itself doesn't fix your problem.
Original comment by bre...@gmail.com
on 22 Feb 2010 at 9:11
Unless I'm missing something, you seem to force the initialization by adding
schemes.
What if I don't need new schemes, how do I initialize the GURL module?
Would be nice to have an init and a term entry/exit points. It would also be
useful to
allow clients to destroy the global allocation, because in a plugin world, this
leak
could accumulate annoyingly every time the plugin DLL is loaded and freed,
which could
happen frequently in some cases...
Original comment by mad@chromium.org
on 22 Feb 2010 at 10:43
I see, if you want to add such a function to url_util.h, feel free to submit a
patch.
If your application uses Chrome code (I have no idea), I'm guessing my new
patch will
work, since the Chrome-specific schemes need to be added. for you.
Original comment by bre...@gmail.com
on 23 Feb 2010 at 12:06
How about this:
Index: src/url_util.cc
===================================================================
--- src/url_util.cc (revision 122)
+++ src/url_util.cc (working copy)
@@ -359,6 +359,15 @@
return DoFindAndCompareScheme(str, str_len, compare, found_scheme);
}
+void InitializeGoogleUrl() {
+ InitStandardSchemes();
+}
+
+void TerminateGoogleUrl() {
+ if (standard_schemes) {
+ delete standard_schemes;
+ standard_schemes = NULL;
+ }
+}
+
bool Canonicalize(const char* spec,
int spec_len,
url_canon::CharsetConverter* charset_converter,
Index: D:/src/ceee/src/googleurl/src/url_util.h
===================================================================
--- src/url_util.h (revision 122)
+++ src/url_util.h (working copy)
@@ -79,6 +79,23 @@
// URL library wrappers -------------------------------------------------------
+// Initializes the URL library to make sure there is no race in initializing
+// internal components like standard schemes. It is OK to call this more than
+// once, subsequent calls will simply "noop", unless TerminateGoogleUrl() was
+// called in the mean time. This will also be a "noop" if other calls to the
+// library have forced an initialization beforehand.
+// Be aware that there is no thread safety in this code so you should make sure
+// to call this before any other thread interacts with the URL library.
+void InitializeGoogleUrl();
+
+// Terminate the URL library so that there are no leaked internal components.
+// Note that once this is called, the URL library can still be used, it will
+// simply re-initialize itself. It is OK to call this more than once, or at a
+// point where the URL library has not been initialized yet.
+// Be aware that there is no thread safety in this code so you should make sure
+// to call this after any other thread interacts with the URL library.
+void TerminateGoogleUrl();
+
// Parses the given spec according to the extracted scheme type. Normal users
// should use the URL object, although this may be useful if performance is
// critical and you don't want to do the heap allocation for the std::string.
Original comment by mad@chromium.org
on 23 Feb 2010 at 4:15
Chrome Frame has the same issue, crashes due to the initialization race, and
the leak
is bad news for a plugin. See [http://code.google.com/p/chromium/issues/detail?
id=38484]
Original comment by si...@google.com
on 24 Mar 2010 at 9:27
I checked in the fix in r126. I renamed the functions Initialize and Shutdown
since
they were already in the url_util namespace. I did not pull it into Chrome, if
you want
that you should submit a DEPS change yourself.
Original comment by bre...@gmail.com
on 31 Mar 2010 at 4:50
Original issue reported on code.google.com by
mad@chromium.org
on 22 Feb 2010 at 8:36