Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Sep 4, 2023
1 parent 83bd505 commit f48afb3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
9 changes: 3 additions & 6 deletions api/cloud/oc_cloud_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,20 @@ cloud_start_process(oc_cloud_context_t *ctx)
ctx->store.cps == OC_CPS_READYTOREGISTER) {
oc_reset_delayed_callback(ctx, cloud_manager_register_async,
g_retry_timeout[0]);
goto finish;
return;
}
if ((ctx->store.status & OC_CLOUD_REGISTERED) != 0) {
if (cloud_context_has_permanent_access_token(ctx)) {
oc_reset_delayed_callback(ctx, cloud_manager_login_async,
g_retry_timeout[0]);
goto finish;
return;
}
if (cloud_context_has_refresh_token(ctx)) {
oc_reset_delayed_callback(ctx, cloud_manager_refresh_token_async,
g_retry_timeout[0]);
goto finish;
return;
}
}

finish:
_oc_signal_event_loop();
}

static uint64_t
Expand Down
1 change: 0 additions & 1 deletion api/cloud/oc_cloud_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ cloud_store_dump_async(const oc_cloud_store_t *store)
// so this void* cast which drops const is safe
oc_remove_delayed_callback((void *)store, cloud_store_dump_handler);
oc_set_delayed_callback((void *)store, cloud_store_dump_handler, 0);
_oc_signal_event_loop();
}

static bool
Expand Down
2 changes: 0 additions & 2 deletions api/oc_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ oc_send_message(oc_message_t *message)
message) == OC_PROCESS_ERR_FULL) {
oc_message_unref(message);
}
_oc_signal_event_loop();
}

#ifdef OC_HAS_FEATURE_TCP_ASYNC_CONNECT
Expand All @@ -241,7 +240,6 @@ oc_tcp_connect_session(oc_tcp_on_connect_event_t *event)
event) == OC_PROCESS_ERR_FULL) {
oc_tcp_on_connect_event_free(event);
}
_oc_signal_event_loop();
}
#endif /* OC_HAS_FEATURE_TCP_ASYNC_CONNECT */

Expand Down
17 changes: 17 additions & 0 deletions api/oc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
#include "api/plgd/plgd_time_internal.h"
#endif /* OC_HAS_FEATURE_PLGD_TIME */

#if defined(OC_DEBUG) && defined(__linux__)
#include <pthread.h>
#endif /* OC_DEBUG && __linux__ */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -83,6 +86,10 @@ static bool g_initialized = false;
static const oc_handler_t *g_app_callbacks;
static oc_factory_presets_t g_factory_presets;

#if defined(OC_DEBUG) && defined(__linux__)
static pthread_t g_main_thread;
#endif /* OC_DEBUG && __linux__ */

void
oc_set_factory_presets_cb(oc_factory_presets_cb_t cb, void *data)
{
Expand Down Expand Up @@ -317,6 +324,10 @@ oc_main_init(const oc_handler_t *handler)
return 0;
}

#if defined(OC_DEBUG) && defined(__linux__)
g_main_thread = pthread_self();
#endif /* OC_DEBUG && __linux__ */

g_app_callbacks = handler;

#ifdef OC_MEMORY_TRACE
Expand Down Expand Up @@ -474,6 +485,12 @@ oc_main_initialized(void)
void
_oc_signal_event_loop(void)
{
#if defined(OC_DEBUG) && defined(__linux__)
if (pthread_equal(pthread_self(), g_main_thread)) {
oc_abort("_oc_signal_event_loop called from main thread");
}
#endif /* OC_DEBUG && __linux__ */

if (g_app_callbacks != NULL) {
g_app_callbacks->signal_event_loop();
}
Expand Down
4 changes: 4 additions & 0 deletions api/oc_network_events_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ OC_PROCESS_NAME(oc_network_events);
* @brief network receive event
*
* @param message the network message
*
* @note called from network thread
*/
void oc_network_receive_event(oc_message_t *message);

Expand All @@ -47,6 +49,8 @@ void oc_network_receive_event(oc_message_t *message);
* @brief network TCP connect event
*
* @param event the TCP on connect event
*
* @note called from network thread
*/
void oc_network_tcp_connect_event(oc_tcp_on_connect_event_t *event);
#endif /* OC_HAS_FEATURE_TCP_ASYNC_CONNECT */
Expand Down
1 change: 0 additions & 1 deletion messaging/coap/observe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,6 @@ static void
dispatch_process_batch_observers(void)
{
oc_reset_delayed_callback(NULL, &process_batch_observers_async, 0);
_oc_signal_event_loop();
}

static void
Expand Down
2 changes: 1 addition & 1 deletion tests/client_get_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ start_server(void)
return ret;
}

while (quit != true) {
while (!quit) {
oc_clock_time_t next_event_mt = oc_main_poll_v1();
pthread_mutex_lock(&mutex);
if (next_event_mt == 0) {
Expand Down

0 comments on commit f48afb3

Please sign in to comment.