Skip to content

RDKEMW-6898: gdialserver not compatible with Libsoup3 library#202

Closed
balav08 wants to merge 2 commits into
developfrom
feature/RDKEMW-6898-may18
Closed

RDKEMW-6898: gdialserver not compatible with Libsoup3 library#202
balav08 wants to merge 2 commits into
developfrom
feature/RDKEMW-6898-may18

Conversation

@balav08
Copy link
Copy Markdown

@balav08 balav08 commented May 18, 2026

Reason for change: gdialserver not compatible with Libsoup3 library Updating gssdp to 1.6.3 provides libsoup3 compatibility . Test Procedure: Compiled and Verified
Risks: Low
Priority: P1
version: minor

Reason for change: gdialserver not compatible with Libsoup3 library
Updating gssdp to 1.6.3 provides libsoup3 compatibility .
Test Procedure: Compiled and Verified
Risks: Low
Priority: P1
version: minor
Signed-off-by: balaji velmurugan <balaji_velmurugan@comcast.com>
Copilot AI review requested due to automatic review settings May 18, 2026 06:03
@balav08 balav08 requested a review from a team as a code owner May 18, 2026 06:03
@rdkcmf-jenkins
Copy link
Copy Markdown
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 2 files pending identification.

  • Protex Server Path: /home/blackduck/github/xdialserver/202/rdkcentral/xdialserver

  • Commit: 190ac9a

Report detail: gist'

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make gdialserver compatible with libsoup 3 by updating dependency selection (gssdp 1.6+) and introducing libsoup-version-specific server sources.

Changes:

  • Add libsoup3-aware code paths in gdialservice.cpp and update build-time detection/defines in CMake.
  • Split REST/SSDP/Shield implementations into separate libsoup 2.4 and libsoup 3.0 C source variants.
  • Adjust runtime behavior around server lifecycle (attempted onStopped notification).

Reviewed changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
server/gdialservice.cpp Adds libsoup3 handler signature support and attempts to add a stop notification callback.
server/CMakeLists.txt Detects libsoup3 + gssdp 1.6 and selects libsoup-version-specific source files.
server/3.0/gdial-rest.c New libsoup3 REST server implementation.
server/3.0/gdial-ssdp.c New libsoup3 SSDP implementation.
server/3.0/gdial-shield.c New libsoup3 “shield” (throttle/timeout) implementation.
server/2.4/gdial-rest.c New libsoup2.4 REST server implementation (moved/split).
server/2.4/gdial-ssdp.c New libsoup2.4 SSDP implementation (moved/split).
server/2.4/gdial-shield.c New libsoup2.4 “shield” implementation (moved/split).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/CMakeLists.txt
Comment on lines +86 to +105
if (LIBSOUP3_FOUND)
set (GDIAL_EXEC_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/gdial-util.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-app.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/3.0/gdial-rest.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/3.0/gdial-ssdp.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/3.0/gdial-shield.c
${CMAKE_CURRENT_SOURCE_DIR}/gdialservice.cpp
)
message("Using libsoup-3.0 compatible source files (gdial1p6-*.c)")
else()
set (GDIAL_EXEC_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/gdial-util.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-app.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/2.4/gdial-rest.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/2.4/gdial-ssdp.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/2.4/gdial-shield.c
${CMAKE_CURRENT_SOURCE_DIR}/gdialservice.cpp
)
message("Using libsoup-2.4 compatible source files (gdial-*.c)")
Comment thread server/CMakeLists.txt
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")
Comment thread server/gdialservice.cpp Outdated
}
}
_instance->m_gdialserver_response_handler_thread = 0;
_instance->m_observer->onStopped();
Comment thread server/gdialservice.cpp Outdated
Comment on lines +1237 to +1241
void gdialServiceImpl::onStopped()
{
//
}

