--- libaitsess/src/aitsess.c 2012/02/10 16:45:36 1.3.2.3 +++ libaitsess/src/aitsess.c 2012/02/10 17:14:21 1.3.2.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsess.c,v 1.3.2.3 2012/02/10 16:45:36 misho Exp $ +* $Id: aitsess.c,v 1.3.2.5 2012/02/10 17:14:21 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -116,8 +116,9 @@ sess_initSession(int id, const char *csFName, ait_sess } } memset(*Sess, 0, sizeof(ait_sess_t)); + strlcpy((*Sess)->name, csFName, sizeof (*Sess)->name); - h = open(csFName, O_WRONLY | O_CREAT | O_EXCL, MEM_MODE); + h = open((*Sess)->name, O_WRONLY | O_CREAT | O_EXCL, MEM_MODE); if (h == -1) { if (errno != EEXIST) { LOGERR; @@ -125,7 +126,7 @@ sess_initSession(int id, const char *csFName, ait_sess return -1; } /* If key file exist, session already connected */ - h = open(csFName, O_RDONLY); + h = open((*Sess)->name, O_RDONLY); if (h == -1) { LOGERR; free(*Sess); @@ -228,8 +229,8 @@ sess_freeSession(const char *csFName, ait_sess_t ** __ memset(&(*Sess)->sess, 0, sizeof (*Sess)->sess); (*Sess)->type = SHARED_UNKNOWN; - if (csFName) - unlink(csFName); + if (csFName && (*Sess)->name) + unlink((*Sess)->name); if (*Sess) free(*Sess); *Sess = NULL; @@ -566,13 +567,13 @@ map_isSemaphoreOK(ait_sess_t * __restrict s) } /* - * map_addSemaphore() MMAP unblock semaphore, increment semaphore + * map_incSemaphore() MMAP unblock semaphore, increment semaphore * * @s = Session item * return: 0 Ok, -1 error: can`t increment */ int -map_addSemaphore(ait_sess_t * __restrict s) +map_incSemaphore(ait_sess_t * __restrict s) { if (!s) return -1; @@ -628,13 +629,13 @@ ipc_isSemaphoreOK(ait_sess_t * __restrict s) } /* - * ipc_addSemaphore() IPC unblock semaphore, increment semaphore + * ipc_incSemaphore() IPC unblock semaphore, increment semaphore * * @s = Session item * return: 0 Ok, -1 error: can`t increment */ int -ipc_addSemaphore(ait_sess_t * __restrict s) +ipc_incSemaphore(ait_sess_t * __restrict s) { struct sembuf sb = { 0, 1, 0 };