#include <unistd.h>
#include "sessiond.h"
-#define SESSION_UID 5001 // default Tizen's 'owner' uid
-const int firstUser = 1; // N.B. Starting from 1, as user number 0 is reserved
-const int lastUser = 10;
-const int noOfUsers = lastUser - firstUser + 1;
+static constexpr int SESSION_UID = 5001; // default Tizen's 'owner' uid
+
+static constexpr int firstUser = 1; // N.B. Starting from 1, as user number 0 is reserved
+static constexpr int lastUser = 10;
+static constexpr int noOfUsers = lastUser - firstUser + 1;
GMutex mutex;
volatile int callbackCount;
-GMainLoop *loop = nullptr;
typedef struct {
int callback_result;
// the array as 1-based, so we need to add 1 more element.
test_user_data userD[noOfUsers + 1];
-int callback_pending_reference;
+int callback_pending_reference = 0;
void test_subsession_switch_user_completion_callback(subsession_event_info info, void *cb_data)
{
gboolean callback_pending(gpointer data)
{
- GMainLoop *lp = (GMainLoop *)data;
+ GMainLoop *loop = (GMainLoop *)data;
gboolean is_pending = g_main_context_pending(NULL);
gint ctrl_value = g_atomic_int_get(&callback_pending_reference);
// N.B. There are `noOfUsers` add and remove operations. Each add/remove
// increments the value of the `callback_pending_reference` variable.
if (ctrl_value >= noOfUsers * 2)
- g_main_loop_quit(lp);
+ g_main_loop_quit(loop);
return TRUE;
}
int main(int argc, char *argv[])
{
- loop = g_main_loop_new(NULL, FALSE);
+ GMainLoop *loop = g_main_loop_new(NULL, FALSE);
g_mutex_init(&mutex);
std::thread g_main_loop_thread(g_main_loop_run, loop);
- g_atomic_int_set(&callback_pending_reference, 0);
///===================================///
printf("Test program start\nCreating test users...");