Changeset 109760 in webkit


Ignore:
Timestamp:
Mar 5, 2012 10:15:32 AM (12 years ago)
Author:
Martin Robinson
Message:

[soup] Crash while loading http://www.jusco.cn
https://bugs.webkit.org/show_bug.cgi?id=68238

Reviewed by Philippe Normand.

.:

  • configure.ac: Bumped the libsoup dependency to 2.37.90.

Source/WebCore:

Test: http/tests/xmlhttprequest/xmlhttprequest-sync-no-timers.html

When running synchronous XMLHttpRequests, push a new inner thread default
context, so that other sources from timers and network activity do not run.
This will make synchronous requests truly synchronous with the rest of
WebCore.

  • platform/network/soup/ResourceHandleSoup.cpp:

(WebCoreSynchronousLoader): Clean up the method definitions a bit by writing them inline.
(WebCore::WebCoreSynchronousLoader::WebCoreSynchronousLoader): Push a new thread default
context to prevent other sources from running.
(WebCore::WebCoreSynchronousLoader::~WebCoreSynchronousLoader): Pop the inner thread default context.
(WebCore::closeCallback): If the client is synchronous call didFinishLoading now.
(WebCore::readCallback): Only call didFinishLoading if the client isn't synchronous.
(WebCore::ResourceHandle::defaultSession): Activate use-thread-context so that the soup session
respects the inner thread context.
(ResourceHandleClient):
(WebCore::ResourceHandleClient::isSynchronousClient): Added this virtual method.

Tools:

  • gtk/jhbuild.modules: Bumped the libsoup and glib dependencies

in the jhbuild file.

