Replace int fd; in local client object with an fde object.
This commit is contained in:
parent
16d59a0d4a
commit
de0572442e
|
@ -251,7 +251,7 @@ struct LocalUser
|
|||
char *fullcaps;
|
||||
|
||||
int caps; /* capabilities bit-field */
|
||||
int fd; /* >= 0, for local clients */
|
||||
fde_t *F; /* >= 0, for local clients */
|
||||
|
||||
/* time challenge response is valid for */
|
||||
time_t chal_time;
|
||||
|
|
|
@ -203,5 +203,6 @@ extern void mangle_mapped_sockaddr(struct sockaddr *in);
|
|||
extern int comm_get_maxconnections(void);
|
||||
|
||||
extern fde_t *comm_locate_fd(int fd);
|
||||
extern fde_t *comm_add_fd(int fd);
|
||||
|
||||
#endif /* INCLUDED_commio_h */
|
||||
|
|
|
@ -741,7 +741,7 @@ set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick)
|
|||
add_to_client_hash(nick, source_p);
|
||||
|
||||
/* fd_desc is long enough */
|
||||
comm_note(client_p->localClient->fd, "Nick: %s", nick);
|
||||
comm_note(client_p->localClient->F->fd, "Nick: %s", nick);
|
||||
|
||||
if(source_p->flags & FLAGS_SENTUSER)
|
||||
{
|
||||
|
@ -850,7 +850,7 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
|
|||
}
|
||||
|
||||
/* fd_desc is long enough */
|
||||
comm_note(client_p->localClient->fd, "Nick: %s", nick);
|
||||
comm_note(client_p->localClient->F->fd, "Nick: %s", nick);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ me_rsfnc(struct Client *client_p, struct Client *source_p,
|
|||
|
||||
del_all_accepts(target_p);
|
||||
|
||||
comm_note(target_p->localClient->fd, "Nick: %s", target_p->name);
|
||||
comm_note(target_p->localClient->F->fd, "Nick: %s", target_p->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ me_svslogin(struct Client *client_p, struct Client *source_p,
|
|||
else
|
||||
{
|
||||
send_signon(NULL, target_p, nick, user, host, CurrentTime, login);
|
||||
comm_note(target_p->localClient->fd, "Nick: %s", target_p->name);
|
||||
comm_note(target_p->localClient->F->fd, "Nick: %s", target_p->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
16
src/client.c
16
src/client.c
|
@ -162,7 +162,7 @@ make_client(struct Client *from)
|
|||
|
||||
client_p->localClient->lasttime = client_p->localClient->firsttime = CurrentTime;
|
||||
|
||||
client_p->localClient->fd = -1;
|
||||
client_p->localClient->F = NULL;
|
||||
client_p->localClient->ctrlfd = -1;
|
||||
|
||||
client_p->preClient = (struct PreClient *) BlockHeapAlloc(pclient_heap);
|
||||
|
@ -222,8 +222,8 @@ free_local_client(struct Client *client_p)
|
|||
client_p->localClient->listener = 0;
|
||||
}
|
||||
|
||||
if(client_p->localClient->fd >= 0)
|
||||
comm_close(client_p->localClient->fd);
|
||||
if(client_p->localClient->F->fd >= 0)
|
||||
comm_close(client_p->localClient->F->fd);
|
||||
|
||||
if(client_p->localClient->passwd)
|
||||
{
|
||||
|
@ -2101,14 +2101,14 @@ close_connection(struct Client *client_p)
|
|||
else
|
||||
ServerStats->is_ni++;
|
||||
|
||||
if(-1 < client_p->localClient->fd)
|
||||
if(client_p->localClient->F)
|
||||
{
|
||||
/* attempt to flush any pending dbufs. Evil, but .. -- adrian */
|
||||
if(!IsIOError(client_p))
|
||||
send_queued_write(client_p->localClient->fd, client_p);
|
||||
send_queued_write(client_p->localClient->F->fd, client_p);
|
||||
|
||||
comm_close(client_p->localClient->fd);
|
||||
client_p->localClient->fd = -1;
|
||||
comm_close(client_p->localClient->F->fd);
|
||||
client_p->localClient->F = NULL;
|
||||
}
|
||||
|
||||
if(-1 < client_p->localClient->ctrlfd)
|
||||
|
@ -2144,7 +2144,7 @@ error_exit_client(struct Client *client_p, int error)
|
|||
* for reading even though it ends up being an EOF. -avalon
|
||||
*/
|
||||
char errmsg[255];
|
||||
int current_error = comm_get_sockerr(client_p->localClient->fd);
|
||||
int current_error = comm_get_sockerr(client_p->localClient->F->fd);
|
||||
|
||||
SetIOError(client_p);
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ add_connection(listener_t *listener, int fd, struct sockaddr *sai, int exempt)
|
|||
|
||||
strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host));
|
||||
|
||||
new_client->localClient->fd = fd;
|
||||
new_client->localClient->F = comm_add_fd(fd);
|
||||
|
||||
new_client->localClient->listener = listener;
|
||||
++listener->ref_count;
|
||||
|
|
|
@ -356,13 +356,13 @@ read_packet(int fd, void *data)
|
|||
* I personally think it makes the code too hairy to make sane.
|
||||
* -- adrian
|
||||
*/
|
||||
length = read(client_p->localClient->fd, readBuf, READBUF_SIZE);
|
||||
length = client_p->localClient->F->read_impl(client_p->localClient->F, readBuf, READBUF_SIZE);
|
||||
|
||||
if(length <= 0)
|
||||
{
|
||||
if((length == -1) && ignoreErrno(errno))
|
||||
{
|
||||
comm_setselect(client_p->localClient->fd, FDLIST_IDLECLIENT,
|
||||
comm_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
|
||||
COMM_SELECT_READ, read_packet, client_p, 0);
|
||||
return;
|
||||
}
|
||||
|
@ -416,12 +416,12 @@ read_packet(int fd, void *data)
|
|||
/* If we get here, we need to register for another COMM_SELECT_READ */
|
||||
if(PARSE_AS_SERVER(client_p))
|
||||
{
|
||||
comm_setselect(client_p->localClient->fd, FDLIST_SERVER, COMM_SELECT_READ,
|
||||
comm_setselect(client_p->localClient->F->fd, FDLIST_SERVER, COMM_SELECT_READ,
|
||||
read_packet, client_p, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
comm_setselect(client_p->localClient->fd, FDLIST_IDLECLIENT,
|
||||
comm_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
|
||||
COMM_SELECT_READ, read_packet, client_p, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
|
|||
struct Message *mptr;
|
||||
|
||||
s_assert(MyConnect(client_p));
|
||||
s_assert(client_p->localClient->fd >= 0);
|
||||
s_assert(client_p->localClient->F->fd >= 0);
|
||||
if(IsAnyDead(client_p))
|
||||
return;
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ check_reject(struct Client *client_p)
|
|||
{
|
||||
ServerStats->is_rej++;
|
||||
SetReject(client_p);
|
||||
comm_setselect(client_p->localClient->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
|
||||
comm_setselect(client_p->localClient->F->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
|
||||
SetClosing(client_p);
|
||||
dlinkMoveNode(&client_p->localClient->tnode, &unknown_list, &delay_exit);
|
||||
return 1;
|
||||
|
@ -277,7 +277,7 @@ add_unknown_ip(struct Client *client_p)
|
|||
{
|
||||
SetExUnknown(client_p);
|
||||
SetReject(client_p);
|
||||
comm_setselect(client_p->localClient->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
|
||||
comm_setselect(client_p->localClient->F->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
|
||||
SetClosing(client_p);
|
||||
dlinkMoveNode(&client_p->localClient->tnode, &unknown_list, &delay_exit);
|
||||
return 1;
|
||||
|
|
14
src/s_auth.c
14
src/s_auth.c
|
@ -149,8 +149,8 @@ release_auth_client(struct AuthRequest *auth)
|
|||
client->localClient->auth_request = NULL;
|
||||
dlinkDelete(&auth->node, &auth_poll_list);
|
||||
free_auth_request(auth);
|
||||
if(client->localClient->fd > highest_fd)
|
||||
highest_fd = client->localClient->fd;
|
||||
if(client->localClient->F->fd > highest_fd)
|
||||
highest_fd = client->localClient->F->fd;
|
||||
|
||||
/*
|
||||
* When a client has auth'ed, we want to start reading what it sends
|
||||
|
@ -158,9 +158,9 @@ release_auth_client(struct AuthRequest *auth)
|
|||
* -- adrian
|
||||
*/
|
||||
client->localClient->allow_read = MAX_FLOOD;
|
||||
comm_setflush(client->localClient->fd, 1000, flood_recalc, client);
|
||||
comm_setflush(client->localClient->F->fd, 1000, flood_recalc, client);
|
||||
dlinkAddTail(client, &client->node, &global_client_list);
|
||||
read_packet(client->localClient->fd, client);
|
||||
read_packet(client->localClient->F->fd, client);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -309,7 +309,7 @@ start_auth_query(struct AuthRequest *auth)
|
|||
* and machines with multiple IP addresses are common now
|
||||
*/
|
||||
memset(&localaddr, 0, locallen);
|
||||
getsockname(auth->client->localClient->fd,
|
||||
getsockname(auth->client->localClient->F->fd,
|
||||
(struct sockaddr *) &localaddr, &locallen);
|
||||
|
||||
mangle_mapped_sockaddr((struct sockaddr *)&localaddr);
|
||||
|
@ -492,9 +492,9 @@ auth_connect_callback(int fd, int error, void *data)
|
|||
}
|
||||
|
||||
if(getsockname
|
||||
(auth->client->localClient->fd, (struct sockaddr *) &us,
|
||||
(auth->client->localClient->F->fd, (struct sockaddr *) &us,
|
||||
(socklen_t *) & ulen)
|
||||
|| getpeername(auth->client->localClient->fd,
|
||||
|| getpeername(auth->client->localClient->F->fd,
|
||||
(struct sockaddr *) &them, (socklen_t *) & tlen))
|
||||
{
|
||||
ilog(L_IOERROR, "auth get{sock,peer}name error for %s:%m",
|
||||
|
|
30
src/s_serv.c
30
src/s_serv.c
|
@ -1063,7 +1063,7 @@ server_estab(struct Client *client_p)
|
|||
(me.info[0]) ? (me.info) : "IRCers United");
|
||||
}
|
||||
|
||||
if(!comm_set_buffers(client_p->localClient->fd, READBUF_SIZE))
|
||||
if(!comm_set_buffers(client_p->localClient->F->fd, READBUF_SIZE))
|
||||
report_error(SETBUF_ERROR_MSG,
|
||||
get_server_name(client_p, SHOW_IP),
|
||||
log_client_name(client_p, SHOW_IP), errno);
|
||||
|
@ -1143,11 +1143,11 @@ server_estab(struct Client *client_p)
|
|||
/* we won't overflow FD_DESC_SZ here, as it can hold
|
||||
* client_p->name + 64
|
||||
*/
|
||||
comm_note(client_p->localClient->fd, "slink data: %s", client_p->name);
|
||||
comm_note(client_p->localClient->F->fd, "slink data: %s", client_p->name);
|
||||
comm_note(client_p->localClient->ctrlfd, "slink ctrl: %s", client_p->name);
|
||||
}
|
||||
else
|
||||
comm_note(client_p->localClient->fd, "Server: %s", client_p->name);
|
||||
comm_note(client_p->localClient->F->fd, "Server: %s", client_p->name);
|
||||
|
||||
/*
|
||||
** Old sendto_serv_but_one() call removed because we now
|
||||
|
@ -1371,7 +1371,7 @@ fork_server(struct Client *server)
|
|||
{
|
||||
|
||||
|
||||
if((i == ctrl_fds[1]) || (i == data_fds[1]) || (i == server->localClient->fd))
|
||||
if((i == ctrl_fds[1]) || (i == data_fds[1]) || (i == server->localClient->F->fd))
|
||||
{
|
||||
comm_set_nb(i);
|
||||
}
|
||||
|
@ -1386,7 +1386,7 @@ fork_server(struct Client *server)
|
|||
|
||||
ircsnprintf(fd_str[0], sizeof(fd_str[0]), "%d", ctrl_fds[1]);
|
||||
ircsnprintf(fd_str[1], sizeof(fd_str[1]), "%d", data_fds[1]);
|
||||
ircsnprintf(fd_str[2], sizeof(fd_str[2]), "%d", server->localClient->fd);
|
||||
ircsnprintf(fd_str[2], sizeof(fd_str[2]), "%d", server->localClient->F->fd);
|
||||
kid_argv[0] = slink;
|
||||
kid_argv[1] = fd_str[0];
|
||||
kid_argv[2] = fd_str[1];
|
||||
|
@ -1401,7 +1401,7 @@ fork_server(struct Client *server)
|
|||
}
|
||||
else
|
||||
{
|
||||
comm_close(server->localClient->fd);
|
||||
comm_close(server->localClient->F->fd);
|
||||
|
||||
/* close the childs end of the pipes */
|
||||
close(ctrl_fds[1]);
|
||||
|
@ -1409,9 +1409,9 @@ fork_server(struct Client *server)
|
|||
|
||||
s_assert(server->localClient);
|
||||
server->localClient->ctrlfd = ctrl_fds[0];
|
||||
server->localClient->fd = data_fds[0];
|
||||
server->localClient->F->fd = data_fds[0];
|
||||
|
||||
if(!comm_set_nb(server->localClient->fd))
|
||||
if(!comm_set_nb(server->localClient->F->fd))
|
||||
{
|
||||
report_error(NONB_ERROR_MSG,
|
||||
get_server_name(server, SHOW_IP),
|
||||
|
@ -1428,10 +1428,10 @@ fork_server(struct Client *server)
|
|||
}
|
||||
|
||||
comm_open(server->localClient->ctrlfd, FD_SOCKET, NULL);
|
||||
comm_open(server->localClient->fd, FD_SOCKET, NULL);
|
||||
comm_open(server->localClient->F->fd, FD_SOCKET, NULL);
|
||||
|
||||
read_ctrl_packet(server->localClient->ctrlfd, server);
|
||||
read_packet(server->localClient->fd, server);
|
||||
read_packet(server->localClient->F->fd, server);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1517,7 +1517,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
|
|||
strlcpy(client_p->name, server_p->name, sizeof(client_p->name));
|
||||
strlcpy(client_p->host, server_p->host, sizeof(client_p->host));
|
||||
strlcpy(client_p->sockhost, server_p->host, sizeof(client_p->sockhost));
|
||||
client_p->localClient->fd = fd;
|
||||
client_p->localClient->F->fd = fd;
|
||||
|
||||
/*
|
||||
* Set up the initial server evilness, ripped straight from
|
||||
|
@ -1525,7 +1525,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
|
|||
* -- adrian
|
||||
*/
|
||||
|
||||
if(!comm_set_buffers(client_p->localClient->fd, READBUF_SIZE))
|
||||
if(!comm_set_buffers(client_p->localClient->F->fd, READBUF_SIZE))
|
||||
{
|
||||
report_error(SETBUF_ERROR_MSG,
|
||||
get_server_name(client_p, SHOW_IP),
|
||||
|
@ -1598,7 +1598,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
|
|||
#endif
|
||||
(server_p->aftype == AF_INET ? "IPv4" : "?"));
|
||||
|
||||
comm_connect_tcp(client_p->localClient->fd, server_p->host,
|
||||
comm_connect_tcp(client_p->localClient->F->fd, server_p->host,
|
||||
server_p->port, NULL, 0, serv_connect_callback,
|
||||
client_p, server_p->aftype,
|
||||
ConfigFileEntry.connect_timeout);
|
||||
|
@ -1614,7 +1614,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
|
|||
(server_p->aftype == AF_INET ? "IPv4" : "?"), vhoststr);
|
||||
|
||||
|
||||
comm_connect_tcp(client_p->localClient->fd, server_p->host,
|
||||
comm_connect_tcp(client_p->localClient->F->fd, server_p->host,
|
||||
server_p->port, (struct sockaddr *) &myipnum,
|
||||
GET_SS_LEN(myipnum), serv_connect_callback, client_p,
|
||||
myipnum.ss_family, ConfigFileEntry.connect_timeout);
|
||||
|
@ -1641,7 +1641,7 @@ serv_connect_callback(int fd, int status, void *data)
|
|||
|
||||
/* First, make sure its a real client! */
|
||||
s_assert(client_p != NULL);
|
||||
s_assert(client_p->localClient->fd == fd);
|
||||
s_assert(client_p->localClient->F->fd == fd);
|
||||
|
||||
if(client_p == NULL)
|
||||
return;
|
||||
|
|
|
@ -296,7 +296,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
del_from_client_hash(source_p->name, source_p);
|
||||
strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1);
|
||||
add_to_client_hash(source_p->name, source_p);
|
||||
comm_note(source_p->localClient->fd, "Nick: %s", source_p->name);
|
||||
comm_note(source_p->localClient->F->fd, "Nick: %s", source_p->name);
|
||||
}
|
||||
|
||||
if(!valid_hostname(source_p->host))
|
||||
|
|
|
@ -108,7 +108,7 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf)
|
|||
to->localClient->sendM += 1;
|
||||
me.localClient->sendM += 1;
|
||||
if(linebuf_len(&to->localClient->buf_sendq) > 0)
|
||||
send_queued_write(to->localClient->fd, to);
|
||||
send_queued_write(to->localClient->F->fd, to);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ send_queued_write(int fd, void *data)
|
|||
#ifdef USE_IODEBUG_HOOKS
|
||||
hook_data_int hd;
|
||||
#endif
|
||||
fde_t *F = comm_locate_fd(to->localClient->fd);
|
||||
fde_t *F = comm_locate_fd(to->localClient->F->fd);
|
||||
if (!F)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue