mypid = (pid_t)app_pid;
////// DELETE SESSION TYPE /////////
- snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
+ snprintf(filename, sizeof(filename)-1, "/tmp/mm-session/mm_session_%d", mypid);
if (-1 == unlink(filename))
return MM_ERROR_FILE_NOT_FOUND;
////// DELETE SESSION TYPE /////////
mypid = (pid_t)app_pid;
////// WRITE SESSION TYPE /////////
- snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
+ snprintf(filename, sizeof(filename)-1, "/tmp/mm-session/mm_session_%d", mypid);
fd = open(filename, O_WRONLY | O_CREAT, 0644);
if (fd < 0) {
debug_error("open() failed with %d", errno);
}
sessiontype = sessiontype << 16;
write(fd, &sessiontype, sizeof(int));
- if (0 > fchmod(fd, 00777))
+ if (0 > fchmod(fd, 00666))
debug_error("fchmod failed with %d", errno);
else
- debug_warning("write sessiontype(%d) to /tmp/mm_session_%d", sessiontype >> 16, mypid);
+ debug_warning("write sessiontype(%d) to /tmp/mm-session/mm_session_%d", sessiontype >> 16, mypid);
close(fd);
////// WRITE SESSION TYPE /////////
mypid = (pid_t)app_pid;
////// READ SESSION TYPE /////////
- snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
+ snprintf(filename, sizeof(filename)-1, "/tmp/mm-session/mm_session_%d", mypid);
fd = open(filename, O_RDONLY);
if (fd < 0)
return MM_ERROR_INVALID_HANDLE;
if (read(fd, sessiontype, sizeof(int)) == sizeof(int)) {
*sessiontype = *sessiontype >> 16;
- debug_warning("read sessiontype(%d) from /tmp/mm_session_%d", *sessiontype, mypid);
+ debug_warning("read sessiontype(%d) from /tmp/mm-session/mm_session_%d", *sessiontype, mypid);
} else {
debug_error("failed to read from %s, errno %d", filename, errno);
result = MM_ERROR_INVALID_HANDLE;
mypid = (pid_t)app_pid;
////// WRITE SESSION INFO /////////
- snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
+ snprintf(filename, sizeof(filename)-1, "/tmp/mm-session/mm_session_%d", mypid);
fd = open(filename, O_WRONLY | O_CREAT, 0644);
if (fd < 0) {
debug_error("open() failed with %d", errno);
result_info = (flags) | (session_type << 16);
write(fd, &result_info, sizeof(int));
- if (0 > fchmod(fd, 00777))
+ if (0 > fchmod(fd, 00666))
debug_error("fchmod failed with %d", errno);
else
- debug_warning("write session information(%x) to /tmp/mm_session_%d", result_info, mypid);
+ debug_warning("write session information(%x) to /tmp/mm-session/mm_session_%d", result_info, mypid);
close(fd);
////// WRITE SESSION INFO /////////
mypid = (pid_t)app_pid;
////// READ SESSION INFO /////////
- snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
+ snprintf(filename, sizeof(filename)-1, "/tmp/mm-session/mm_session_%d", mypid);
fd = open(filename, O_RDONLY);
if (fd < 0)
return MM_ERROR_INVALID_HANDLE;
if (read(fd, &result_info, sizeof(int)) == sizeof(int)) {
*session_type = result_info >> 16;
*flags = result_info & 0x0000ffff;
- debug_warning("read session_type(%d), session_option(%x) from /tmp/mm_session_%d", *session_type, *flags, mypid);
+ debug_warning("read session_type(%d), session_option(%x) from /tmp/mm-session/mm_session_%d", *session_type, *flags, mypid);
} else {
debug_error("failed to read from %s, errno %d", filename, errno);
result = MM_ERROR_INVALID_HANDLE;
}
#endif
+static void _mm_session_util_clear_information(void)
+{
+ char filename[MAX_FILE_LENGTH] = {'\0',};
+ int pid = (int)getpid();
+
+ snprintf(filename, sizeof(filename)-1, "/tmp/mm-session/mm_session_%d", pid);
+
+ if (access(filename, F_OK) != 0)
+ return; /* nothing to clear */
+
+ debug_warning("[%s] exists...delete now!!!", filename);
+ if (unlink(filename) == -1)
+ debug_error("[%s] unlink failed, errno=%d", filename, errno);
+}
+
__attribute__ ((constructor))
void __mmsession_initialize(void)
{
debug_fenter();
+ _mm_session_util_clear_information();
+
#ifdef TIZEN_TV
if (_is_dotnet_app()) {
debug_warning("no signal handler for dotnet!!");