RDKEMW-6898: gdialserver not compatible with Libsoup3 library#202
Closed
balav08 wants to merge 2 commits into
Closed
RDKEMW-6898: gdialserver not compatible with Libsoup3 library#202balav08 wants to merge 2 commits into
balav08 wants to merge 2 commits into
Conversation
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>
Contributor
There was a problem hiding this comment.
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.cppand 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
onStoppednotification).
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 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)") |
| 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") |
| } | ||
| } | ||
| _instance->m_gdialserver_response_handler_thread = 0; | ||
| _instance->m_observer->onStopped(); |
Comment on lines
+1237
to
+1241
| void gdialServiceImpl::onStopped() | ||
| { | ||
| // | ||
| } | ||
|
|
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 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 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 ..."); | ||
| } |
| pthread_mutex_lock(&ssdpServerEventSync); | ||
| if (ssdp_http_server_) | ||
| { | ||
| soup_server_remove_handler(ssdp_http_server_, "/dd.xml"); |
Contributor
There was a problem hiding this comment.
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 withg_free(), but this code usesfree()fortmpandadditional_data_url_safe. Mixing allocators can cause heap issues on platforms where GLib uses a different allocator. Replacefree()withg_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 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 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 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 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 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 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 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); | ||
| } |
| } | ||
| else { | ||
| GDIAL_LOGINFO("clear [%s] dial_data", app_name); | ||
| GHashTable* empty = g_hash_table_new(NULL, NULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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