Diff for /libaitsess/src/sess.c between versions 1.5 and 1.5.4.1

version 1.5, 2012/07/22 22:13:48 version 1.5.4.1, 2013/01/17 13:10:49
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 44  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF TH Line 44  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF TH
 SUCH DAMAGE.  SUCH DAMAGE.
 */  */
 #include "global.h"  #include "global.h"
 #include "aitsess.h"  
   
   
 /*  /*
Line 63  sess_FreeValues(char *** __restrict ppsVals) Line 62  sess_FreeValues(char *** __restrict ppsVals)
                 return;                  return;
   
         for (ptr = *ppsVals; *ptr; ptr++)          for (ptr = *ppsVals; *ptr; ptr++)
                io_free(*ptr);                e_free(*ptr);
        io_free(*ppsVals);        e_free(*ppsVals);
         *ppsVals = NULL;          *ppsVals = NULL;
 }  }
   
Line 84  sess_GetValues(ait_sess_t * __restrict s, char ***ppsV Line 83  sess_GetValues(ait_sess_t * __restrict s, char ***ppsV
   
         if (!s || !ppsVals)          if (!s || !ppsVals)
                 return -1;                  return -1;
        valz = io_malloc(sizeof(caddr_t));        valz = e_malloc(sizeof(caddr_t));
         if (!valz) {          if (!valz) {
                 LOGERR;                  LOGERR;
                 return -1;                  return -1;
Line 92  sess_GetValues(ait_sess_t * __restrict s, char ***ppsV Line 91  sess_GetValues(ait_sess_t * __restrict s, char ***ppsV
                 *valz = NULL;                  *valz = NULL;
   
         // allocated memory & mirrored shared memory into this          // allocated memory & mirrored shared memory into this
        Shared = io_malloc(s->eom);        Shared = e_malloc(s->eom);
         if (!Shared) {          if (!Shared) {
                 LOGERR;                  LOGERR;
                io_free(valz);                e_free(valz);
                 return -1;                  return -1;
         } else          } else
                 memcpy(Shared, s->addr, s->eom);                  memcpy(Shared, s->addr, s->eom);
Line 107  sess_GetValues(ait_sess_t * __restrict s, char ***ppsV Line 106  sess_GetValues(ait_sess_t * __restrict s, char ***ppsV
                 else                  else
                         i++;                          i++;
   
                valz = io_realloc(valz, (i + 1) * sizeof(caddr_t));                valz = e_realloc(valz, (i + 1) * sizeof(caddr_t));
                 if (!valz) {                  if (!valz) {
                         LOGERR;                          LOGERR;
                        io_free(Shared);                        e_free(Shared);
                         return -1;                          return -1;
                 } else                  } else
                         valz[i] = NULL;                          valz[i] = NULL;
   
                valz[i - 1] = io_strdup(peer);                valz[i - 1] = e_strdup(peer);
         }          }
   
        io_free(Shared);        e_free(Shared);
         *ppsVals = valz;          *ppsVals = valz;
         return i;          return i;
 }  }
Line 151  sess_GetValue(ait_sess_t * __restrict s, const char *c Line 150  sess_GetValue(ait_sess_t * __restrict s, const char *c
         }          }
   
         // allocated memory & mirrored shared memory into this          // allocated memory & mirrored shared memory into this
        Shared = io_malloc(s->eom);        Shared = e_malloc(s->eom);
         if (!Shared) {          if (!Shared) {
                 LOGERR;                  LOGERR;
                 return -1;                  return -1;
Line 171  sess_GetValue(ait_sess_t * __restrict s, const char *c Line 170  sess_GetValue(ait_sess_t * __restrict s, const char *c
                         } else                          } else
                                 def = IS_DEF;                                  def = IS_DEF;
   
                        io_free(Shared);                        e_free(Shared);
                         return i | def;                          return i | def;
                 }                  }
         }          }
   
        io_free(Shared);        e_free(Shared);
         return 0;          return 0;
 }  }
   
Line 203  sess_DelValue(ait_sess_t * __restrict s, const char *c Line 202  sess_DelValue(ait_sess_t * __restrict s, const char *c
         strlcpy(szAttr, csAttr, sizeof szAttr);          strlcpy(szAttr, csAttr, sizeof szAttr);
         strlcat(szAttr, "=", sizeof szAttr);          strlcat(szAttr, "=", sizeof szAttr);
   
        Buffer = io_malloc(s->eom);        Buffer = e_malloc(s->eom);
         if (!Buffer) {          if (!Buffer) {
                 LOGERR;                  LOGERR;
                 return -1;                  return -1;
         } else          } else
                 memset(Buffer, 0, s->eom);                  memset(Buffer, 0, s->eom);
        Shared = io_malloc(s->eom);        Shared = e_malloc(s->eom);
         if (!Shared) {          if (!Shared) {
                 LOGERR;                  LOGERR;
                io_free(Buffer);                e_free(Buffer);
                 return -1;                  return -1;
         } else {          } else {
                 DEC_SEM(s);                  DEC_SEM(s);
Line 236  sess_DelValue(ait_sess_t * __restrict s, const char *c Line 235  sess_DelValue(ait_sess_t * __restrict s, const char *c
                 msync(s->addr, 0, MS_SYNC | MS_INVALIDATE);                  msync(s->addr, 0, MS_SYNC | MS_INVALIDATE);
   
         INC_SEM(s);          INC_SEM(s);
        io_free(Shared);        e_free(Shared);
        io_free(Buffer);        e_free(Buffer);
         return 0;          return 0;
 }  }
   
Line 265  sess_SetValue(ait_sess_t * __restrict s, const char *c Line 264  sess_SetValue(ait_sess_t * __restrict s, const char *c
         strlcpy(szAttr, csAttr, sizeof szAttr);          strlcpy(szAttr, csAttr, sizeof szAttr);
         strlcat(szAttr, "=", sizeof szAttr);          strlcat(szAttr, "=", sizeof szAttr);
   
        Buffer = io_malloc(s->eom);        Buffer = e_malloc(s->eom);
         if (!Buffer) {          if (!Buffer) {
                 LOGERR;                  LOGERR;
                 return -1;                  return -1;
         } else          } else
                 memset(Buffer, 0, s->eom);                  memset(Buffer, 0, s->eom);
        Shared = io_malloc(s->eom);        Shared = e_malloc(s->eom);
         if (!Shared) {          if (!Shared) {
                 LOGERR;                  LOGERR;
                io_free(Buffer);                e_free(Buffer);
                 return -1;                  return -1;
         } else {          } else {
                 DEC_SEM(s);                  DEC_SEM(s);
Line 320  sess_SetValue(ait_sess_t * __restrict s, const char *c Line 319  sess_SetValue(ait_sess_t * __restrict s, const char *c
                 msync(s->addr, 0, MS_SYNC | MS_INVALIDATE);                  msync(s->addr, 0, MS_SYNC | MS_INVALIDATE);
   
         INC_SEM(s);          INC_SEM(s);
        io_free(Shared);        e_free(Shared);
        io_free(Buffer);        e_free(Buffer);
         return upd | def;          return upd | def;
 }  }
   
Line 364  sess_prepareSession(ait_sess_t * __restrict s, char us Line 363  sess_prepareSession(ait_sess_t * __restrict s, char us
   
         DEC_SEM(s);          DEC_SEM(s);
         s->zcpy = useDirect;          s->zcpy = useDirect;
        arr = io_map2vars(s->addr + sizeof(sess_hdr_t), s->eom - sizeof(sess_hdr_t),         arr = ait_map2vars(s->addr + sizeof(sess_hdr_t), s->eom - sizeof(sess_hdr_t), 
                         hdr->hdr_argc, useDirect);                          hdr->hdr_argc, useDirect);
         INC_SEM(s);          INC_SEM(s);
   
Line 390  sess_doneSession(ait_sess_t * __restrict s, array_t ** Line 389  sess_doneSession(ait_sess_t * __restrict s, array_t **
         }          }
   
         if (!s->zcpy)          if (!s->zcpy)
                io_arrayFree(*arr);                array_Free(*arr);
         else          else
                 DETACH_MEMORY(s);                  DETACH_MEMORY(s);
        io_arrayDestroy(arr);        array_Destroy(arr);
 }  }
   
 /*  /*
Line 423  sess_commitSession(ait_sess_t * __restrict s, array_t  Line 422  sess_commitSession(ait_sess_t * __restrict s, array_t 
                 hdr = (sess_hdr_t*) s->addr;                  hdr = (sess_hdr_t*) s->addr;
   
         DEC_SEM(s);          DEC_SEM(s);
        if ((ret = io_vars2map(s->addr + sizeof(sess_hdr_t), s->eom - sizeof(sess_hdr_t), arr)) != -1) {        if ((ret = ait_vars2map(s->addr + sizeof(sess_hdr_t), 
                                         s->eom - sizeof(sess_hdr_t), arr)) != -1) {
                 hdr->hdr_magic = SESS_AIT_MAGIC;                  hdr->hdr_magic = SESS_AIT_MAGIC;
                hdr->hdr_argc = io_arraySize(arr);                hdr->hdr_argc = array_Size(arr);
                 ret += sizeof(sess_hdr_t);                  ret += sizeof(sess_hdr_t);
         }          }
         INC_SEM(s);          INC_SEM(s);

Removed from v.1.5  
changed lines
  Added in v.1.5.4.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>