projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git]
/
resource
/
csdk
/
connectivity
/
src
/
bt_le_adapter
/
linux
/
peripheral.c
diff --git
a/resource/csdk/connectivity/src/bt_le_adapter/linux/peripheral.c
b/resource/csdk/connectivity/src/bt_le_adapter/linux/peripheral.c
index
9966198
..
6cd91ac
100644
(file)
--- a/
resource/csdk/connectivity/src/bt_le_adapter/linux/peripheral.c
+++ b/
resource/csdk/connectivity/src/bt_le_adapter/linux/peripheral.c
@@
-39,13
+39,13
@@
static CAPeripheralContext g_context = {
static bool CAPeripheralCheckStarted()
{
static bool CAPeripheralCheckStarted()
{
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
bool const started =
(g_context.event_loop != NULL
&& g_main_loop_is_running(g_context.event_loop));
bool const started =
(g_context.event_loop != NULL
&& g_main_loop_is_running(g_context.event_loop));
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
/**
* @todo Fix potential TOCTOU race condition. A peripheral could
/**
* @todo Fix potential TOCTOU race condition. A peripheral could
@@
-59,11
+59,11
@@
static bool CAPeripheralCheckStarted()
static bool CAPeripheralAdaptersFound(CALEContext * context)
{
// Check if BlueZ detected bluetooth hardware adapters.
static bool CAPeripheralAdaptersFound(CALEContext * context)
{
// Check if BlueZ detected bluetooth hardware adapters.
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
bool const found = (context->adapters != NULL);
bool const found = (context->adapters != NULL);
-
ca
_mutex_unlock(context->lock);
+
oc
_mutex_unlock(context->lock);
if (!found)
{
if (!found)
{
@@
-162,7
+162,7
@@
static bool CAPeripheralRegisterGattServices(
bool success = true;
bool success = true;
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
for (GList * l = context->gatt_services; l != NULL; l = l->next)
{
for (GList * l = context->gatt_services; l != NULL; l = l->next)
{
@@
-209,7
+209,7
@@
static bool CAPeripheralRegisterGattServices(
g_variant_unref(ret);
}
g_variant_unref(ret);
}
-
ca
_mutex_unlock(context->lock);
+
oc
_mutex_unlock(context->lock);
return success;
}
return success;
}
@@
-224,7
+224,7
@@
static bool CAPeripheralRegisterAdvertisements(
LE Advertisement Manager.
*/
LE Advertisement Manager.
*/
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
char const * const advertisement_path =
g_dbus_interface_skeleton_get_object_path(
char const * const advertisement_path =
g_dbus_interface_skeleton_get_object_path(
@@
-310,7
+310,7
@@
static bool CAPeripheralRegisterAdvertisements(
success = true;
}
success = true;
}
-
ca
_mutex_unlock(context->lock);
+
oc
_mutex_unlock(context->lock);
return success;
}
return success;
}
@@
-383,14
+383,14
@@
static CAResult_t CAPeripheralSetDiscoverability(
Synchronize access to the adapter information using the base
context lock since we don't own the adapter_infos.
*/
Synchronize access to the adapter information using the base
context lock since we don't own the adapter_infos.
*/
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
// Make all detected adapters discoverable.
g_list_foreach(context->adapters,
discoverability_func,
&result);
// Make all detected adapters discoverable.
g_list_foreach(context->adapters,
discoverability_func,
&result);
-
ca
_mutex_unlock(context->lock);
+
oc
_mutex_unlock(context->lock);
return result;
}
return result;
}
@@
-447,9
+447,9
@@
static void CAPeripheralOnNameLost(GDBusConnection * connection,
*/
static gboolean CAPeripheralEventLoopStarted(gpointer user_data)
{
*/
static gboolean CAPeripheralEventLoopStarted(gpointer user_data)
{
-
ca
_cond const condition = user_data;
+
oc
_cond const condition = user_data;
-
ca
_cond_signal(condition); // For service registration
+
oc
_cond_signal(condition); // For service registration
return G_SOURCE_REMOVE;
}
return G_SOURCE_REMOVE;
}
@@
-515,7
+515,7
@@
static void CAPeripheralStartEventLoop(void * data)
"manager interface.");
}
"manager interface.");
}
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
assert(g_context.event_loop == NULL);
g_context.event_loop = event_loop;
assert(g_context.event_loop == NULL);
g_context.event_loop = event_loop;
@@
-542,7
+542,7
@@
static void CAPeripheralStartEventLoop(void * data)
context->connection,
advertising_managers);
context->connection,
advertising_managers);
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
/*
Add an idle handler that notifies a thread waiting for the
/*
Add an idle handler that notifies a thread waiting for the
@@
-571,12
+571,12
@@
static void CAPeripheralStartEventLoop(void * data)
static void CAPeripheralStopEventLoop(CAPeripheralContext * context)
{
static void CAPeripheralStopEventLoop(CAPeripheralContext * context)
{
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
GMainLoop * const event_loop = context->event_loop;
context->event_loop = NULL;
GMainLoop * const event_loop = context->event_loop;
context->event_loop = NULL;
-
ca
_mutex_unlock(context->lock);
+
oc
_mutex_unlock(context->lock);
if (event_loop != NULL)
{
if (event_loop != NULL)
{
@@
-596,14
+596,14
@@
static void CAPeripheralStopEventLoop(CAPeripheralContext * context)
void CAPeripheralInitialize()
{
void CAPeripheralInitialize()
{
- g_context.lock =
ca
_mutex_new();
- g_context.condition =
ca
_cond_new();
+ g_context.lock =
oc
_mutex_new();
+ g_context.condition =
oc
_cond_new();
}
void CAPeripheralFinalize()
{
}
void CAPeripheralFinalize()
{
-
ca
_cond_free(g_context.condition);
-
ca
_mutex_free(g_context.lock);
+
oc
_cond_free(g_context.condition);
+
oc
_mutex_free(g_context.lock);
}
CAResult_t CAPeripheralStart(CALEContext * context)
}
CAResult_t CAPeripheralStart(CALEContext * context)
@@
-634,7
+634,7
@@
CAResult_t CAPeripheralStart(CALEContext * context)
*/
result = ca_thread_pool_add_task(context->server_thread_pool,
CAPeripheralStartEventLoop,
*/
result = ca_thread_pool_add_task(context->server_thread_pool,
CAPeripheralStartEventLoop,
- context);
+ context
, NULL
);
if (result != CA_STATUS_OK)
{
if (result != CA_STATUS_OK)
{
@@
-653,21
+653,21
@@
CAResult_t CAPeripheralStart(CALEContext * context)
static uint64_t const timeout =
2 * MICROSECS_PER_SEC; // Microseconds
static uint64_t const timeout =
2 * MICROSECS_PER_SEC; // Microseconds
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
for (int i = 0;
g_context.gatt_services == NULL && i < max_retries;
++i)
{
for (int i = 0;
g_context.gatt_services == NULL && i < max_retries;
++i)
{
- if (
ca
_cond_wait_for(g_context.condition,
+ if (
oc
_cond_wait_for(g_context.condition,
g_context.lock,
g_context.lock,
- timeout) ==
CA
_WAIT_SUCCESS)
+ timeout) ==
OC
_WAIT_SUCCESS)
{
result = CA_STATUS_OK;
}
}
{
result = CA_STATUS_OK;
}
}
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
if (result != CA_STATUS_OK)
{
if (result != CA_STATUS_OK)
{
@@
-718,7
+718,7
@@
CAResult_t CAPeripheralStop()
CAPeripheralStopEventLoop(&g_context);
CAPeripheralStopEventLoop(&g_context);
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
guint const owner_id = g_context.owner_id;
g_context.owner_id = 0;
guint const owner_id = g_context.owner_id;
g_context.owner_id = 0;
@@
-728,7
+728,7
@@
CAResult_t CAPeripheralStop()
g_context.base = NULL;
g_context.base = NULL;
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
CALEAdvertisementDestroy(&g_context.advertisement);
CALEAdvertisementDestroy(&g_context.advertisement);
@@
-741,9
+741,9
@@
CAResult_t CAPeripheralStop()
void CAPeripheralForEachService(GFunc func, void * user_data)
{
void CAPeripheralForEachService(GFunc func, void * user_data)
{
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
g_list_foreach(g_context.gatt_services, func, user_data);
g_list_foreach(g_context.gatt_services, func, user_data);
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
}
}