? ../ircu2.10.06/patch.db36 ? ../ircu2.10.06/patch.db37 Index: ../ircu2.10.06/todo.jcea =================================================================== RCS file: /cvsroot/ircd/todo.jcea,v retrieving revision 1.15 retrieving revision 1.16 diff -c -r1.15 -r1.16 *** ../ircu2.10.06/todo.jcea 1999/10/18 10:59:48 1.15 --- ../ircu2.10.06/todo.jcea 1999/10/18 16:45:13 1.16 *************** *** 1,3 **** --- 1,9 ---- + 19/Oct/99 + DjAcE - glog + + Si un servidor no tiene acceso a las BDD en disco, + un REHASH lo mata. + 15/Oct/99 Poner los HASHES con mmap(), para no tener que hacer tantas operaciones cuando se reciben Index: ../ircu2.10.06/ircd/s_debug.c =================================================================== RCS file: /cvsroot/ircd/ircd/s_debug.c,v retrieving revision 1.59 retrieving revision 1.60 diff -c -r1.59 -r1.60 *** ../ircu2.10.06/ircd/s_debug.c 1999/10/18 10:59:48 1.59 --- ../ircu2.10.06/ircd/s_debug.c 1999/10/18 22:46:37 1.60 *************** *** 191,197 **** '-', #endif #endif ! 'D','B','3','6', #ifdef DB_ESNET '+', #else --- 191,197 ---- '-', #endif #endif ! 'D','B','3','7', #ifdef DB_ESNET '+', #else Index: ../ircu2.10.06/ircd/s_serv.c =================================================================== RCS file: /cvsroot/ircd/ircd/s_serv.c,v retrieving revision 1.41 retrieving revision 1.42 diff -c -r1.41 -r1.42 *** ../ircu2.10.06/ircd/s_serv.c 1999/10/18 10:59:48 1.41 --- ../ircu2.10.06/ircd/s_serv.c 1999/10/18 22:46:37 1.42 *************** *** 29,35 **** --- 29,38 ---- #include #include #include + #ifdef USE_SYSLOG + #include #endif + #endif #include "h.h" #include "struct.h" *************** *** 1506,1511 **** --- 1509,1551 ---- #endif /* defined(DB_ESNET) || defined(DB_HISPANO) */ + /* + ** Esta rutina mata el servidor. + ** Es casi una copia de m_die(). + */ + extern char **myargv; /* ircd.c */ + void db_die(char *msg, char que_bdd) + { + aClient *acptr; + int i; + char buf[1024]; + + sprintf_irc(buf, "DB '%c' - %s", que_bdd, msg); + for (i = 0; i <= highest_fd; i++) + { + if (!(acptr = loc_clients[i])) + continue; + if (IsUser(acptr)) + sendto_one(acptr, ":%s NOTICE %s :%s", me.name, acptr->name, buf); + else if (IsServer(acptr)) + sendto_one(acptr, ":%s ERROR :%s", me.name, buf); + } + + #ifdef USE_SYSLOG + //openlog(myargv[0], LOG_PID | LOG_NDELAY, LOG_USER); + syslog(LOG_CRIT, buf); + //closelog(); + #endif + + Debug((DEBUG_ERROR, buf)); + + #ifdef __cplusplus + s_die(0); + #else + s_die(); + #endif + } + #ifdef DB_ESNET /* * leer_db *************** *** 1594,1600 **** * Se mueve hasta un registro de la base de datos * */ ! int abrir_db(unsigned long registro, char *buf, char bdd, struct tabla_en_memoria *mapeo) { int handle; --- 1634,1640 ---- * Se mueve hasta un registro de la base de datos * */ ! int abrir_db(unsigned long registro, char *buf, char que_bdd, struct tabla_en_memoria *mapeo) { int handle; *************** *** 1603,1609 **** struct stat estado; *buf = '\0'; ! sprintf_irc(path, "%s/tabla.%c", DBPATH, bdd); alarm(3); handle = open(path, O_RDONLY, S_IRUSR | S_IWUSR); fstat(handle, &estado); --- 1643,1649 ---- struct stat estado; *buf = '\0'; ! sprintf_irc(path, "%s/tabla.%c", DBPATH, que_bdd); alarm(3); handle = open(path, O_RDONLY, S_IRUSR | S_IWUSR); fstat(handle, &estado); *************** *** 1613,1620 **** --- 1653,1667 ---- close(handle); alarm(0); mapeo->puntero_r = mapeo->puntero_w = mapeo->posicion; + + if (handle == -1) + db_die("Error al intentar leer (open)", que_bdd); + if ((mapeo->len != 0) && (mapeo->posicion == MAP_FAILED)) + db_die("Error al intentar leer (mmap)", que_bdd); + if ((handle == -1) || (mapeo->posicion == MAP_FAILED)) return -1; + cont = seek_db(mapeo, buf, registro); if (cont == -1) { *************** *** 1648,1656 **** inttobase64(hash + 6, tabla_hash_lo[que_bdd], 6); alarm(3); db_file = open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); sprintf_irc(path, "%c %s\n", que_bdd, hash); ! lseek(db_file, 15 * (que_bdd - ESNET_BDD), SEEK_SET); ! write(db_file, path, strlen(path)); close(db_file); alarm(0); } --- 1695,1707 ---- inttobase64(hash + 6, tabla_hash_lo[que_bdd], 6); alarm(3); db_file = open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); + if (db_file == -1) + db_die("Error al intentar guardar hashes (open)", que_bdd); sprintf_irc(path, "%c %s\n", que_bdd, hash); ! if (lseek(db_file, 15 * (que_bdd - ESNET_BDD), SEEK_SET) == -1) ! db_die("Error al intentar guardar hashes (lseek)", que_bdd); ! if (write(db_file, path, strlen(path)) == -1) ! db_die("Error al intentar guardas hashes (write)", que_bdd); close(db_file); alarm(0); } *************** *** 1667,1672 **** --- 1718,1727 ---- sprintf_irc(path, "%s/hashes", DBPATH); alarm(3); db_file = open(path, O_RDONLY); + /* + ** No metemos verificacion, porque ya verifica + ** al contrastar el hash. + */ lseek(db_file, 15 * (que_bdd - ESNET_BDD) + 2, SEEK_SET); read(db_file, path, 12); close(db_file); *************** *** 1751,1756 **** --- 1806,1815 ---- map = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERVE, db_file, 0); alarm(0); + if (db_file == -1) + db_die("Error al intentar compactar (open)", que_bdd); + if ((len != 0) && (map == MAP_FAILED)) + db_die("Error al intentar compactar (mmap)", que_bdd); if (!tabla_residente[que_bdd]) { /* No residente -> No pack */