LayoutTests:

  • http/tests/xmlhttprequest/xmlhttprequest-sync-no-timers-expected.txt: Added.
  • http/tests/xmlhttprequest/xmlhttprequest-sync-no-timers.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r109695 r109760  
     12012-03-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [soup] Crash while loading http://www.jusco.cn
     4        https://bugs.webkit.org/show_bug.cgi?id=68238
     5
     6        Reviewed by Philippe Normand.
     7
     8        * configure.ac: Bumped the libsoup dependency to 2.37.90.
     9
    1102012-03-04  Raphael Kubo da Costa  <kubo@profusion.mobi>
    211
  • trunk/LayoutTests/ChangeLog

    r109753 r109760  
     12012-03-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [soup] Crash while loading http://www.jusco.cn
     4        https://bugs.webkit.org/show_bug.cgi?id=68238
     5
     6        Reviewed by Philippe Normand.
     7
     8        * http/tests/xmlhttprequest/xmlhttprequest-sync-no-timers-expected.txt: Added.
     9        * http/tests/xmlhttprequest/xmlhttprequest-sync-no-timers.html: Added.
     10
    1112012-03-05  Zan Dobersek  <zandobersek@gmail.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r109746 r109760  
     12012-03-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [soup] Crash while loading http://www.jusco.cn
     4        https://bugs.webkit.org/show_bug.cgi?id=68238
     5
     6        Reviewed by Philippe Normand.
     7
     8        Test: http/tests/xmlhttprequest/xmlhttprequest-sync-no-timers.html
     9
     10        When running synchronous XMLHttpRequests, push a new inner thread default
     11        context, so that other sources from timers and network activity do not run.
     12        This will make synchronous requests truly synchronous with the rest of
     13        WebCore.
     14
     15        * platform/network/soup/ResourceHandleSoup.cpp:
     16        (WebCoreSynchronousLoader): Clean up the method definitions a bit by writing them inline.
     17        (WebCore::WebCoreSynchronousLoader::WebCoreSynchronousLoader): Push a new thread default
     18        context to prevent other sources from running.
     19        (WebCore::WebCoreSynchronousLoader::~WebCoreSynchronousLoader): Pop the inner thread default context.
     20        (WebCore::closeCallback): If the client is synchronous call didFinishLoading now.
     21        (WebCore::readCallback): Only call didFinishLoading if the client isn't synchronous.
     22        (WebCore::ResourceHandle::defaultSession): Activate use-thread-context so that the soup session
     23        respects the inner thread context.
     24        (ResourceHandleClient):
     25        (WebCore::ResourceHandleClient::isSynchronousClient): Added this virtual method.
     26
    1272012-03-05  Alexander Færøy  <alexander.faeroy@nokia.com>
    228
  • trunk/Source/WebCore/platform/network/ResourceHandleClient.h

    r105203 r109760  
    110110        virtual AsyncFileStream* createAsyncFileStream(FileStreamClient*) { return 0; }
    111111#endif
     112#if USE(SOUP)
     113        virtual bool isSynchronousClient() { return false; }
     114#endif
    112115    };
    113116
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r109129 r109760  
    7373    WTF_MAKE_NONCOPYABLE(WebCoreSynchronousLoader);
    7474public:
    75     WebCoreSynchronousLoader(ResourceError&, ResourceResponse &, Vector<char>&);
    76     ~WebCoreSynchronousLoader();
    77 
    78     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
    79     virtual void didReceiveData(ResourceHandle*, const char*, int, int encodedDataLength);
    80     virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
    81     virtual void didFail(ResourceHandle*, const ResourceError&);
    82 
    83     void run();
     75
     76    WebCoreSynchronousLoader(ResourceError& error, ResourceResponse& response, Vector<char>& data)
     77        : m_error(error)
     78        , m_response(response)
     79        , m_data(data)
     80        , m_finished(false)
     81    {
     82        // We don't want any timers to fire while we are doing our synchronous load
     83        // so we replace the thread default main context. The main loop iterations
     84        // will only process GSources associated with this inner context.
     85        GRefPtr<GMainContext> innerMainContext = adoptGRef(g_main_context_new());
     86        g_main_context_push_thread_default(innerMainContext.get());
     87        m_mainLoop = g_main_loop_new(innerMainContext.get(), false);
     88    }
     89
     90    ~WebCoreSynchronousLoader()
     91    {
     92        g_main_context_pop_thread_default(g_main_context_get_thread_default());
     93    }
     94
     95    virtual bool isSynchronousClient()
     96    {
     97        return true;
     98    }
     99
     100    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
     101    {
     102        m_response = response;
     103    }
     104
     105    virtual void didReceiveData(ResourceHandle*, const char* data, int length, int)
     106    {
     107        m_data.append(data, length);
     108    }
     109
     110    virtual void didFinishLoading(ResourceHandle*, double)
     111    {
     112        if (g_main_loop_is_running(m_mainLoop.get()))
     113            g_main_loop_quit(m_mainLoop.get());
     114        m_finished = true;
     115    }
     116
     117    virtual void didFail(ResourceHandle* handle, const ResourceError& error)
     118    {
     119        m_error = error;
     120        didFinishLoading(handle, 0);
     121    }
     122
     123    void run()
     124    {
     125        if (!m_finished)
     126            g_main_loop_run(m_mainLoop.get());
     127    }
    84128
    85129private:
     
    90134    GRefPtr<GMainLoop> m_mainLoop;
    91135};
    92 
    93 WebCoreSynchronousLoader::WebCoreSynchronousLoader(ResourceError& error, ResourceResponse& response, Vector<char>& data)
    94     : m_error(error)
    95     , m_response(response)
    96     , m_data(data)
    97     , m_finished(false)
    98 {
    99     m_mainLoop = adoptGRef(g_main_loop_new(0, false));
    100 }
    101 
    102 WebCoreSynchronousLoader::~WebCoreSynchronousLoader()
    103 {
    104 }
    105 
    106 void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
    107 {
    108     m_response = response;
    109 }
    110 
    111 void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, int length, int)
    112 {
    113     m_data.append(data, length);
    114 }
    115 
    116 void WebCoreSynchronousLoader::didFinishLoading(ResourceHandle*, double)
    117 {
    118     g_main_loop_quit(m_mainLoop.get());
    119     m_finished = true;
    120 }
    121 
    122 void WebCoreSynchronousLoader::didFail(ResourceHandle* handle, const ResourceError& error)
    123 {
    124     m_error = error;
    125     didFinishLoading(handle, 0);
    126 }
    127 
    128 void WebCoreSynchronousLoader::run()
    129 {
    130     if (!m_finished)
    131         g_main_loop_run(m_mainLoop.get());
    132 }
    133136
    134137static void cleanupSoupRequestOperation(ResourceHandle*, bool isDestroying);
     
    638641    g_input_stream_close_finish(d->m_inputStream.get(), res, 0);
    639642    cleanupSoupRequestOperation(handle.get());
     643
     644    if (handle->client()->isSynchronousClient())
     645        handle->client()->didFinishLoading(handle.get(), 0);
    640646}
    641647
     
    667673    if (!bytesRead) {
    668674        // We inform WebCore of load completion now instead of waiting for the input
    669         // stream to close because the input stream is closed asynchronously.
    670         client->didFinishLoading(handle.get(), 0);
     675        // stream to close because the input stream is closed asynchronously. If this
     676        // is a synchronous request, we wait until the closeCallback, because we don't
     677        // want to halt the internal main loop before the input stream closes.
     678        if (!handle->client()->isSynchronousClient())
     679            client->didFinishLoading(handle.get(), 0);
    671680        g_input_stream_close_async(d->m_inputStream.get(), G_PRIORITY_DEFAULT, 0, closeCallback, handle.get());
    672681        return;
     
    740749                     SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER,
    741750                     SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_DEFAULT,
     751                     SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
    742752                     NULL);
    743753    }
  • trunk/Tools/ChangeLog

    r109755 r109760  
     12012-03-05  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [soup] Crash while loading http://www.jusco.cn
     4        https://bugs.webkit.org/show_bug.cgi?id=68238
     5
     6        Reviewed by Philippe Normand.
     7
     8        * gtk/jhbuild.modules: Bumped the libsoup and glib dependencies
     9        in the jhbuild file.
     10
    1112012-03-05  Sheriff Bot  <webkit.review.bot@gmail.com>
    212
  • trunk/Tools/gtk/jhbuild.modules

    r106936 r109760  
    121121      <dep package="libffi"/>
    122122    </dependencies>
    123     <branch module="/pub/GNOME/sources/glib/2.31/glib-2.31.2.tar.xz" version="2.31.2"
    124             repo="ftp.gnome.org"
    125             hash="sha256:19d7921671a487c3c5759a57df7b8508afdbadd7764d62a47a82fff7b399032b"
    126             md5sum="1cbdf314d7c87916a0c3dce83ac0285f"/>
     123    <branch module="/pub/GNOME/sources/glib/2.31/glib-2.31.8.tar.xz" version="2.31.8"
     124            repo="ftp.gnome.org"
     125            hash="sha256:1ce3d275189000e1c50e92efcdb6447bc260b1e5c41699b7a1959e3e1928fbaa"/>
    127126  </autotools>
    128127
     
    153152      <dep package="glib-networking"/>
    154153    </dependencies>
    155     <branch module="libsoup" version="2.37.2.1+git"
     154    <branch module="libsoup" version="2.37.91+git"
    156155            repo="git.gnome.org"
    157             tag="5cbfc48caf76ced2e28ee06c9e40523273601dc6"/>
     156            tag="52057510accba49cfc6d1d0e52292368ba2e0c99"/>
    158157  </autotools>
    159158
  • trunk/configure.ac

    r109667 r109760  
    379379FREETYPE2_REQUIRED_VERSION=9.0
    380380GLIB_REQUIRED_VERSION=2.31.2
    381 LIBSOUP_REQUIRED_VERSION=2.37.2.1
     381LIBSOUP_REQUIRED_VERSION=2.37.90
    382382LIBXML_REQUIRED_VERSION=2.6
    383383PANGO_REQUIRED_VERSION=1.21.0
Note: See TracChangeset for help on using the changeset viewer.