diff --git a/Changes b/Changes index c332e24ef..cdeaf895d 100644 --- a/Changes +++ b/Changes @@ -2023,3 +2023,7 @@ seen. gmtime warning still there - Fixed an SQLINE bug with sqlines without a reason - Fixed a bug effecting additions/deletions of SQLINES and deletions of SVSNLINES (may be the cause of #0000866) +- Fixed MAJOR "messages are lost" bug which can cause various problems: ziplink corruption, + duplicate user entry in sjoin, etc etc. This would happen if BUFFERPOOL was set too low (like + the default) and you got a lot of traffic. It's now handled a bit better and you'll get + a nice warning, additionally the default BUFFERPOOL is now set to MAXSENDQLENGTH*18 instead of *9. diff --git a/Config b/Config index b93d9c46a..adfd50afc 100755 --- a/Config +++ b/Config @@ -86,7 +86,7 @@ ZIPLINKSDIR="" LISTEN_SIZE="5" NICKNAMEHISTORYLENGTH="2000" MAXSENDQLENGTH="3000000" -BUFFERPOOL="9" +BUFFERPOOL="18" MAXCONNECTIONS="1024" INET6="" EXTRAPARA="" diff --git a/include/config.h b/include/config.h index 9e47ca1d8..3b9452619 100644 --- a/include/config.h +++ b/include/config.h @@ -361,7 +361,7 @@ * Recommended value is 2 * MAXSENDQLENGTH, for hubs, 5 *. */ #ifndef BUFFERPOOL -#define BUFFERPOOL (9 * MAXSENDQLENGTH) +#define BUFFERPOOL (18 * MAXSENDQLENGTH) #endif /* diff --git a/include/h.h b/include/h.h index 53011f31f..c0f1bebfa 100644 --- a/include/h.h +++ b/include/h.h @@ -560,5 +560,6 @@ long config_checkval(char *value, unsigned short flags); void config_status(char *format, ...); void init_random(); u_int32_t getrandom32(); +extern char trouble_info[1024]; #define EVENT_DRUGS BASE_VERSION diff --git a/src/dbuf.c b/src/dbuf.c index 7438add1a..a1625d420 100644 --- a/src/dbuf.c +++ b/src/dbuf.c @@ -39,9 +39,7 @@ #include "struct.h" #include "common.h" #include "sys.h" -#ifdef USE_DMALLOC #include "h.h" -#endif ID_Copyright("(C) 1990 Markku Savela"); ID_Notes("2.17 1/30/94 (C) 1990 Markku Savela"); #if !defined(VALLOC) && !defined(valloc) && !defined(USE_DMALLOC) @@ -84,6 +82,7 @@ static dbufbuf *dbuf_alloc(void) if (dbufalloc * DBUFSIZ > BUFFERPOOL) { dbufalloc--; + strcpy(trouble_info, "buffer allocation error! Increase BUFFERPOOL!"); return NULL; } @@ -100,7 +99,10 @@ static dbufbuf *dbuf_alloc(void) dbptr = (dbufbuf *)valloc(num * sizeof(dbufbuf)); if (!dbptr) + { + strcpy(trouble_info, "buffer allocation error! Out of memory! OUCH!!!"); return (dbufbuf *)NULL; + } num--; for (db2ptr = dbptr; num; num--) @@ -112,7 +114,10 @@ static dbufbuf *dbuf_alloc(void) return dbptr; #else dbufblocks++; - return (dbufbuf *)MyMalloc(sizeof(dbufbuf)); + dbptr = (dbufbuf *)MyMalloc(sizeof(dbufbuf)); + if (!dbptr) + strcpy(trouble_info, "buffer allocation error! Out of memory! OUCH!!!"); + return dbptr; #endif } @@ -144,7 +149,7 @@ static int dbuf_malloc_error(dbuf *dyn) dbuf_free(p); } dyn->tail = dyn->head; - return -1; + return 0; } diff --git a/src/ircd.c b/src/ircd.c index 2427cfc58..296c39ec2 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -129,6 +129,7 @@ TS check_fdlists(); #endif unsigned char conf_debuglevel = 0; +char trouble_info[1024]; void save_stats(void) { @@ -1393,6 +1394,14 @@ void SocketLoop(void *dummy) nextfdlistcheck = check_fdlists(timeofday); #endif flush_connections(&me); + + /* ThA UnReAl TrOuBlE RePoRtInG SyStEm!!! */ + if (trouble_info[0] != '\0') + { + sendto_realops("*** TROUBLE: %s ***", trouble_info); + ircd_log(LOG_ERROR, "TROUBLE: %s", trouble_info); + trouble_info[0] = '\0'; + } } } diff --git a/src/s_bsd.c b/src/s_bsd.c index 93243700f..0f5528ebf 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -1400,7 +1400,7 @@ static int read_packet(aClient *cptr, fd_set *rfd) ** it on the end of the receive queue and do it when its ** turn comes around. */ - if (dbuf_put(&cptr->recvQ, readbuf, length) < 0) + if (!dbuf_put(&cptr->recvQ, readbuf, length)) return exit_client(cptr, cptr, cptr, "dbuf_put fail"); if (IsPerson(cptr) && DBufLength(&cptr->recvQ) > get_recvq(cptr)) @@ -1563,7 +1563,7 @@ static int read_packet(aClient *cptr) * Before we even think of parsing what we just read, stick * it on the end of the receive queue and do it when its turn * comes around. */ - if (dbuf_put(&cptr->recvQ, readbuf, length) < 0) + if (!dbuf_put(&cptr->recvQ, readbuf, length)) return exit_client(cptr, cptr, cptr, "dbuf_put fail"); if (IsPerson(cptr) &&