static void response_cb2(void *data, void *event_info);
static int create_popup(struct appdata *ad);
static void sighandler(int signo);
+static void _wait_backend(pid_t pid);
static int __get_position_from_pkg_type(char *pkgtype);
static int __is_efl_tpk_app(char *pkgpath);
static int __xsystem(const char *argv[]);
return FALSE;
}
+static void _wait_backend(pid_t pid)
+{
+ int status;
+ pid_t cpid;
+ int i = 0;
+ backend_info *ptr = NULL;
+ ptr = begin;
+ cpid = waitpid(pid, &status, 0);
+ if (cpid != pid)
+ ERR("WaitBackend Faillure %d",cpid);
+ else if (WIFEXITED(status)) {
+ DBG("child NORMAL exit [%d]\n", cpid);
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (cpid == (ptr + i)->pid) {
+ __set_backend_free(i);
+ __set_backend_mode(i);
+ __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
+ DBG("clear the status of [%d] nb %d \n", cpid, i);
+
+ break;
+ }
+ else
+ DBG("PID of registered backend is [%d]\n", (ptr + i)->pid);
+
+ }
+ }
+ else if (WIFSIGNALED(status)) {
+ DBG("child SIGNALED exit [%d]\n", cpid);
+ /*get the pkgid and pkgtype to send fail signal*/
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (cpid == (ptr + i)->pid) {
+ __set_backend_free(i);
+ __set_backend_mode(i);
+ __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
+ strncpy(pname, (ptr + i)->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy(ptype, (ptr + i)->pkgtype, MAX_PKG_TYPE_LEN-1);
+ strncpy(args, (ptr + i)->args, MAX_PKG_ARGS_LEN-1);
+ g_idle_add(send_fail_signal, NULL);
+ break;
+ }
+ }
+ }
+}
+
+
static void sighandler(int signo)
{
int status;
__set_backend_free(i);
__set_backend_mode(i);
__unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
+ DBG("clear the status of [%d] nb %d \n", cpid, i);
+
break;
}
+ else
+ DBG("PID of registered backend is [%d]\n", (ptr + i)->pid);
+
}
}
else if (WIFSIGNALED(status)) {
else if (strstr(args, " -d ")
|| strstr(args, " '-d' ")) {
ad->op_type = OPERATION_UNINSTALL;
-
- /* 2011-04-01
- Change the mode temporarily. This should be removed */
- /*strncat(item->args, " -q",
- strlen(" -q"));*/
} else if (strstr(args, " -r ")
|| strstr(args, " '-r' "))
ad->op_type = OPERATION_REINSTALL;
if (err != 0) {
*ret = COMM_RET_ERROR;
DBG("create popup failed\n");
- /*queue_job(NULL);*/
goto err;
} else {
*ret = COMM_RET_OK;
backend_info *ptr = NULL;
ptr = begin;
int x = 0;
+ int pos = 0;
/* Pop a job from queue */
pop:
- if (!__is_backend_busy(pos % num_of_backends)) {
- item = _pm_queue_pop(pos % num_of_backends);
- pos = (pos + 1) % num_of_backends;
- }
- else {
- pos = (pos + 1) % num_of_backends;
- goto pop;
- }
+ if (!__is_backend_busy(pos % num_of_backends)) {
+ item = _pm_queue_pop(pos % num_of_backends);
+ pos = (pos + 1) % num_of_backends;
+ }
+ else {
+ pos = (pos + 1) % num_of_backends;
+ goto pop;
+ }
+
int ret = 0;
char *backend_cmd = NULL;
if ( (item == NULL) || (item->req_type == -1) ) {
if(item)
free(item);
- goto pop;
+ DBG("the queue is empty");
+ return FALSE;
}
__set_backend_busy((pos + num_of_backends - 1) % num_of_backends);
__set_recovery_mode(item->pkgid, item->pkg_type);
default: /* parent */
DBG("parent \n");
+ _wait_backend((ptr + x)->pid);
_save_queue_status(item, "done");
break;
}
default: /* parent */
DBG("parent exit\n");
+ _wait_backend((ptr + x)->pid);
_save_queue_status(item, "done");
break;
}
default: /* parent */
DBG("parent \n");
+ _wait_backend((ptr + x)->pid);
_save_queue_status(item, "done");
break;
}
default: /* parent */
DBG("parent \n");
+ _wait_backend((ptr + x)->pid);
_save_queue_status(item, "done");
break;
}
default: /* parent */
DBG("parent exit\n");
+ _wait_backend((ptr + x)->pid);
_save_queue_status(item, "done");
break;
}
static int __is_pkg_supported(char *pkgtype);
queue_info_map *start = NULL;
+pthread_mutex_t pm_mutex;
int entries = 0;
int slot = 0;
int num_of_backends = 0;
}
free(namelist);
num_of_backends = slot;
+ pthread_mutex_init(&pm_mutex, NULL);
+
#ifdef DEBUG_INFO
/*Debug info*/
printf("Queue Info Map\n");
ptr++;
}
#endif
+
return 0;
}
if (ret == 0)
return -1;
+ pthread_mutex_lock(&pm_mutex);
cur = __get_head_from_pkgtype(item);
tmp = cur;
data = _add_node();
if (!data) { /* fail to allocate mem */
fprintf(stderr, "Fail to allocate memory\n");
+ pthread_mutex_unlock(&pm_mutex);
return -1;
}
tmp->next = data;
}
+ pthread_mutex_unlock(&pm_mutex);
return 0;
}
pm_dbus_msg *ret;
pm_queue_data *cur = NULL;
pm_queue_data *saveptr = NULL;
- queue_info_map *ptr = start;
+ queue_info_map *ptr = NULL;
int i = 0;
ret = (pm_dbus_msg *) malloc(sizeof(pm_dbus_msg));
return NULL;
}
memset(ret, 0x00, sizeof(pm_dbus_msg));
-
+ pthread_mutex_lock(&pm_mutex);
+ ptr = start;
for(i = 0; i < entries; i++)
{
if (ptr->queue_slot == position) {
}
ptr++;
}
+ pthread_mutex_unlock(&pm_mutex);
return ret;
}