*/
#define _GNU_SOURCE
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdbool.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/xattr.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <ctype.h>
#include <tzplatform_config.h>
#include <glib.h>
#include <vconf.h>
} app_pkt_header_t;
static int socket_timeout_initialized;
+static int socket_link_created;
+static char socket_link_path[108];
static struct timeval tv = { 5, 200 * 1000 }; /* 5.2 */
static int __create_socket_dir(int pid, uid_t uid)
{
- char path[PATH_MAX];
+ char path[108];
if (uid < REGULAR_UID_MIN)
snprintf(path, sizeof(path), "/run/aul/daemons/%d", uid);
static void __create_socket_link(const char *socket_path, int pid, uid_t uid)
{
- char path[PATH_MAX];
+ char path[108];
if (__create_socket_dir(pid, uid) < 0)
return;
else
_E("path(%s) - unknown create error", path);
}
+
+ snprintf(socket_link_path, sizeof(socket_link_path), "%s", path);
+ socket_link_created = 1;
}
API int aul_sock_create_server(int pid, uid_t uid)
"/run/aul/apps/%u/%d",
getuid(), getpid());
__delete_dir(path);
+
+ if (socket_link_created) {
+ __delete_dir(dirname(socket_link_path));
+ socket_link_created = 0;
+ }
} else {
snprintf(path, sizeof(path),
"/run/aul/daemons/%u/.app-sock-%d",
getuid(), getpid());
unlink(path);
+
+ if (socket_link_created) {
+ unlink(socket_link_path);
+ socket_link_created = 0;
+ }
}
return 0;