From 8871dfd2490f04e319ce6465fd2a7a8b2c78a6de Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Fri, 23 Sep 2022 12:44:52 -0700 Subject: [PATCH] Use pthread instead of upnp ithread which seems to be deprecated. Fixes #254 --- src/main.c | 2 +- src/upnp_connmgr.c | 4 ++-- src/upnp_control.c | 8 ++++---- src/upnp_device.c | 30 +++++++++++++++--------------- src/upnp_renderer.c | 2 +- src/upnp_service.c | 2 +- src/upnp_service.h | 4 ++-- src/upnp_transport.c | 8 ++++---- src/webserver.c | 2 +- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main.c b/src/main.c index 2030c49..5356205 100644 --- a/src/main.c +++ b/src/main.c @@ -43,7 +43,7 @@ #endif #include -#include +#include // For version strings of upnp and gstreamer #include diff --git a/src/upnp_connmgr.c b/src/upnp_connmgr.c index 52db333..73bc809 100644 --- a/src/upnp_connmgr.c +++ b/src/upnp_connmgr.c @@ -32,7 +32,7 @@ #include #include -#include +#include // Can't include above upnp.h breaks stdbool? #include @@ -141,7 +141,7 @@ static const char *direction_values[] = { NULL }; -static ithread_mutex_t connmgr_mutex; +static pthread_mutex_t connmgr_mutex; static GSList* supported_types_list; diff --git a/src/upnp_control.c b/src/upnp_control.c index e43ddb7..9ab30df 100644 --- a/src/upnp_control.c +++ b/src/upnp_control.c @@ -38,7 +38,7 @@ #include #include -#include +#include #include "logging.h" #include "webserver.h" @@ -178,11 +178,11 @@ typedef enum { static variable_container_t *state_variables_ = NULL; -static ithread_mutex_t control_mutex; +static pthread_mutex_t control_mutex; static void service_lock(void) { - ithread_mutex_lock(&control_mutex); + pthread_mutex_lock(&control_mutex); struct upnp_last_change_collector* collector = upnp_control_get_service()->last_change; if (collector) { @@ -197,7 +197,7 @@ static void service_unlock(void) if (collector) { UPnPLastChangeCollector_finish(collector); } - ithread_mutex_unlock(&control_mutex); + pthread_mutex_unlock(&control_mutex); } static struct argument arguments_list_presets[] = { diff --git a/src/upnp_device.c b/src/upnp_device.c index 3151238..c027431 100644 --- a/src/upnp_device.c +++ b/src/upnp_device.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include "logging.h" @@ -56,7 +56,7 @@ struct upnp_device { struct upnp_device_descriptor *upnp_device_descriptor; - ithread_mutex_t device_mutex; + pthread_mutex_t device_mutex; UpnpDevice_Handle device_handle; }; @@ -98,13 +98,13 @@ void upnp_append_variable(struct action_event *event, assert(event != NULL); assert(paramname != NULL); - ithread_mutex_lock(service->service_mutex); + pthread_mutex_lock(service->service_mutex); value = VariableContainer_get(service->variable_container, varnum, NULL); assert(value != NULL); // triggers on invalid variable. upnp_add_response(event, paramname, value); - ithread_mutex_unlock(service->service_mutex); + pthread_mutex_unlock(service->service_mutex); } void upnp_set_error(struct action_event *event, int error_code, @@ -180,7 +180,7 @@ static int handle_subscription_request(struct upnp_device *priv, } int result = -1; - ithread_mutex_lock(&(priv->device_mutex)); + pthread_mutex_lock(&(priv->device_mutex)); // There is really only one variable evented: LastChange const char *eventvar_names[] = { @@ -193,7 +193,7 @@ static int handle_subscription_request(struct upnp_device *priv, // Build the current state of the variables as one gigantic initial // LastChange update. - ithread_mutex_lock(srv->service_mutex); + pthread_mutex_lock(srv->service_mutex); const int var_count = VariableContainer_get_num_vars(srv->variable_container); // TODO(hzeller): maybe use srv->last_change directly ? @@ -209,7 +209,7 @@ static int handle_subscription_request(struct upnp_device *priv, UPnPLastChangeBuilder_add(builder, name, value); } } - ithread_mutex_unlock(srv->service_mutex); + pthread_mutex_unlock(srv->service_mutex); char *xml_value = UPnPLastChangeBuilder_to_xml(builder); Log_info("upnp", "Initial variable sync: %s", xml_value); eventvar_values[0] = xmlescape(xml_value, 0); @@ -227,7 +227,7 @@ static int handle_subscription_request(struct upnp_device *priv, UpnpGetErrorMessage(rc), rc); } - ithread_mutex_unlock(&(priv->device_mutex)); + pthread_mutex_unlock(&(priv->device_mutex)); free((char*)eventvar_values[0]); @@ -258,7 +258,7 @@ static int handle_var_request(struct upnp_device *priv, return -1; } - ithread_mutex_lock(srv->service_mutex); + pthread_mutex_lock(srv->service_mutex); char *result = NULL; const int var_count = @@ -273,7 +273,7 @@ static int handle_var_request(struct upnp_device *priv, } } - ithread_mutex_unlock(srv->service_mutex); + pthread_mutex_unlock(srv->service_mutex); UpnpStateVarRequest_set_CurrentVal(event, result); int errCode = (result == NULL) ? UPNP_SOAP_E_INVALID_VAR : UPNP_E_SUCCESS; @@ -314,9 +314,9 @@ static int handle_action_request(struct upnp_device *priv, // It would be good to enqueue the upnp_device_notify() after // the action event is finished. if (event_service->last_change) { - ithread_mutex_lock(event_service->service_mutex); + pthread_mutex_lock(event_service->service_mutex); UPnPLastChangeCollector_start(event_service->last_change); - ithread_mutex_unlock(event_service->service_mutex); + pthread_mutex_unlock(event_service->service_mutex); } #ifdef ENABLE_ACTION_LOGGING @@ -383,9 +383,9 @@ static int handle_action_request(struct upnp_device *priv, } if (event_service->last_change) { // See comment above. - ithread_mutex_lock(event_service->service_mutex); + pthread_mutex_lock(event_service->service_mutex); UPnPLastChangeCollector_finish(event_service->last_change); - ithread_mutex_unlock(event_service->service_mutex); + pthread_mutex_unlock(event_service->service_mutex); } return 0; } @@ -502,7 +502,7 @@ struct upnp_device *upnp_device_init(struct upnp_device_descriptor *device_def, struct upnp_device *result_device = (struct upnp_device*)malloc(sizeof(*result_device)); result_device->upnp_device_descriptor = device_def; - ithread_mutex_init(&(result_device->device_mutex), NULL); + pthread_mutex_init(&(result_device->device_mutex), NULL); /* register icons in web server */ for (int i = 0; (icon_entry = device_def->icons[i]); i++) { diff --git a/src/upnp_renderer.c b/src/upnp_renderer.c index 130df7b..5314d1c 100644 --- a/src/upnp_renderer.c +++ b/src/upnp_renderer.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include "webserver.h" #include "upnp_service.h" diff --git a/src/upnp_service.c b/src/upnp_service.c index fdfab84..4a31b99 100644 --- a/src/upnp_service.c +++ b/src/upnp_service.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include "xmldoc.h" #include "upnp_service.h" diff --git a/src/upnp_service.h b/src/upnp_service.h index c70bc43..46d07d7 100644 --- a/src/upnp_service.h +++ b/src/upnp_service.h @@ -25,7 +25,7 @@ #define _UPNP_SERVICE_H #include -#include +#include #include "upnp_compat.h" struct action; @@ -91,7 +91,7 @@ struct icon { }; struct service { - ithread_mutex_t *service_mutex; + pthread_mutex_t *service_mutex; const char *service_id; const char *service_type; const char *scpd_url; diff --git a/src/upnp_transport.c b/src/upnp_transport.c index 1f7a039..558ff5e 100644 --- a/src/upnp_transport.c +++ b/src/upnp_transport.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include "output.h" #include "upnp_service.h" @@ -406,11 +406,11 @@ static variable_container_t *state_variables_ = NULL; /* protects transport_values, and service-specific state */ -static ithread_mutex_t transport_mutex; +static pthread_mutex_t transport_mutex; static void service_lock(void) { - ithread_mutex_lock(&transport_mutex); + pthread_mutex_lock(&transport_mutex); struct upnp_last_change_collector * collector = upnp_transport_get_service()->last_change; @@ -426,7 +426,7 @@ static void service_unlock(void) if (collector) { UPnPLastChangeCollector_finish(collector); } - ithread_mutex_unlock(&transport_mutex); + pthread_mutex_unlock(&transport_mutex); } static char has_instance_id(struct action_event *event) diff --git a/src/webserver.c b/src/webserver.c index 3ce3804..dd79858 100644 --- a/src/webserver.c +++ b/src/webserver.c @@ -37,7 +37,7 @@ #include #include // UpnpGetErrorMessage -#include +#include #include "logging.h" #include "webserver.h"