Comment thread server/3.0/gdial-rest.c
Comment on lines +460 to +466
if (new_app_instance) {
gchar *additional_data_url = NULL;
if (app_registry->use_additional_data) {
additional_data_url = gdial_rest_server_new_additional_data_url(listening_port, app_registry->name, FALSE, app_registry->app_uri );
}
gchar *additional_data_url_safe = g_uri_escape_string(additional_data_url, NULL, FALSE);
GDIAL_LOGINFO("additionalDataUrl = %s, %s", additional_data_url, additional_data_url_safe);
Comment thread server/3.0/gdial-rest.c
Comment on lines +474 to +501
char *tmp = g_uri_escape_string(query_str, NULL, FALSE);
// note that we later g_free(query_str_safe) which doesn't necessarily work with malloc'ed memory (seems to depend on glib version)
query_str_safe = g_strdup(tmp);
free(tmp);
}
else {
query_str_safe = g_strdup(query_str);
}
}
const gchar *payload = request_body->data;
gchar *payload_safe = NULL;
if (payload && strlen(payload)) {
if (g_str_has_prefix(app->name, "YouTube")) {
/* temporary disabling encoding payload for YouTube till cloud side changed*/
payload_safe = g_strdup(payload);
}
else {
char *tmp = g_uri_escape_string(payload, "=&", FALSE);
// note that we later g_free(payload_safe) which doesn't necessarily work with malloc'ed memory (seems to depend on glib version)
payload_safe = g_strdup(tmp);
free(tmp);
}
}
start_error = gdial_app_start(app, payload_safe, query_str_safe, additional_data_url_safe, gdial_rest_server);
if (query_str_safe) g_free(query_str_safe);
if (payload_safe) g_free(payload_safe);
free(additional_data_url_safe);
g_free(additional_data_url);
Comment thread server/3.0/gdial-shield.c
Comment on lines +35 to +73
static void soup_message_weak_ref_callback(gpointer user_data, GObject *obj);
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);
if (conn_context) {
conn_context->read_timeout_source = 0;
g_socket_close(conn_context->read_gsocket, NULL);//this will trigger abort callback
}
GDIAL_LOGTRACE("Exiting ...");
return G_SOURCE_REMOVE;;
}


static void server_request_read_callback (SoupServer *server, SoupServerMessage *msg,
gpointer data) {
GDIAL_LOGTRACE("Entering ...");
g_print_with_timestamp("server_request_read_callback tid=[%lx] msg=%p", pthread_self(), msg);
g_object_weak_unref(G_OBJECT(msg), (GWeakNotify)soup_message_weak_ref_callback, msg);
server_request_remove_callback(msg);
GDIAL_LOGTRACE("Exiting ...");
}
Comment thread server/3.0/gdial-ssdp.c
pthread_mutex_lock(&ssdpServerEventSync);
if (ssdp_http_server_)
{
soup_server_remove_handler(ssdp_http_server_, "/dd.xml");
Copilot AI review requested due to automatic review settings May 18, 2026 06:10
@rdkcmf-jenkins
Copy link
Copy Markdown
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 2 files pending identification.

  • Protex Server Path: /home/blackduck/github/xdialserver/202/rdkcentral/xdialserver

  • Commit: 2dba0ec

Report detail: gist'

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 8 changed files in this pull request and generated 8 comments.

Comments suppressed due to low confidence (1)

server/3.0/gdial-rest.c:501

  • Memory management: g_uri_escape_string() returns memory that must be released with g_free(), but this code uses free() for tmp and additional_data_url_safe. Mixing allocators can cause heap issues on platforms where GLib uses a different allocator. Replace free() with g_free() for these strings.
    GDIAL_LOGINFO("query = %s", query_str);
      if (!use_query_directly_from_soup) {
        char *tmp = g_uri_escape_string(query_str, NULL, FALSE);
        // note that we later g_free(query_str_safe) which doesn't necessarily work with malloc'ed memory (seems to depend on glib version)
        query_str_safe = g_strdup(tmp);
        free(tmp);
      }
      else {
        query_str_safe = g_strdup(query_str);
      }
    }
    const gchar *payload = request_body->data;
    gchar *payload_safe = NULL;
    if (payload && strlen(payload)) {
      if (g_str_has_prefix(app->name, "YouTube")) {
        /* temporary disabling encoding payload for YouTube till cloud side changed*/
        payload_safe = g_strdup(payload);
      }
      else {
        char *tmp = g_uri_escape_string(payload, "=&", FALSE);
        // note that we later g_free(payload_safe) which doesn't necessarily work with malloc'ed memory (seems to depend on glib version)
        payload_safe = g_strdup(tmp);
        free(tmp);
      }
    }
    start_error = gdial_app_start(app, payload_safe, query_str_safe, additional_data_url_safe, gdial_rest_server);
    if (query_str_safe) g_free(query_str_safe);
    if (payload_safe) g_free(payload_safe);
    free(additional_data_url_safe);
    g_free(additional_data_url);

