diff options
author | Brendan Long <self@brendanlong.com> | 2017-10-09 22:59:28 +0300 |
---|---|---|
committer | Brendan Long <self@brendanlong.com> | 2017-10-09 22:59:28 +0300 |
commit | 9cb784550958740b0117de178caddef55e2d5de2 (patch) | |
tree | a106369ac4e6cebc1090fe0c39c0bf31514b1cee | |
parent | cb6c81d068b95ac281cfdfcda7e253d7c2186fd7 (diff) |
Revert "Fix a race condition with the static soup session in Utils"
This reverts commit 6ebed77add49a0f3b8177e98a9ef9d2de209026d.
-rw-r--r-- | src/Utils.vala | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Utils.vala b/src/Utils.vala index f53a1fb6..d6221f57 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -15,14 +15,19 @@ public class FeedReader.Utils : GLib.Object { - private static Soup.Session m_session; + private static Soup.Session? m_session; - static construct + private static Soup.Session getSession() { - m_session = new Soup.Session(); - m_session.user_agent = Constants.USER_AGENT; - m_session.ssl_strict = false; - m_session.timeout = 1; + if(m_session == null) + { + m_session = new Soup.Session(); + m_session.user_agent = Constants.USER_AGENT; + m_session.ssl_strict = false; + m_session.timeout = 1; + } + + return m_session; } public static void generatePreviews(Gee.List<Article> articles) @@ -274,7 +279,7 @@ public class FeedReader.Utils : GLib.Object { return false; } - var status = m_session.send_message(message); + var status = getSession().send_message(message); Logger.debug(@"Ping: status $status"); @@ -572,7 +577,7 @@ public class FeedReader.Utils : GLib.Object { InputStream bodyStream; try { - bodyStream = yield m_session.send_async(message_html); + bodyStream = yield getSession().send_async(message_html); } catch (Error e) { @@ -686,7 +691,7 @@ public class FeedReader.Utils : GLib.Object { InputStream bodyStream; try { - bodyStream = yield m_session.send_async(message, cancellable); + bodyStream = yield getSession().send_async(message, cancellable); } catch (Error e) { |