diff options
author | ramon <ramongomez@us.es> | 2012-10-10 16:06:12 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2012-10-10 16:06:12 +0000 |
commit | fc480f2951bba6813ec9c7ee1f47f31637dabd19 (patch) | |
tree | d1ae5d82e4b75a0625c2e7521d1c92f33e9f6be2 | |
parent | 319b9f59d70033d8542776d4896dfc89f7c50be5 (diff) |
#559: Liberar memoria reservada en todos los demonios.
git-svn-id: https://opengnsys.es/svn/branches/version1.0@3345 a21b9725-9963-47de-94b9-378ad31fedc9
-rw-r--r-- | admin/Sources/Includes/ogAdmLib.c | 2 | ||||
-rw-r--r-- | admin/Sources/Includes/ogAdmLib.h | 2 | ||||
-rw-r--r-- | admin/Sources/Services/ogAdmAgent/sources/ogAdmAgent.cpp | 21 | ||||
-rw-r--r-- | admin/Sources/Services/ogAdmRepo/sources/ogAdmRepo.cpp | 1 | ||||
-rw-r--r-- | admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp | 64 |
5 files changed, 63 insertions, 27 deletions
diff --git a/admin/Sources/Includes/ogAdmLib.c b/admin/Sources/Includes/ogAdmLib.c index ebd0dc00..57eeb113 100644 --- a/admin/Sources/Includes/ogAdmLib.c +++ b/admin/Sources/Includes/ogAdmLib.c @@ -287,7 +287,7 @@ char* ampliaMemoria(char* ptr,int lon) // Devuelve:
// Nada
//______________________________________________________________________________________________________
-void liberaMemoria(char* ptr)
+void liberaMemoria(void* ptr)
{
if(ptr)
free (ptr);
diff --git a/admin/Sources/Includes/ogAdmLib.h b/admin/Sources/Includes/ogAdmLib.h index 07b05985..748fe59b 100644 --- a/admin/Sources/Includes/ogAdmLib.h +++ b/admin/Sources/Includes/ogAdmLib.h @@ -275,7 +275,7 @@ void infoDebug(char*); BOOLEAN validacionParametros(int,char**,int); char* reservaMemoria(int); char* ampliaMemoria(char*,int); -void liberaMemoria(char*); +void liberaMemoria(void*); BOOLEAN initParametros(TRAMA*,int); int splitCadena(char **,char *, char); void sustituir(char *,char ,char ); diff --git a/admin/Sources/Services/ogAdmAgent/sources/ogAdmAgent.cpp b/admin/Sources/Services/ogAdmAgent/sources/ogAdmAgent.cpp index 11c1d77f..f245d040 100644 --- a/admin/Sources/Services/ogAdmAgent/sources/ogAdmAgent.cpp +++ b/admin/Sources/Services/ogAdmAgent/sources/ogAdmAgent.cpp @@ -59,6 +59,7 @@ BOOLEAN tomaConfiguracion(char* filecfg) catalog[0] = (char) NULL;
numlin = splitCadena(lineas, buffer, '\n');
+ liberaMemoria(buffer);
for (i = 0; i < numlin; i++) {
splitCadena(dualparametro, lineas[i], '=');
resul = strcmp(StrToUpper(dualparametro[0]), "SERVIDORADM");
@@ -418,13 +419,15 @@ BOOLEAN ejecutarProcedimiento(Database db,int idprocedimiento,int ambito,int ida if(!tbl.Get("parametros",parametros)){
tbl.GetErrorErrStr(msglog);
errorInfo(modulo, msglog);
+ liberaMemoria(parametros);
return (FALSE);
- }
+ }
+ liberaMemoria(parametros);
if(!tbl.Get("idcomando",idcomando)){
tbl.GetErrorErrStr(msglog);
errorInfo(modulo, msglog);
return (FALSE);
- }
+ }
if(!insertaComando(db,idcomando,parametros,idprocedimiento,ambito,idambito,restrambito))
return(false);
@@ -457,10 +460,10 @@ BOOLEAN ejecutarTarea(Database db, int idprogramacion, int idtarea) char modulo[] = "ejecutarTarea()";
sprintf(sqlstr,"SELECT tareas_acciones.orden,tareas_acciones.idprocedimiento,tareas_acciones.tareaid,"\
- " tareas.ambito,tareas.idambito,tareas.restrambito,length(tareas.restrambito) as lonrestrambito"\
- " FROM tareas"\
- " INNER JOIN tareas_acciones ON tareas_acciones.idtarea=tareas.idtarea"\
- " WHERE tareas_acciones.idtarea=%d ORDER BY tareas_acciones.orden",idtarea);
+ " tareas.ambito,tareas.idambito,tareas.restrambito,length(tareas.restrambito) as lonrestrambito"\
+ " FROM tareas"\
+ " INNER JOIN tareas_acciones ON tareas_acciones.idtarea=tareas.idtarea"\
+ " WHERE tareas_acciones.idtarea=%d ORDER BY tareas_acciones.orden",idtarea);
if (!db.Execute(sqlstr, tbl)) { // Error al leer
errorLog(modulo, 21, FALSE);
@@ -508,14 +511,16 @@ BOOLEAN ejecutarTarea(Database db, int idprogramacion, int idtarea) if(!tbl.Get("restrambito",restrambito)){
tbl.GetErrorErrStr(msglog);
errorInfo(modulo, msglog);
+ liberaMemoria(restrambito);
return (FALSE);
}
+ liberaMemoria(restrambito);
RecopilaIpesMacs(db,ambito,idambito,restrambito); // Recopila Ipes del ámbito
if(!tbl.Get("idprocedimiento",idprocedimiento)){
tbl.GetErrorErrStr(msglog);
errorInfo(modulo, msglog);
return (FALSE);
- }
+ }
sesion=time(NULL);
if(!ejecutarProcedimiento(db,idprocedimiento,ambito,idambito,restrambito))
@@ -618,8 +623,10 @@ BOOLEAN enviaPeticion(int idprogramacion) if(!enviaMensaje(&socket_c,ptrTrama,MSG_PETICION)){
errorLog(modulo,91,FALSE);
+ liberaMemoria(ptrTrama);
return(FALSE);
}
+ liberaMemoria(ptrTrama);
return(TRUE);
}
// _____________________________________________________________________________________________________________
diff --git a/admin/Sources/Services/ogAdmRepo/sources/ogAdmRepo.cpp b/admin/Sources/Services/ogAdmRepo/sources/ogAdmRepo.cpp index 067b6af0..06a81267 100644 --- a/admin/Sources/Services/ogAdmRepo/sources/ogAdmRepo.cpp +++ b/admin/Sources/Services/ogAdmRepo/sources/ogAdmRepo.cpp @@ -53,6 +53,7 @@ BOOLEAN tomaConfiguracion(char* filecfg) { puerto[0] = (char) NULL; numlin = splitCadena(lineas, buffer, '\n'); + liberaMemoria(buffer); for (i = 0; i < numlin; i++) { splitCadena(dualparametro, lineas[i], '='); resul = strcmp(StrToUpper(dualparametro[0]), "IPLOCAL"); diff --git a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp index 6f4a4785..8c34e06e 100644 --- a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp +++ b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp @@ -58,6 +58,7 @@ BOOLEAN tomaConfiguracion(char* filecfg) { aulaup[0] = (char) NULL; numlin = splitCadena(lineas, buffer, '\n'); + liberaMemoria(buffer); for (i = 0; i < numlin; i++) { splitCadena(dualparametro, lineas[i], '='); resul = strcmp(StrToUpper(dualparametro[0]), "SERVIDORADM"); @@ -218,6 +219,7 @@ BOOLEAN respuestaSondeo(SOCKET *socket_c, TRAMA* ptrTrama) { } } strcat(ptrTrama->parametros, "\r"); + liberaMemoria(Ipes); if (!mandaTrama(socket_c, ptrTrama)) { errorLog(modulo, 26, FALSE); return (FALSE); @@ -808,7 +810,6 @@ BOOLEAN actualizaConfiguracion(Database db, Table tbl, char* cfg, int ido) " idperfilsoft=%d" " WHERE idordenador=%d AND numdisk=%s AND numpar=%s", cpt, tam, idsfi, idsoi, 0, 0, ido, disk, par); - errorInfo(modulo,sqlstr); if (!db.Execute(sqlstr, tbl)) { // Error al recuperar los datos errorLog(modulo, 21, FALSE); db.GetErrorErrStr(msglog); @@ -1269,6 +1270,7 @@ BOOLEAN enviaComando(TRAMA* ptrTrama, const char *estado) close(tbsockets[idx].sock); // Cierra el socket del cliente hasta nueva disponibilidad } } + liberaMemoria(Ipes); return (TRUE); } //______________________________________________________________________________________________________ @@ -2222,6 +2224,7 @@ BOOLEAN actualizaHardware(Database db, Table tbl, char* hrd, char*ido, char msglog[LONSTD], sqlstr[LONSQL]; int idtipohardware, idperfilhard; int lon, i, j, aux; + bool retval; char *tbHardware[MAXHARDWARE]; int tbidhardware[MAXHARDWARE]; char *dualHardware[2], descripcion[250], strInt[LONINT], *idhardwares; @@ -2357,9 +2360,13 @@ BOOLEAN actualizaHardware(Database db, Table tbl, char* hrd, char*ido, npc, tbidhardware, lon)) { errorLog(modulo, 55, FALSE); errorInfo(modulo, msglog); - return (FALSE); + retval=FALSE; } - return (TRUE); + else { + retval=TRUE; + } + liberaMemoria(idhardwares); + return (retval); } // ________________________________________________________________________________________________________ // Función: cuestionPerfilHardware @@ -2402,6 +2409,7 @@ BOOLEAN cuestionPerfilHardware(Database db, Table tbl, char* idc, char* ido, errorLog(modulo, 21, FALSE); db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } if (tbl.ISEOF()) { // No existe un perfil hardware con esos componentes de componentes hardware, lo crea @@ -2410,6 +2418,7 @@ BOOLEAN cuestionPerfilHardware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } // Recupera el identificador del nuevo perfil hardware @@ -2417,12 +2426,14 @@ BOOLEAN cuestionPerfilHardware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al leer db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } if (!tbl.ISEOF()) { // Si existe registro if (!tbl.Get("identificador", nwidperfilhard)) { tbl.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } @@ -2434,6 +2445,7 @@ BOOLEAN cuestionPerfilHardware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } @@ -2441,6 +2453,7 @@ BOOLEAN cuestionPerfilHardware(Database db, Table tbl, char* idc, char* ido, if (!tbl.Get("idperfilhard", nwidperfilhard)) { tbl.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } @@ -2451,6 +2464,7 @@ BOOLEAN cuestionPerfilHardware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } @@ -2461,26 +2475,29 @@ BOOLEAN cuestionPerfilHardware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } /* Eliminar Perfiles hardware que quedan húerfanos */ sprintf(sqlstr, "DELETE FROM perfileshard WHERE idperfilhard NOT IN" - " (SELECT DISTINCT idperfilhard from ordenadores)"); + " (SELECT DISTINCT idperfilhard FROM ordenadores)"); if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } /* Eliminar Relación de hardwares con Perfiles hardware que quedan húerfanos */ - sprintf(sqlstr, - "DELETE FROM perfileshard_hardwares WHERE idperfilhard NOT IN" - " (SELECT idperfilhard from perfileshard)"); + sprintf(sqlstr, "DELETE FROM perfileshard_hardwares WHERE idperfilhard NOT IN" + " (SELECT idperfilhard FROM perfileshard)"); if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } + liberaMemoria(sqlstr); return (TRUE); } // ________________________________________________________________________________________________________ @@ -2577,6 +2594,7 @@ BOOLEAN RESPUESTA_InventarioSoftware(SOCKET *socket_c, TRAMA* ptrTrama) { BOOLEAN actualizaSoftware(Database db, Table tbl, char* sft, char* par, char* ido, char* npc, char* idc) { int i, j, lon, aux, idperfilsoft; + bool retval; char *tbSoftware[MAXSOFTWARE]; int tbidsoftware[MAXSOFTWARE]; char msglog[LONSTD], sqlstr[LONSQL], strInt[LONINT], *idsoftwares; @@ -2695,9 +2713,13 @@ BOOLEAN actualizaSoftware(Database db, Table tbl, char* sft, char* par, npc, par, tbidsoftware, lon)) { errorLog(modulo, 83, FALSE); errorInfo(modulo, msglog); - return (FALSE); + retval=FALSE; } - return (TRUE); + else { + retval=TRUE; + } + liberaMemoria(idsoftwares); + return (retval); } // ________________________________________________________________________________________________________ // Función: CuestionPerfilSoftware @@ -2741,6 +2763,7 @@ BOOLEAN cuestionPerfilSoftware(Database db, Table tbl, char* idc, char* ido, errorLog(modulo, 21, FALSE); db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } if (tbl.ISEOF()) { // No existe un perfil software con esos componentes de componentes software, lo crea @@ -2756,23 +2779,25 @@ BOOLEAN cuestionPerfilSoftware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al leer tbl.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } if (!tbl.ISEOF()) { // Si existe registro if (!tbl.Get("identificador", nwidperfilsoft)) { tbl.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } // Crea la relación entre perfiles y componenetes software for (i = 0; i < lon; i++) { - sprintf(sqlstr, - "INSERT perfilessoft_softwares (idperfilsoft,idsoftware)" + sprintf(sqlstr, "INSERT perfilessoft_softwares (idperfilsoft,idsoftware)" " VALUES(%d,%d)", nwidperfilsoft, tbidsoftware[i]); if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } @@ -2780,19 +2805,19 @@ BOOLEAN cuestionPerfilSoftware(Database db, Table tbl, char* idc, char* ido, if (!tbl.Get("idperfilsoft", nwidperfilsoft)) { tbl.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } if (idperfilsoftware != nwidperfilsoft) { // No coinciden los perfiles // Actualiza el identificador del perfil software del ordenador - sprintf(sqlstr, - "UPDATE ordenadores_particiones SET idperfilsoft=%d,idimagen=0" - " WHERE idordenador=%s AND numpar=%s", nwidperfilsoft, ido, - par); + sprintf(sqlstr, "UPDATE ordenadores_particiones SET idperfilsoft=%d,idimagen=0" + " WHERE idordenador=%s AND numpar=%s", nwidperfilsoft, ido, par); if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } } @@ -2807,6 +2832,7 @@ BOOLEAN cuestionPerfilSoftware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } /* Eliminar Perfiles software que quedan húerfanos */ @@ -2817,17 +2843,19 @@ BOOLEAN cuestionPerfilSoftware(Database db, Table tbl, char* idc, char* ido, if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } /* Eliminar Relación de softwares con Perfiles software que quedan húerfanos */ - sprintf(sqlstr, - "DELETE FROM perfilessoft_softwares WHERE idperfilsoft NOT IN" - " (SELECT idperfilsoft from perfilessoft)"); + sprintf(sqlstr, "DELETE FROM perfilessoft_softwares WHERE idperfilsoft NOT IN" + " (SELECT idperfilsoft from perfilessoft)"); if (!db.Execute(sqlstr, tbl)) { // Error al insertar db.GetErrorErrStr(msglog); errorInfo(modulo, msglog); + liberaMemoria(sqlstr); return (false); } + liberaMemoria(sqlstr); return (TRUE); } // ________________________________________________________________________________________________________ |