Changeset 6244

Show
Ignore:
Timestamp:
08/21/08 18:10:40 (3 months ago)
Author:
rbertholon
Message:

beginning of purge module

Location:
trunk/centstorage
Files:
2 added
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/centstorage/ChangeLog

    r6192 r6244  
    22 CentStorage ChangeLog 
    33######################### 
     4 
     5??? - 08/21/2008 
     6----------------- 
     7* begin to code the module purge 
     8* load the configuration of module purge 
    49 
    510??? - 08/20/2008 
  • trunk/centstorage/README

    r6174 r6244  
    3333connection between client and server. 
    3434 
    35 For the oracle support, you need to install Oracle Call Interface. You can find it  
     35For the oracle support, you need to install Oracle Call Interface. You can find it 
    3636on the oracle official website: 
    3737http://www.oracle.com/technology/software/tech/oci/instantclient/index.html 
     
    3939 
    4040the script configure can take some options in pramameter: 
    41 --with-<db>-inc=<path to your include files> => to specify the position of header  
     41--with-<db>-inc=<path to your include files> => to specify the position of header 
    4242files of the database you are using (<db> must be replace by mysql, pgsql or 
    4343oracle). By default, it should be something like /usr/include/<db>, so this option should'nt 
  • trunk/centstorage/modules/purge/Makefile

    r6209 r6244  
    6767binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 
    6868PROGRAMS = $(bin_PROGRAMS) 
    69 am_purge_so_OBJECTS = purge_so-purge.$(OBJEXT) 
     69am_purge_so_OBJECTS = purge_so-purge.$(OBJEXT) \ 
     70        purge_so-runPurge.$(OBJEXT) \ 
     71        purge_so-db_purge_connection.$(OBJEXT) 
    7072purge_so_OBJECTS = $(am_purge_so_OBJECTS) 
    7173purge_so_DEPENDENCIES = 
     
    185187top_builddir = ../.. 
    186188top_srcdir = ../.. 
    187 purge_so_SOURCES = purge.c      \ 
    188                                 \ 
    189                         purge.h 
     189purge_so_SOURCES = purge.c                      \ 
     190                        runPurge.c              \ 
     191                        db_purge_connection.c   \ 
     192                                                \ 
     193                        purge.h                 \ 
     194                        runPurge.h              \ 
     195                        db_purge_connection.h 
    190196 
    191197INCLUDES = -I. -I/usr/include/libxml -I../../includes 
     
    262268        -rm -f *.tab.c 
    263269 
     270include ./$(DEPDIR)/purge_so-db_purge_connection.Po 
    264271include ./$(DEPDIR)/purge_so-purge.Po 
     272include ./$(DEPDIR)/purge_so-runPurge.Po 
    265273 
    266274.c.o: 
     
    291299#       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 
    292300#       $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-purge.obj `if test -f 'purge.c'; then $(CYGPATH_W) 'purge.c'; else $(CYGPATH_W) '$(srcdir)/purge.c'; fi` 
     301 
     302purge_so-runPurge.o: runPurge.c 
     303        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-runPurge.o -MD -MP -MF $(DEPDIR)/purge_so-runPurge.Tpo -c -o purge_so-runPurge.o `test -f 'runPurge.c' || echo '$(srcdir)/'`runPurge.c 
     304        mv -f $(DEPDIR)/purge_so-runPurge.Tpo $(DEPDIR)/purge_so-runPurge.Po 
     305#       source='runPurge.c' object='purge_so-runPurge.o' libtool=no \ 
     306#       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 
     307#       $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-runPurge.o `test -f 'runPurge.c' || echo '$(srcdir)/'`runPurge.c 
     308 
     309purge_so-runPurge.obj: runPurge.c 
     310        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-runPurge.obj -MD -MP -MF $(DEPDIR)/purge_so-runPurge.Tpo -c -o purge_so-runPurge.obj `if test -f 'runPurge.c'; then $(CYGPATH_W) 'runPurge.c'; else $(CYGPATH_W) '$(srcdir)/runPurge.c'; fi` 
     311        mv -f $(DEPDIR)/purge_so-runPurge.Tpo $(DEPDIR)/purge_so-runPurge.Po 
     312#       source='runPurge.c' object='purge_so-runPurge.obj' libtool=no \ 
     313#       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 
     314#       $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-runPurge.obj `if test -f 'runPurge.c'; then $(CYGPATH_W) 'runPurge.c'; else $(CYGPATH_W) '$(srcdir)/runPurge.c'; fi` 
     315 
     316purge_so-db_purge_connection.o: db_purge_connection.c 
     317        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-db_purge_connection.o -MD -MP -MF $(DEPDIR)/purge_so-db_purge_connection.Tpo -c -o purge_so-db_purge_connection.o `test -f 'db_purge_connection.c' || echo '$(srcdir)/'`db_purge_connection.c 
     318        mv -f $(DEPDIR)/purge_so-db_purge_connection.Tpo $(DEPDIR)/purge_so-db_purge_connection.Po 
     319#       source='db_purge_connection.c' object='purge_so-db_purge_connection.o' libtool=no \ 
     320#       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 
     321#       $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-db_purge_connection.o `test -f 'db_purge_connection.c' || echo '$(srcdir)/'`db_purge_connection.c 
     322 
     323purge_so-db_purge_connection.obj: db_purge_connection.c 
     324        $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-db_purge_connection.obj -MD -MP -MF $(DEPDIR)/purge_so-db_purge_connection.Tpo -c -o purge_so-db_purge_connection.obj `if test -f 'db_purge_connection.c'; then $(CYGPATH_W) 'db_purge_connection.c'; else $(CYGPATH_W) '$(srcdir)/db_purge_connection.c'; fi` 
     325        mv -f $(DEPDIR)/purge_so-db_purge_connection.Tpo $(DEPDIR)/purge_so-db_purge_connection.Po 
     326#       source='db_purge_connection.c' object='purge_so-db_purge_connection.obj' libtool=no \ 
     327#       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 
     328#       $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-db_purge_connection.obj `if test -f 'db_purge_connection.c'; then $(CYGPATH_W) 'db_purge_connection.c'; else $(CYGPATH_W) '$(srcdir)/db_purge_connection.c'; fi` 
    293329 
    294330ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 
  • trunk/centstorage/modules/purge/Makefile.am

    r6209 r6244  
    2222bin_PROGRAMS = purge.so 
    2323 
    24 purge_so_SOURCES =      purge.c \ 
    25                                 \ 
    26                         purge.h 
     24purge_so_SOURCES =      purge.c                 \ 
     25                        runPurge.c              \ 
     26                        db_purge_connection.c   \ 
     27                                                \ 
     28                        purge.h                 \ 
     29                        runPurge.h              \ 
     30                        db_purge_connection.h 
    2731 
    2832INCLUDES = -I. @XML_HEADER@ -I../../includes 
  • trunk/centstorage/modules/purge/Makefile.in

    r6209 r6244  
    6767binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 
    6868PROGRAMS = $(bin_PROGRAMS) 
    69 am_purge_so_OBJECTS = purge_so-purge.$(OBJEXT) 
     69am_purge_so_OBJECTS = purge_so-purge.$(OBJEXT) \ 
     70        purge_so-runPurge.$(OBJEXT) \ 
     71        purge_so-db_purge_connection.$(OBJEXT) 
    7072purge_so_OBJECTS = $(am_purge_so_OBJECTS) 
    7173purge_so_DEPENDENCIES = 
     
    185187top_builddir = @top_builddir@ 
    186188top_srcdir = @top_srcdir@ 
    187 purge_so_SOURCES = purge.c      \ 
    188                                 \ 
    189                         purge.h 
     189purge_so_SOURCES = purge.c                      \ 
     190                        runPurge.c              \ 
     191                        db_purge_connection.c   \ 
     192                                                \ 
     193                        purge.h                 \ 
     194                        runPurge.h              \ 
     195                        db_purge_connection.h 
    190196 
    191197INCLUDES = -I. @XML_HEADER@ -I../../includes 
     
    262268        -rm -f *.tab.c 
    263269 
     270@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/purge_so-db_purge_connection.Po@am__quote@ 
    264271@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/purge_so-purge.Po@am__quote@ 
     272@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/purge_so-runPurge.Po@am__quote@ 
    265273 
    266274.c.o: 
     
    291299@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 
    292300@am__fastdepCC_FALSE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-purge.obj `if test -f 'purge.c'; then $(CYGPATH_W) 'purge.c'; else $(CYGPATH_W) '$(srcdir)/purge.c'; fi` 
     301 
     302purge_so-runPurge.o: runPurge.c 
     303@am__fastdepCC_TRUE@    $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-runPurge.o -MD -MP -MF $(DEPDIR)/purge_so-runPurge.Tpo -c -o purge_so-runPurge.o `test -f 'runPurge.c' || echo '$(srcdir)/'`runPurge.c 
     304@am__fastdepCC_TRUE@    mv -f $(DEPDIR)/purge_so-runPurge.Tpo $(DEPDIR)/purge_so-runPurge.Po 
     305@AMDEP_TRUE@@am__fastdepCC_FALSE@       source='runPurge.c' object='purge_so-runPurge.o' libtool=no @AMDEPBACKSLASH@ 
     306@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 
     307@am__fastdepCC_FALSE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-runPurge.o `test -f 'runPurge.c' || echo '$(srcdir)/'`runPurge.c 
     308 
     309purge_so-runPurge.obj: runPurge.c 
     310@am__fastdepCC_TRUE@    $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-runPurge.obj -MD -MP -MF $(DEPDIR)/purge_so-runPurge.Tpo -c -o purge_so-runPurge.obj `if test -f 'runPurge.c'; then $(CYGPATH_W) 'runPurge.c'; else $(CYGPATH_W) '$(srcdir)/runPurge.c'; fi` 
     311@am__fastdepCC_TRUE@    mv -f $(DEPDIR)/purge_so-runPurge.Tpo $(DEPDIR)/purge_so-runPurge.Po 
     312@AMDEP_TRUE@@am__fastdepCC_FALSE@       source='runPurge.c' object='purge_so-runPurge.obj' libtool=no @AMDEPBACKSLASH@ 
     313@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 
     314@am__fastdepCC_FALSE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-runPurge.obj `if test -f 'runPurge.c'; then $(CYGPATH_W) 'runPurge.c'; else $(CYGPATH_W) '$(srcdir)/runPurge.c'; fi` 
     315 
     316purge_so-db_purge_connection.o: db_purge_connection.c 
     317@am__fastdepCC_TRUE@    $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-db_purge_connection.o -MD -MP -MF $(DEPDIR)/purge_so-db_purge_connection.Tpo -c -o purge_so-db_purge_connection.o `test -f 'db_purge_connection.c' || echo '$(srcdir)/'`db_purge_connection.c 
     318@am__fastdepCC_TRUE@    mv -f $(DEPDIR)/purge_so-db_purge_connection.Tpo $(DEPDIR)/purge_so-db_purge_connection.Po 
     319@AMDEP_TRUE@@am__fastdepCC_FALSE@       source='db_purge_connection.c' object='purge_so-db_purge_connection.o' libtool=no @AMDEPBACKSLASH@ 
     320@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 
     321@am__fastdepCC_FALSE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-db_purge_connection.o `test -f 'db_purge_connection.c' || echo '$(srcdir)/'`db_purge_connection.c 
     322 
     323purge_so-db_purge_connection.obj: db_purge_connection.c 
     324@am__fastdepCC_TRUE@    $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -MT purge_so-db_purge_connection.obj -MD -MP -MF $(DEPDIR)/purge_so-db_purge_connection.Tpo -c -o purge_so-db_purge_connection.obj `if test -f 'db_purge_connection.c'; then $(CYGPATH_W) 'db_purge_connection.c'; else $(CYGPATH_W) '$(srcdir)/db_purge_connection.c'; fi` 
     325@am__fastdepCC_TRUE@    mv -f $(DEPDIR)/purge_so-db_purge_connection.Tpo $(DEPDIR)/purge_so-db_purge_connection.Po 
     326@AMDEP_TRUE@@am__fastdepCC_FALSE@       source='db_purge_connection.c' object='purge_so-db_purge_connection.obj' libtool=no @AMDEPBACKSLASH@ 
     327@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 
     328@am__fastdepCC_FALSE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(purge_so_CFLAGS) $(CFLAGS) -c -o purge_so-db_purge_connection.obj `if test -f 'db_purge_connection.c'; then $(CYGPATH_W) 'db_purge_connection.c'; else $(CYGPATH_W) '$(srcdir)/db_purge_connection.c'; fi` 
    293329 
    294330ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 
  • trunk/centstorage/modules/purge/purge.c

    r6209 r6244  
    2525 
    2626#include <time.h> 
     27#include <stdio.h> 
     28#include <string.h> 
     29#include <libxml/xmlmemory.h> 
     30#include <libxml/parser.h> 
     31#include <libxml/xpath.h> 
     32 
    2733#include <purge.h> 
    28  
    2934#include <extvar.h> 
    30  
    31 void    purge(int *i) 
     35#include <ParseXmlFile.h> 
     36 
     37void    *purge_db_connection = NULL; 
     38 
     39/* 
     40** function purge is the "main" function of module purge, 
     41** the one called when the thread for module purge is created (see 
     42** man 3 pthread_create for more explainaition about pthread_create) 
     43** 
     44** @param int*: pointer to int, indicating the "position" in the 
     45** module table. The module table is defined in the core (file Conf.h) 
     46** and filed in runCentstorage.c 
     47*/ 
     48void            purge(int *i) 
    3249{ 
    33   unsigned char flagStop; 
    34  
    35   while (1) 
    36     { 
    37       printf("je suis le module purge\n"); 
    38       LOCK_MUTEX(&mutex); 
    39       flagStop = conf->flag_stop[*i + 1]; 
    40       UNLOCK_MUTEX(&mutex); 
    41       if (flagStop == TRUE) 
    42         break ; 
    43       sleep(5); 
    44     } 
     50  unsigned char flagStop; 
     51  Purge_t       *confPurge; 
     52  char          confFile[PATH_SIZE]; 
     53  int           log; 
     54 
     55  /* first thing, copy values from the configuration in local variable 
     56     to avoid access the global Conf_t *conf, that require a mutex and 
     57     load the configuration */ 
     58  LOCK_MUTEX(&mutex); 
     59  strncpy(confFile, conf->confFile, 128); 
     60  confPurge = loadPurgeConf(confFile, log, *i); 
     61  log = conf->logs->log; 
     62  UNLOCK_MUTEX(&mutex); 
     63 
     64  runPurge(confPurge, log, *i, confFile); 
     65 
     66  purge_db_disconnect(purge_db_connection, log); 
     67 
     68  free(confPurge); 
     69  return ; 
    4570} 
     71 
     72/* 
     73** This function load the configuration of module purge from the configuration 
     74** file. If the file is incomplete default values are loaded for the missing 
     75** values. If the file is syntaxically incorrect default values are loaded. 
     76** 
     77** @param char *: path to the configuration file 
     78** @param int: flag indicating if informations must be log or not 
     79** @param int: "position" of the module in the module array 
     80** 
     81** return a pointer to a structure Purge_t, containing the module configuration 
     82*/ 
     83Purge_t                 *loadPurgeConf(char *confFile, int log, int i) 
     84{ 
     85  Purge_t               *confPurge = NULL; 
     86  xmlDocPtr             doc; 
     87  xmlXPathContextPtr    xmlContext; 
     88  xmlNodePtr            cur; 
     89  xmlChar               *txt; 
     90 
     91  /* alloc memory for structure Purge_t */ 
     92  confPurge = malloc(sizeof(*confPurge)); 
     93  if (!confPurge) 
     94     { 
     95      /* if malloc failed printf and eventually log errors messages */ 
     96      fprintf(stderr, "[module %s] %s : exting thread.\n", 
     97              MOD_PURGE_NAME, ERROR_MALLOC_CONF_PURGE); 
     98      if (log) 
     99        logger(" [module %s] %s", MOD_PURGE_NAME, ERROR_MALLOC_CONF_PURGE); 
     100 
     101      conf->threads_id[i] = 0; 
     102      conf->modules[i].CallFunction = NULL; 
     103 
     104      /* exit thread */ 
     105      pthread_exit(NULL); 
     106    } 
     107 
     108  /* load default values */ 
     109  confPurge->unit = PURGE_DEFAULT_TIME_UNIT; 
     110  confPurge->timeval = PURGE_DEFAULT_TIMEVAL; 
     111 
     112  /* verify configuration file validity */ 
     113  if (checkFileValidity(&doc, &cur, confFile) == -1) 
     114    return confPurge; 
     115 
     116  /* initialize xml XPath context */ 
     117  xmlXPathInit(); 
     118  xmlContext = xmlXPathNewContext(doc); 
     119  if (!xmlContext) 
     120    { 
     121      /* free ressource */ 
     122      xmlFreeDoc(doc); 
     123 
     124      /* print and log error messages */ 
     125      fprintf(stderr, "[module %s] %s\n", 
     126              MOD_PURGE_NAME, PURGE_XMLCONTEXT_ERROR); 
     127      if (log) 
     128        logger(" [module %s] %s", MOD_PURGE_NAME, PURGE_XMLCONTEXT_ERROR); 
     129      return confPurge; 
     130    } 
     131 
     132  /* load the values from configuration file using XPath: 
     133   first the timeval*/ 
     134  txt = getParam(PURGE_XPATH_TIME_S, xmlContext, doc); 
     135  if (!txt) 
     136    { 
     137      txt = getParam(PURGE_XPATH_TIME_M, xmlContext, doc); 
     138      if (!txt) 
     139        { 
     140          txt = getParam(PURGE_XPATH_TIME_H, xmlContext, doc); 
     141          if (!txt) 
     142            { 
     143              txt = getParam(PURGE_XPATH_TIME_D, xmlContext, doc); 
     144              if (txt) 
     145                { 
     146                  confPurge->unit = DAYS; 
     147                  confPurge->timeval = atoi(txt); 
     148                  free(txt); 
     149                  txt = NULL; 
     150                } 
     151            } 
     152          else 
     153            { 
     154              confPurge->unit = HOURS; 
     155              confPurge->timeval = atoi(txt); 
     156              free(txt); 
     157              txt = NULL; 
     158            } 
     159        } 
     160      else 
     161        { 
     162          confPurge->unit = MINUTES; 
     163          confPurge->timeval = atoi(txt); 
     164          free(txt); 
     165          txt = NULL; 
     166        } 
     167    } 
     168  else 
     169    { 
     170      confPurge->unit = SECONDS; 
     171      confPurge->timeval = atoi(txt); 
     172      free(txt); 
     173      txt = NULL; 
     174    } 
     175 
     176  if (confPurge->timeval == 0) 
     177    confPurge->timeval = 1; 
     178 
     179  /* and second the age */ 
     180  confPurge->age = PURGE_DEFAULT_AGE; 
     181  confPurge->ageUnit = PURGE_DEFAULT_AGE_UNIT; 
     182 
     183  txt = getParam(PURGE_XPATH_AGE_M, xmlContext, doc); 
     184  if (!txt) 
     185    { 
     186      txt = getParam(PURGE_XPATH_AGE_D, xmlContext, doc); 
     187      if (txt) 
     188        { 
     189          confPurge->age = atoi(txt); 
     190          confPurge->ageUnit = DAY; 
     191          free(txt); 
     192        } 
     193    } 
     194  else 
     195    { 
     196      confPurge->age = atoi(txt); 
     197      confPurge->ageUnit = MONTH; 
     198      free(txt); 
     199    } 
     200 
     201  if (confPurge->age == 0) 
     202    confPurge->age = 1; 
     203 
     204  /* free ressources */ 
     205  xmlXPathFreeContext(xmlContext); 
     206  xmlFreeDoc(doc); 
     207  return confPurge; 
     208} 
  • trunk/centstorage/modules/purge/purge.h

    r6209 r6244  
    2323# define PURGE_H_ 
    2424 
     25#define PATH_SIZE       128 
     26 
     27enum    timeUnit 
     28  { 
     29    SECONDS, 
     30    MINUTES, 
     31    HOURS, 
     32    DAYS 
     33  }; 
     34 
     35#define MOD_PURGE_NAME  "purge" 
     36#define ERROR_MALLOC_CONF_PURGE "Cannot malloc enough memory to load purge configuration" 
     37#define PURGE_XMLCONTEXT_ERROR "Cannot create an xml XPath Context. Keeping default configuration" 
     38 
     39enum    ageUnits 
     40  { 
     41    DAY, 
     42    MONTH 
     43  }; 
     44 
     45#define PURGE_DEFAULT_TIMEVAL   5 
     46#define PURGE_DEFAULT_TIME_UNIT MINUTES 
     47#define PURGE_DEFAULT_AGE       1 
     48#define PURGE_DEFAULT_AGE_UNIT  MONTH 
     49 
     50#define PURGE_XPATH_TIME_S "/CentStorage/modules/module[@name='purge']/interval[@unit='s']/text()" 
     51#define PURGE_XPATH_TIME_M "/CentStorage/modules/module[@name='purge']/interval[@unit='min']/text()" 
     52#define PURGE_XPATH_TIME_H "/CentStorage/modules/module[@name='purge']/interval[@unit='h']/text()" 
     53#define PURGE_XPATH_TIME_D "/CentStorage/modules/module[@name='purge']/interval[@unit='d']/text()" 
     54#define PURGE_XPATH_AGE_M  "/CentStorage/modules/module[@name='purge']/age[@unit='month']/text()" 
     55#define PURGE_XPATH_AGE_D "/CentStorage/modules/module[@name='purge']/age[@unit='day']/text()" 
     56 
     57/* structure containing the configuration of the module purge */ 
     58typedef struct  Purge_s 
     59{ 
     60  int           timeval; 
     61  int           unit; 
     62 
     63  int           age; 
     64  int           ageUnit; 
     65}               Purge_t; 
     66 
     67/* prototypes */ 
     68/* 
     69** function purge is the "main" function of module purge, 
     70** the one called when the thread for module purge is created (see 
     71** man 3 pthread_create for more explainaition about pthread_create) 
     72** 
     73** @param int*: pointer to int, indicating the "position" in the 
     74** module table. The module table is defined in the core (file Conf.h) 
     75** and filed in runCentstorage.c 
     76*/ 
    2577void    purge(int *); 
    2678 
     79/* 
     80** This function load the configuration of module purge from the configuration 
     81** file. If the file is incomplete default values are loaded for the missing 
     82** values. If the file is syntaxically incorrect default values are loaded. 
     83** 
     84** @param char *: path to the configuration file 
     85** @param int: flag indicating if informations must be log or not 
     86** @param int: "position" of the module in the module array 
     87** 
     88** return a pointer to a structure Purge_t, containing the module configuration 
     89*/ 
     90Purge_t *loadPurgeConf(char *conf, int, int); 
     91 
    2792#endif /* PURGE_H_ */ 
  • trunk/centstorage/modules/recup_perf_datas/db_connection.h

    r6185 r6244  
    7575#endif /* USE_ORACLE */ 
    7676 
    77  
    7877#define MOD_NAME        "recup_perf_datas" 
    7978 
  • trunk/centstorage/modules/recup_perf_datas/insertValInDataBase.c

    r6209 r6244  
    6868extern void     *db_connection; 
    6969extern int      serverFailure; 
     70extern pthread_mutex_t  Access_DB; 
    7071 
    7172#ifdef  USE_MYSQL 
     
    9495  int           i, count; 
    9596  char          nbr[11]; 
    96  
    97   //  serverFailure = 0; 
     97  unsigned char lock; 
     98 
    9899  sprintf(client->cmd, "OK%d\n", client->nb_lines); 
     100 
     101  LOCK_MUTEX(&mutex); 
     102  lock = conf->dbLock; 
     103  UNLOCK_MUTEX(&mutex); 
    99104 
    100105  if (timeout && timeout < time(NULL)) 
  • trunk/centstorage/modules/recup_perf_datas/recup_perf_datas.c

    r6122 r6244  
    5757#endif 
    5858 
    59 void    *db_connection = NULL; 
     59void *db_connection = NULL; 
    6060 
    6161/* 
  • trunk/centstorage/src/Conf.c

    r6209 r6244  
    216216      } 
    217217 
     218  tmp = getParam(XPATH_DB_LOCK(ROOT_ELEMENT), xmlConfContext, doc); 
     219  conf->dbLock = (tmp ? TRUE : FALSE); 
     220  if (tmp) 
     221    free(tmp); 
    218222 
    219223  loadBaseConf(xmlConfContext, doc); 
     
    225229#undef __DEBUG__ 
    226230#ifdef __DEBUG__ 
    227   printf("timout:%d unit:%d\n", conf->timeout, conf->unit); 
     231  printf("timeout:%d unit:%d\n", conf->timeout, conf->unit); 
    228232  printf("archive: unit:%d time:%d use:%d\n", conf->logs->unit, 
    229233        conf->logs->time, conf->logs->arch); 
  • trunk/centstorage/src/reloadConf.c

    r5883 r6244  
    5555#include <extvar.h> 
    5656#include <runCentStorage.h> 
     57 
     58pthread_mutex_t Access_DB = PTHREAD_MUTEX_INITIALIZER; 
    5759 
    5860/* 
     
    200202 
    201203  reloadModules(saveConf); 
    202   
     204 
    203205  /* this part is written to avoid some mmory leaks */ 
    204206  if (conf->modules) 
  • trunk/centstorage/src/runCentStorage.c

    r6209 r6244  
    5252  /* setting the conf->flag_stop[i] to TRUE to indicate to the threads 
    5353     they must quit. */ 
    54   //  printf("Killing all threads:\n"); 
    5554  for (i = 0; conf->modules[i].ModuleName; i++) 
    5655    {