#include <glib.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <thread>
#include <type_traits>
#include <app_control_internal.h>
}
Instance::PostMessage(callback_data->instance, return_value.serialize().c_str());
- delete callback_data;
+ // Calling order of reply_callback and result_callback cannot be determined,
+ // thus callback_data is not released here - it is always
+ // released in result_callback with delay to prevent using a released memory.
};
}
Instance::PostMessage(callback_data->instance, callback_data->response->serialize().c_str());
- if (result.IsError() || (callback_data->reply_callback_id).empty()) {
+ // Calling order of reply_callback and result_callback cannot be determined,
+ // thus callback_data is released here with delay to prevent using a released
+ // memory in reply_callback function.
+ int timeout = 10;
+ std::thread([callback_data, timeout]() {
+ std::this_thread::sleep_for(std::chrono::seconds(timeout));
+ LoggerD("Deleting callback_data: %p", callback_data);
delete callback_data;
- }
+ }).detach();
};
/*
};
/*
- * TODO: Observe how often app_control_send_launch_request_async tries to launch the application.
+ * TODO: Observe how often app_control_send_resume_request tries to launch the application.
* Previous implementation, using synchronous app_control_send_launch_request,
* tries to launch the application 3 times, before reporting an error.
- * New implementation, using app_control_send_launch_request_async makes only one attempt.
+ * New implementation, using app_control_send_resume_request makes only one attempt.
* If problems, such as failed application start occur, multiple attempts may solve the problem.
*/
auto launch_result = TranslateLaunchError(static_cast<app_control_error_e>(