[REGRESSION] Cannot cancel `soup_session_send_async` in the latest build
Problem
The following code
#include <cassert>
#include <iostream>
#include <string>
#include <libsoup/soup.h>
int main(int argc, char* argv[]) {
if (argc < 3) {
return -1;
}
std::cout << "Testing under libsoup "
<< soup_get_major_version() << '.'
<< soup_get_minor_version() << '.'
<< soup_get_micro_version() << std::endl;
static auto loop = g_main_loop_new(g_main_context_get_thread_default(), true);
static auto session = soup_session_new();
static auto message = soup_message_new("GET", argv[2]);
static auto cancellable = g_cancellable_new();
static GInputStream* stream;
soup_session_send_async(session, message, cancellable, [](GObject* source, GAsyncResult* result, void*) {
assert(reinterpret_cast<SoupSession*>(source) == session);
GError* error{};
stream = soup_session_send_finish(session, result, &error);
std::cout << (error ? error->message : "Success") << std::endl;
g_main_loop_quit(loop);
g_main_loop_unref(loop);
g_object_unref(session);
g_object_unref(message);
g_object_unref(cancellable);
}, nullptr);
g_timeout_add(std::stoi(argv[1]), [](void*) -> gboolean {
g_cancellable_cancel(cancellable);
std::cout << "Cancelling" << std::endl;
return false;
}, nullptr);
g_main_loop_run(loop);
return 0;
}
Compiled with g++ -std=c++17 -O0 -g $(pkg-config --libs --cflags libsoup-2.4) -o soup_regression soup_regression.cpp
Under the org.gnome.Sdk/x86_64/3.30
runtime from https://flathub.org/repo/flathub.flatpakrepo, the result is
$ ./soup_regression 50 http://2.2.2.2/
Testing under libsoup 2.64.2
Cancelling
Operation was cancelled
$ ./soup_regression 5000 http://2.2.2.2/
Testing under libsoup 2.64.2
Cancelling
Operation was cancelled
$
However, under the org.gnome.Sdk/x86_64/master
runtime from https://sdk.gnome.org/gnome-nightly.flatpakrepo, the result is
$ ./soup_regression 50 http://2.2.2.2/
Testing under libsoup 2.65.90
Cancelling
Operation was cancelled
$ ./soup_regression 5000 http://2.2.2.2/
Testing under libsoup 2.65.90
Cancelling
^C
$
The callback is not triggered by the cancel operation in the second invocation, and the program has to be terminated by manual keyboard interrupt.
Additional Information
As shown above, the version of the malfunctioning libsoup
is 2.65.90
, while the other one is 2.64.2
. The versions of the Flatpak runtimes are shown below
$ flatpak info org.gnome.Sdk/x86_64/3.30
GNOME Software Development Kit version 3.30 - Tools and headers for developing
applications using the GNOME application platform
ID: org.gnome.Sdk
Ref: runtime/org.gnome.Sdk/x86_64/3.30
Arch: x86_64
Branch: 3.30
License: GPL-2.0+
Origin: flathub
Collection: org.flathub.Stable
Installation: system
Installed: 4.2 GB
Commit: 9546b511a0e976044ad57a1ef444299e2c628d19202095d07b36605d96fa8025
Parent: 659079025ce26de6fb2bb5e7cb95d0d6017ebdae8d98395d420bee1d4a5814ea
Subject: Export org.gnome.Sdk
Date: 2019-01-23 21:34:16 +0000
$ flatpak info org.gnome.Sdk/x86_64/master
GNOME Software Development Kit version master - Tools and headers for
developing applications using the GNOME application platform
ID: org.gnome.Sdk
Ref: runtime/org.gnome.Sdk/x86_64/master
Arch: x86_64
Branch: master
License: GPL-2.0+
Origin: gnome-nightly
Collection:
Installation: system
Installed: 4.2 GB
Commit: 0d10f234d6f1e751b3eed42db6d85f00392515e49356e97c848a8cb1266a5d82
Parent: f27b26896b5b1f8fd67c4a011be6b5d67df6d5863ce31c1a2c6307552f916679
Subject: Export org.gnome.Sdk
Date: 2019-02-07 23:17:31 +0000
$
Edited by Ghost User