X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fs_bsd.c;h=63e9081c51da376193f3a01b9884c8e76b2da4be;hb=6a896dc3a06393ec254a43bd5ac4b7e282d4a968;hp=2a57382856f66d4030e6eedfc7fe67c96906602c;hpb=055f52f6ed8900a32af2a22ec83d3aeeba115a59;p=ircu2.10.12-pk.git diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index 2a57382..63e9081 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -71,10 +71,6 @@ #include #include -#ifdef USE_POLL -#include -#endif /* USE_POLL */ - /** Array of my own clients, indexed by file descriptor. */ struct Client* LocalClientArray[MAXCONNECTIONS]; /** Maximum file descriptor in current use. */ @@ -108,24 +104,6 @@ const char* const TOS_ERROR_MSG = "error setting TOS for %s: %s"; static void client_sock_callback(struct Event* ev); static void client_timer_callback(struct Event* ev); -#if !defined(USE_POLL) -#if FD_SETSIZE < (MAXCONNECTIONS + 4) -/* - * Sanity check - * - * All operating systems work when MAXCONNECTIONS <= 252. - * Most operating systems work when MAXCONNECTIONS <= 1020 and FD_SETSIZE is - * updated correctly in the system headers (on BSD systems our sys.h has - * defined FD_SETSIZE to MAXCONNECTIONS+4 before including the system's headers - * but sys/types.h might have abruptly redefined it so the check is still - * done), you might already need to recompile your kernel. - * For larger FD_SETSIZE your mileage may vary (kernel patches may be needed). - * The check is _NOT_ done if we will not use FD_SETS at all (USE_POLL) - */ -#error "FD_SETSIZE is too small or MAXCONNECTIONS too large." -#endif -#endif - /* * Cannot use perror() within daemon. stderr is closed in @@ -154,13 +132,7 @@ void report_error(const char* text, const char* who, int err) if (EmptyString(who)) who = "unknown"; - if (last_notice + 20 < CurrentTime) { - /* - * pace error messages so opers don't get flooded by transients - */ - sendto_opmask_butone(0, SNO_OLDSNO, text, who, errmsg); - last_notice = CurrentTime; - } + sendto_opmask_butone_ratelimited(0, SNO_OLDSNO, &last_notice, text, who, errmsg); log_write(LS_SOCKET, L_ERROR, 0, text, who, errmsg); errno = errtmp; } @@ -210,7 +182,7 @@ int init_connection_limits(void) if (0 == limit) return 1; if (limit < 0) { - fprintf(stderr, "error setting max fd's to %d\n", limit); + fprintf(stderr, "error setting max fds to %d: %s\n", limit, strerror(errno)); } else if (limit > 0) { fprintf(stderr, "ircd fd table too big\nHard Limit: %d IRC max: %d\n", @@ -229,6 +201,8 @@ static int connect_inet(struct ConfItem* aconf, struct Client* cptr) { const struct irc_sockaddr *local; IOResult result; + int family = 0; + assert(0 != aconf); assert(0 != cptr); /* @@ -237,11 +211,12 @@ static int connect_inet(struct ConfItem* aconf, struct Client* cptr) */ if (irc_in_addr_valid(&aconf->origin.addr)) local = &aconf->origin; - else if (irc_in_addr_is_ipv4(&aconf->address.addr)) + else if (irc_in_addr_is_ipv4(&aconf->address.addr)) { local = &VirtualHost_v4; - else + family = AF_INET; + } else local = &VirtualHost_v6; - cli_fd(cptr) = os_socket(local, SOCK_STREAM, cli_name(cptr)); + cli_fd(cptr) = os_socket(local, SOCK_STREAM, cli_name(cptr), family); if (cli_fd(cptr) < 0) return 0; @@ -377,7 +352,7 @@ static int completed_connection(struct Client* cptr) * Make us timeout after twice the timeout for DNS look ups */ cli_lasttime(cptr) = CurrentTime; - SetFlag(cptr, FLAG_PINGSENT); + ClearPingSent(cptr); sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s6 :%s", cli_name(&me), cli_serv(&me)->timestamp, newts, @@ -518,7 +493,7 @@ void add_connection(struct Listener* listener, int fd) { */ os_disable_options(fd); - if (listener->server) + if (listener_server(listener)) { new_client = make_client(0, STAT_UNKNOWN_SERVER); } @@ -606,12 +581,11 @@ static int read_packet(struct Client *cptr, int socket_ready) case IO_SUCCESS: if (length) { - if (!IsServer(cptr)) - cli_lasttime(cptr) = CurrentTime; + cli_lasttime(cptr) = CurrentTime; + ClearPingSent(cptr); + ClrFlag(cptr, FLAG_NONL); if (cli_lasttime(cptr) > cli_since(cptr)) cli_since(cptr) = cli_lasttime(cptr); - ClrFlag(cptr, FLAG_PINGSENT); - ClrFlag(cptr, FLAG_NONL); } break; case IO_BLOCKED: @@ -661,7 +635,13 @@ static int read_packet(struct Client *cptr, int socket_ready) if (DBufLength(&(cli_recvQ(cptr))) < 510) SetFlag(cptr, FLAG_NONL); else + { + /* More than 512 bytes in the line - drop the input and yell + * at the client. + */ DBufClear(&(cli_recvQ(cptr))); + send_reply(cptr, ERR_INPUTTOOLONG); + } } else if (client_dopacket(cptr, dolen) == CPTR_KILLED) return CPTR_KILLED;