Conversation
There was a problem hiding this comment.
Pull request overview
Upgrades the server stack to support newer GSSDP (1.6) and libsoup 3 by conditionally switching build dependencies and source files, plus adding libsoup3-compatible server handling.
Changes:
- Add libsoup2 vs libsoup3 conditional compilation in
gdialservice.cppfor request throttling and URI logging. - Update
server/CMakeLists.txtto prefer libsoup-3.0 + gssdp-1.6 and switch togdial1p6-*.csources when available. - Add a libsoup3-specific shield implementation (
gdial1p6-shield.c).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| server/gdialservice.cpp | Adds libsoup3 conditionals for callback signatures and URI handling. |
| server/gdial1p6-shield.c | Introduces a libsoup3-oriented connection “shield” implementation. |
| server/CMakeLists.txt | Selects libsoup3 + gssdp-1.6 and switches source lists accordingly. |
Comments suppressed due to low confidence (1)
server/CMakeLists.txt:52
- The
if (LIBSOUP3_FOUND)block that selects GSSDP packages is missing a matchingendif(). As written, theelse()branch for LIBSOUP3_FOUND is never closed, which will cause a CMake configure error (unmatched if/else). Add anendif()after the GSSDP selection logic to properly close the LIBSOUP3_FOUND conditional (and keep the SOUP selection outside of it).
if (LIBSOUP3_FOUND)
add_definitions(-DHAVE_LIBSOUP_VERSION_3)
pkg_search_module (GSSDP16 gssdp-1.6)
if (GSSDP16_FOUND)
pkg_search_module (GSSDP REQUIRED gssdp-1.6)
add_definitions(-DHAVE_GSSDP_VERSION_1_6_OR_NEWER)
message("Using gssdp-1.6")
endif()
else()
pkg_search_module (GSSDP12 gssdp-1.2)
if (GSSDP12_FOUND)
pkg_search_module (GSSDP REQUIRED gssdp-1.2)
add_definitions(-DHAVE_GSSDP_VERSION_1_2_OR_NEWER)
message("Using gssdp-1.2")
else()
pkg_search_module (GSSDP REQUIRED gssdp-1.0)
endif()
if (LIBSOUP3_FOUND)
pkg_search_module (SOUP REQUIRED libsoup-3.0)
message("Using libsoup-3.0")
else()
pkg_search_module (SOUP REQUIRED libsoup-2.4)
endif()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| static void server_request_remove_callback (SoupMessage *msg) { | ||
| GDIAL_LOGTRACE("Entering ..."); | ||
| DialShieldConnectionContext * conn_context = (DialShieldConnectionContext *) g_hash_table_lookup(active_conns_, msg); | ||
| if (conn_context) { | ||
| if (conn_context->read_timeout_source != 0) { | ||
| g_print_with_timestamp("server_request_remove_callback tid=[%lx] msg=%p timeout source %d removed", | ||
| pthread_self(), msg, conn_context->read_timeout_source); | ||
| g_source_remove(conn_context->read_timeout_source); | ||
| } | ||
| g_hash_table_remove(active_conns_, msg); | ||
| g_free(conn_context); | ||
| conn_context = NULL; | ||
| } | ||
| GDIAL_LOGTRACE("Exiting ..."); | ||
| } | ||
|
|
||
| static gboolean soup_message_read_timeout_callback(gpointer user_data) { | ||
| SoupMessage *msg = (SoupMessage*)user_data; | ||
| GDIAL_LOGTRACE("Entering ..."); | ||
| DialShieldConnectionContext * conn_context = (DialShieldConnectionContext *)g_hash_table_lookup(active_conns_, msg); | ||
| g_print_with_timestamp("soup_message_read_timeout_callback tid=[%lx] msg=%p", pthread_self(), msg); |
There was a problem hiding this comment.
This libsoup3 shield implementation mixes SoupServerMessage* (signal callbacks) with SoupMessage* (hash-table key type, timeout callback, weak-ref callback). In libsoup3, SoupServerMessage is not a SoupMessage, so these signatures/casts are incorrect and can lead to undefined behavior or hard-to-debug issues. Use SoupServerMessage* consistently throughout (including server_request_remove_callback, soup_message_read_timeout_callback, and the weak-ref callback).
| static void soup_message_weak_ref_callback(gpointer user_data, GObject *obj) { | ||
| SoupMessage *msg0=(SoupMessage*)obj; | ||
| SoupMessage *msg=(SoupMessage*)user_data; | ||
| GDIAL_LOGTRACE("Entering ..."); | ||
| assert(msg0==msg); | ||
| g_print_with_timestamp("soup_message_weak_ref_callback tid=[%lx] msg=%p", pthread_self(), msg); | ||
| server_request_remove_callback(msg); | ||
| GDIAL_LOGTRACE("Exiting ..."); |
There was a problem hiding this comment.
soup_message_weak_ref_callback casts the GObject* to SoupMessage* and asserts equality against the user_data pointer. Under libsoup3 the object being finalized is a SoupServerMessage, so these casts are wrong. Update the callback to use SoupServerMessage* (or just compare raw pointers / GObject*) to avoid relying on an unrelated type.
| SoupMessage *msg = (SoupMessage *)key; | ||
| server_request_remove_callback(msg); | ||
| } |
There was a problem hiding this comment.
gdial_shield_term() iterates active_conns_ keys and casts them to SoupMessage*, but in the libsoup3 build the keys are SoupServerMessage* pointers. Keep the key type consistent with the libsoup3 message type to avoid incorrect casts and to make the ownership/lifetime expectations clear.
| if (LIBSOUP3_FOUND) | ||
| add_definitions(-DHAVE_LIBSOUP_VERSION_3) | ||
| pkg_search_module (GSSDP16 gssdp-1.6) | ||
| if (GSSDP16_FOUND) | ||
| pkg_search_module (GSSDP REQUIRED gssdp-1.6) | ||
| add_definitions(-DHAVE_GSSDP_VERSION_1_6_OR_NEWER) | ||
| message("Using gssdp-1.6") | ||
| endif() |
There was a problem hiding this comment.
When LIBSOUP3_FOUND is true, GSSDP is only set if GSSDP16_FOUND is true; otherwise GSSDP is never marked REQUIRED and ${GSSDP_INCLUDE_DIRS}/${GSSDP_LIBRARIES} may be empty, leading to build/link failures later. If libsoup3 builds require gssdp-1.6, make pkg_search_module(GSSDP REQUIRED gssdp-1.6) unconditional in that branch (or add a clear fallback/error path).
| ${CMAKE_CURRENT_SOURCE_DIR}/gdial1p6-rest.c | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/gdial1p6-ssdp.c |
There was a problem hiding this comment.
The libsoup3 source list references gdial1p6-rest.c and gdial1p6-ssdp.c, but the repository files are named with a trailing invisible Unicode mark (e.g., gdial1p6-rest.c / gdial1p6-ssdp.c). With the current paths, CMake may fail to locate these sources on disk. Rename the files to plain ASCII .c filenames (preferred) or update the CMake source paths to match the actual filenames.
| ${CMAKE_CURRENT_SOURCE_DIR}/gdial1p6-rest.c | |
| ${CMAKE_CURRENT_SOURCE_DIR}/gdial1p6-ssdp.c | |
| ${CMAKE_CURRENT_SOURCE_DIR}/gdial1p6-rest.c | |
| ${CMAKE_CURRENT_SOURCE_DIR}/gdial1p6-ssdp.c |
|
Hi @balav08 : Please fix the filenames server/gdial1p6-rest.c and server/gdial1p6-ssdp.c which have trailing non-ascii characters. This breaks the scans and will cause lots of confusion: |
|
Hi @balav08 : Please check server/gdial1p6-rest.c and server/gdial1p6-ssdp.c which have non-ascii characters in the filenames. This is preventing scans and will cause lots of confusion anyway. Thanks! |
No description provided.