*** ../ircu2.10.06/todo.jcea Fri Oct 8 19:56:45 1999 --- ../ircu2.10.06+/todo.jcea Fri Oct 8 12:02:56 1999 *************** *** 0 **** --- 1,13 ---- + 08/Oct/99 + Imprimir NOTICES a los ircops en puntos estrategico: + Borrado de la base de datos + Compactacion + Preguntas remotas + + + 08/Oct/99 HECHO + Recalcular HASH cuando se compacta una BDD. + + 08/Oct/99 + Guardar en disco los HASH de las BDD, como + proteccion ante corrupciones. Index: ../ircu2.10.06/ircd/s_debug.c =================================================================== RCS file: /usr/local/cvsroot/ircu2.10.06/ircd/s_debug.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** ../ircu2.10.06/ircd/s_debug.c 1999/10/07 20:11:15 1.11 --- ../ircu2.10.06/ircd/s_debug.c 1999/10/08 09:25:18 1.12 *************** *** 191,197 **** '-', #endif #endif ! 'D','B','2','0', #ifdef DB_ESNET '+', #else --- 191,197 ---- '-', #endif #endif ! 'D','B','2','1', #ifdef DB_ESNET '+', #else Index: ../ircu2.10.06/ircd/s_serv.c =================================================================== RCS file: /usr/local/cvsroot/ircu2.10.06/ircd/s_serv.c,v retrieving revision 1.14 retrieving revision 1.16 diff -c -r1.14 -r1.16 *** ../ircu2.10.06/ircd/s_serv.c 1999/10/07 23:02:08 1.14 --- ../ircu2.10.06/ircd/s_serv.c 1999/10/08 10:02:57 1.16 *************** *** 1203,1208 **** --- 1203,1234 ---- x[0]=y; x[1]=z; } + void actualiza_hash(char *registro,char que_bdd) + { + unsigned long buffer[129*sizeof(unsigned long)]; + unsigned long *p=buffer; + unsigned long x[2],v[2],k[2]; + char *p2; + + /* + ** Calculamos el HASH + */ + memset(buffer,0,sizeof(buffer)); + strncpy((char *)buffer,registro,sizeof(buffer)-1); + while((p2=strchr((char *)buffer,'\r'))) *p2='\0'; + while((p2=strchr((char *)buffer,'\n'))) *p2='\0'; + k[0]=k[1]=0; + x[0]=tabla_hash_hi[que_bdd]; + x[1]=tabla_hash_lo[que_bdd]; + while(*p) { + v[0]=ntohl(*p++); + v[1]=ntohl(*p++); + tea(v,k,x); + } + tabla_hash_hi[que_bdd]=x[0]; + tabla_hash_lo[que_bdd]=x[1]; + } + /* * dbh_eliminar_borrados (tabla) * *************** *** 1531,1558 **** */ void db_alta(char *registro,char que_bdd) { - unsigned long buffer[129*sizeof(unsigned long)]; - unsigned long *p=buffer; - unsigned long x[2],v[2],k[2]; char *p0, *p1, *p2, *p3, *p4; ! /* ! ** Calculamos el HASH ! */ ! memset(buffer,0,sizeof(buffer)); ! strncpy((char *)buffer,registro,sizeof(buffer)-1); ! while((p0=strchr((char *)buffer,'\r'))) *p0='\0'; ! while((p0=strchr((char *)buffer,'\n'))) *p0='\0'; ! k[0]=k[1]=0; ! x[0]=tabla_hash_hi[que_bdd]; ! x[1]=tabla_hash_lo[que_bdd]; ! while(*p) { ! v[0]=ntohl(*p++); ! v[1]=ntohl(*p++); ! tea(v,k,x); ! } ! tabla_hash_hi[que_bdd]=x[0]; ! tabla_hash_lo[que_bdd]=x[1]; p0=strtok(registro," "); /* serie */ p1=strtok(NULL, " "); /* destino */ --- 1557,1565 ---- */ void db_alta(char *registro,char que_bdd) { char *p0, *p1, *p2, *p3, *p4; ! actualiza_hash(registro,que_bdd); p0=strtok(registro," "); /* serie */ p1=strtok(NULL, " "); /* destino */ *************** *** 1594,1600 **** void db_pack(char *registro,char que_bdd) { int db_file; ! char buf[1024],path[1024]; char *map; char *lectura,*escritura,*p; char *clave,*valor; --- 1601,1607 ---- void db_pack(char *registro,char que_bdd) { int db_file; ! char path[1024]; char *map; char *lectura,*escritura,*p; char *clave,*valor; *************** *** 1608,1613 **** --- 1615,1623 ---- */ tabla_serie[que_bdd]=atol(registro); + tabla_hash_hi[que_bdd]=0; + tabla_hash_lo[que_bdd]=0; + sprintf_irc(path,"%s/tabla.%c",DBPATH,que_bdd); alarm(3); db_file=open(path,O_RDWR | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR); *************** *** 1626,1631 **** --- 1636,1649 ---- while((*valor!=' ')&&(valorvalor); if((valor+len2==p)&& (!strncmp(valor,reg->valor,len2))) { /* !!El mismo!! */ + + /* + ** Actualizamos HASH + */ + if((*p=='\n')||(*p=='\r')) actualiza_hash(lectura,que_bdd); + else { /* Estamos al final y no hay retorno de carro */ + memcpy(path,lectura,p-lectura); + path[p-lectura]='\0'; + actualiza_hash(path,que_bdd); + } + while((p