...
 
Commits (6)
......@@ -38,7 +38,9 @@
static struct ubus_context *ctx = NULL;
static pthread_t tid[1];
static pthread_t wfa_ubus_init;
static pthread_t wfa_collect ;
pthread_mutex_t wfa_delm_lock;
struct client_info cinfo;
......@@ -118,10 +120,8 @@ static int wfa_delm_ubus_init()
void *collect_wifi_data_elements(void *arg)
{
while(true) {
pthread_mutex_lock(&wfa_delm_lock);
syslog(LOG_ERR, "Calling populate wifi data");
populate_wifi_data_element_model();
pthread_mutex_unlock(&wfa_delm_lock);
sleep(POLLING_TIME);
}
......@@ -134,6 +134,17 @@ static void print_usage(const char * name) {
printf("\thelp\t: print this help and exit\n\n");
}
static void wfa_ubus_process(){
if (wfa_delm_ubus_init() < 0) {
syslog(LOG_ERR, "Failed to connect to ubus");
return 1;
}
uloop_run();
ubus_free(ctx);
}
int main(int argc, char * argv[]) {
const char * short_opt = "p:h";
const struct option long_opt[] = {
......@@ -165,26 +176,28 @@ int main(int argc, char * argv[]) {
exit(1);
}
if (wfa_delm_ubus_init() < 0) {
syslog(LOG_ERR, "Failed to connect to ubus");
int pt;
if ((pt = pthread_create(&wfa_ubus_init, NULL, &wfa_ubus_process, NULL ) != 0)) {
syslog(LOG_ERR, "Failed to create wfa_ubus_process thread");
return 1;
}
if (pthread_mutex_init(&wfa_delm_lock, NULL) != 0)
{
syslog(LOG_ERR, "Failed to initialize mutex");
if ((pt = pthread_create(&wfa_collect, NULL, &collect_wifi_data_elements, NULL) != 0)) {
syslog(LOG_ERR, "Failed to create wfa_collect_de thread");
return 1;
}
int pt;
if ((pt = pthread_create(&(tid[0]), NULL, &collect_wifi_data_elements, NULL) != 0)) {
syslog(LOG_ERR, "Failed to create thread");
void *retval;
pthread_join(wfa_ubus_init, &retval);
pthread_join(wfa_collect, &retval);
if (pthread_mutex_init(&wfa_delm_lock, NULL) != 0)
{
syslog(LOG_ERR, "Failed to initialize mutex");
return 1;
}
uloop_run();
pthread_mutex_destroy(&wfa_delm_lock);
ubus_free(ctx);
syslog(LOG_ERR, "Exiting program");
return 0;
......