Comment thread server/CMakeLists.txt
Comment on lines +86 to +103
if (LIBSOUP3_FOUND)
set (GDIAL_EXEC_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/gdial-util.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-app.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/3.0/gdial-rest.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/3.0/gdial-ssdp.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/3.0/gdial-shield.c
${CMAKE_CURRENT_SOURCE_DIR}/gdialservice.cpp
)
message("Using libsoup-3.0 compatible source files (gdial1p6-*.c)")
else()
set (GDIAL_EXEC_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/gdial-util.c
${CMAKE_CURRENT_SOURCE_DIR}/gdial-app.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/2.4/gdial-rest.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/2.4/gdial-ssdp.c
${CMAKE_CURRENT_SOURCE_DIR}/libsoup/2.4/gdial-shield.c
${CMAKE_CURRENT_SOURCE_DIR}/gdialservice.cpp
Comment thread server/CMakeLists.txt
Comment on lines +32 to +37
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()
Comment thread server/3.0/gdial-shield.c
Comment on lines +35 to +72
static void soup_message_weak_ref_callback(gpointer user_data, GObject *obj);
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);
if (conn_context) {
conn_context->read_timeout_source = 0;
g_socket_close(conn_context->read_gsocket, NULL);//this will trigger abort callback
}
GDIAL_LOGTRACE("Exiting ...");
return G_SOURCE_REMOVE;;
}


static void server_request_read_callback (SoupServer *server, SoupServerMessage *msg,
gpointer data) {
GDIAL_LOGTRACE("Entering ...");
g_print_with_timestamp("server_request_read_callback tid=[%lx] msg=%p", pthread_self(), msg);
g_object_weak_unref(G_OBJECT(msg), (GWeakNotify)soup_message_weak_ref_callback, msg);
server_request_remove_callback(msg);
GDIAL_LOGTRACE("Exiting ...");
Comment thread server/3.0/gdial-ssdp.c
Comment on lines +84 to +90
* /dd.xml only supports GET
*/
if (!msg || !soup_server_message_get_method(msg) || soup_server_message_get_method(msg) != SOUP_METHOD_GET) {
soup_server_message_set_status(msg, SOUP_STATUS_BAD_REQUEST, NULL);
GDIAL_CHECK("GET_method_only");
GDIAL_DEBUG("warning: SSDP HTTP Method is not GET");
return;
Comment thread server/3.0/gdial-ssdp.c
Comment on lines +248 to +264
g_object_ref(ssdp_http_server);
ssdp_http_server_ = ssdp_http_server;
app_random_uuid = g_strdup(random_uuid);
gchar *dail_ssdp_handler = g_strdup_printf("/%s/%s", random_uuid,"dd.xml");
soup_server_add_handler(ssdp_http_server_, dail_ssdp_handler, ssdp_http_server_callback, NULL, NULL);
ssdp_client_ = ssdp_client;

return 0;
}

int gdial_ssdp_destroy() {
GDIAL_LOGTRACE("Entering ...");
pthread_mutex_lock(&ssdpServerEventSync);
if (ssdp_http_server_)
{
soup_server_remove_handler(ssdp_http_server_, "/dd.xml");
}
Comment thread server/3.0/gdial-rest.c
Comment on lines +460 to +466
if (new_app_instance) {
gchar *additional_data_url = NULL;
if (app_registry->use_additional_data) {
additional_data_url = gdial_rest_server_new_additional_data_url(listening_port, app_registry->name, FALSE, app_registry->app_uri );
}
gchar *additional_data_url_safe = g_uri_escape_string(additional_data_url, NULL, FALSE);
GDIAL_LOGINFO("additionalDataUrl = %s, %s", additional_data_url, additional_data_url_safe);
Comment thread server/3.0/gdial-rest.c
Comment on lines +687 to +701
GDialRestServer *gdial_rest_server = (GDIAL_REST_SERVER(user_data));

if (soup_server_message_get_method(msg) == SOUP_METHOD_DELETE) {
/*
* Stop Server
*/
g_signal_emit(gdial_rest_server, gdial_rest_server_signals[SIGNAL_GMAINLOOP_QUIT], 0, "stop rest http gmainloop");
}
else if (soup_server_message_get_method(msg) == SOUP_METHOD_PUT) {
gchar *value = g_hash_table_lookup(query,"rest_enable");
g_print_with_timestamp("gdial_rest_http_server_system_callback emit SIGNAL_REST_ENABLE value:%s ",(gchar *)value);
g_signal_emit(gdial_rest_server, gdial_rest_server_signals[SIGNAL_REST_ENABLE], 0,value);
}
soup_server_message_set_status(msg, SOUP_STATUS_OK, NULL);
}
Comment thread server/3.0/gdial-rest.c
}
else {
GDIAL_LOGINFO("clear [%s] dial_data", app_name);
GHashTable* empty = g_hash_table_new(NULL, NULL);
@balav08 balav08 closed this May 18, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants