#include "channel.h"
#include "class.h"
#include "hash.h"
+#include "ircd_alloc.h"
#include "ircd_log.h"
#include "ircd_features.h"
#include "ircd_osdep.h"
* a non-null pointer, otherwise reply will be null.
* if successful start the connection, otherwise notify opers
*/
-static void connect_dns_callback(void* vptr, struct DNSReply* reply)
+static void connect_dns_callback(void* vptr, struct hostent* hp)
{
struct ConfItem* aconf = (struct ConfItem*) vptr;
+ assert(aconf);
aconf->dns_pending = 0;
- if (reply) {
- memcpy(&aconf->ipnum, reply->hp->h_addr, sizeof(struct in_addr));
- connect_server(aconf, 0, reply);
+ if (hp) {
+ memcpy(&aconf->ipnum, hp->h_addr, sizeof(struct in_addr));
+ MyFree(hp);
+ connect_server(aconf, 0);
}
else
sendto_opmask_butone(0, SNO_OLDSNO, "Connect to %s failed: host lookup",
void close_connections(int close_stderr)
{
int i;
-#if 0
close(0);
close(1);
if (close_stderr)
close(2);
-#endif
for (i = 3; i < MAXCONNECTIONS; ++i)
close(i);
}
/*
* we want a big buffer for server connections
*/
- if (!os_set_sockbufs(cli_fd(cptr), SERVER_TCP_WINDOW)) {
+ if (!os_set_sockbufs(cli_fd(cptr), feature_int(FEAT_SOCKSENDBUF), feature_int(FEAT_SOCKRECVBUF))) {
cli_error(cptr) = errno;
report_error(SETBUFS_ERROR_MSG, cli_name(cptr), errno);
close(cli_fd(cptr));
assert(MyConnect(cptr));
if (cli_dns_reply(cptr)) {
- assert(0 < cli_dns_reply(cptr)->ref_count);
- --(cli_dns_reply(cptr))->ref_count;
+ MyFree(cli_dns_reply(cptr));
cli_dns_reply(cptr) = 0;
}
}
* For server connections, we process as many as we can without
* worrying about the time of day or anything :)
*/
- if (length <= 0)
- ;
- else if (IsServer(cptr))
+ if (length > 0 && IsServer(cptr))
return server_dopacket(cptr, readbuf, length);
- else if (IsConnecting(cptr) || IsHandshake(cptr))
+ else if (length > 0 && (IsHandshake(cptr) || IsConnecting(cptr)))
return connect_dopacket(cptr, readbuf, length);
else
{
* it on the end of the receive queue and do it when its
* turn comes around.
*/
- if (dbuf_put(&(cli_recvQ(cptr)), readbuf, length) == 0)
+ if (length > 0 && dbuf_put(&(cli_recvQ(cptr)), readbuf, length) == 0)
return exit_client(cptr, cptr, &me, "dbuf_put fail");
- else if (DBufLength(&(cli_recvQ(cptr))) > feature_int(FEAT_CLIENT_FLOOD))
+
+ if (DBufLength(&(cli_recvQ(cptr))) > feature_int(FEAT_CLIENT_FLOOD))
return exit_client(cptr, cptr, &me, "Excess Flood");
while (DBufLength(&(cli_recvQ(cptr))) && !NoNewLine(cptr) &&
* be done, we loose the information about who started the connection and
* it's considered an auto connect.
*/
-int connect_server(struct ConfItem* aconf, struct Client* by,
- struct DNSReply* reply)
+int connect_server(struct ConfItem* aconf, struct Client* by)
{
struct Client* cptr = 0;
assert(0 != aconf);
* not a ip# string, then try and find the appropriate host record.
*/
if (INADDR_NONE == aconf->ipnum.s_addr) {
- char buf[HOSTLEN + 1];
- assert(0 == reply);
if (INADDR_NONE == (aconf->ipnum.s_addr = inet_addr(aconf->host))) {
+ char buf[HOSTLEN + 1];
struct DNSQuery query;
query.vptr = aconf;
host_from_uh(buf, aconf->host, HOSTLEN);
buf[HOSTLEN] = '\0';
- reply = gethost_byname(buf, &query);
-
- if (!reply) {
- aconf->dns_pending = 1;
- return 0;
- }
- memcpy(&aconf->ipnum, reply->hp->h_addr, sizeof(struct in_addr));
+ gethost_byname(buf, &query);
+ aconf->dns_pending = 1;
}
+ return 0;
}
cptr = make_client(NULL, STAT_UNKNOWN_SERVER);
- if (reply)
- ++reply->ref_count;
- cli_dns_reply(cptr) = reply;
/*
* Copy these in so we have something for error detection.
assert(0 != ev_socket(ev));
assert(0 != s_data(ev_socket(ev)));
- con = s_data(ev_socket(ev));
+ con = (struct Connection*) s_data(ev_socket(ev));
assert(0 != con_client(con) || ev_type(ev) == ET_DESTROY);
assert(0 != t_data(ev_timer(ev)));
assert(ET_DESTROY == ev_type(ev) || ET_EXPIRE == ev_type(ev));
- con = t_data(ev_timer(ev));
+ con = (struct Connection*) t_data(ev_timer(ev));
assert(0 != con_client(con) || ev_type(ev) == ET_DESTROY);