#include "ircd.h"
#include "ircd_alloc.h"
#include "ircd_osdep.h"
+#include "ircd_reply.h"
#include "ircd_string.h"
#include "numeric.h"
#include "s_bsd.h"
#define INADDR_NONE ((unsigned int) 0xffffffff)
#endif
+int tos_server = 0x08; // Low delay
+int tos_client = 0x08; // Low delay
+
struct Listener* ListenerPollList = 0;
static struct Listener* make_listener(int port, struct in_addr addr)
{
static char buf[HOSTLEN + PORTNAMELEN + 4];
assert(0 != listener);
- sprintf_irc(buf, "%s:%u", me.name, listener->port);
+ sprintf_irc(buf, "%s:%u", cli_name(&me), listener->port);
return buf;
}
}
else
flags[1] = '\0';
-
- sendto_one(sptr, rpl_str(RPL_STATSPLINE),
- me.name, sptr->name, listener->port,
- listener->ref_count, flags,
- (listener->active) ? "active" : "disabled");
+
+ send_reply(sptr, RPL_STATSPLINE, listener->port, listener->ref_count,
+ flags, (listener->active) ? "active" : "disabled");
if (--count == 0)
break;
}
close(fd);
return 0;
}
+ /*
+ * Set the TOS bits - this is nonfatal if it doesn't stick.
+ */
+ if (!os_set_tos(fd,(listener->server) ? tos_server : tos_client)) {
+ report_error(TOS_ERROR_MSG, get_listener_name(listener), errno);
+ }
listener->fd = fd;
return 1;
assert(0 != listener);
- if (EmptyString(mask) && strcmp(mask,"*")!=0) {
+ if (EmptyString(mask) || 0 == strcmp(mask, "*")) {
listener->mask.s_addr = 0;
return;
}
*/
void accept_connection(struct Listener* listener)
{
- struct sockaddr_in addr;
- size_t addrlen = sizeof(struct sockaddr_in);
+ struct sockaddr_in addr = { 0 };
+ unsigned int addrlen = sizeof(struct sockaddr_in);
int fd;
assert(0 != listener);
* point, just assume that connections cannot
* be accepted until some old is closed first.
*/
- if (-1 == (fd = accept(listener->fd, (struct sockaddr*) &addr, &addrlen)))
+ if (-1 == (fd = accept(listener->fd, (struct sockaddr*) &addr, &addrlen))) {
+ /* Lotsa admins seem to have problems with not giving enough file descriptors
+ * to their server so we'll add a generic warning mechanism here. If it
+ * turns out too many messages are generated for meaningless reasons we
+ * can filter them back.
+ */
+ sendto_opmask_butone(0, SNO_TCPCOMMON, "Unable to accept connection: %m");
return;
+ }
/*
* check for connection limit
*/