]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Replace int fd; in local client object with an fde object.
authorWilliam Pitcock <redacted>
Fri, 28 Dec 2007 21:06:33 +0000 (15:06 -0600)
committerWilliam Pitcock <redacted>
Fri, 28 Dec 2007 21:06:33 +0000 (15:06 -0600)
14 files changed:
include/client.h
libcharybdis/commio.h
modules/core/m_nick.c
modules/m_services.c
modules/m_signon.c
src/client.c
src/listener.c
src/packet.c
src/parse.c
src/reject.c
src/s_auth.c
src/s_serv.c
src/s_user.c
src/send.c

index 20f9bfcbe9e28cb92c87e5e52c68c831e947be26..36d99cfd42f6aaf7a4d697005f38295f09927c0d 100644 (file)
@@ -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;
index a22db1ad785847abef0c45c96fd80397a8910384..db65ca0c59a2ace9ea065b1a57fd609ce38aefd1 100644 (file)
@@ -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 */
index 336b8521e2358aa9fcc6d52d1709e2d74e921a2e..a624d4b3d60f485fb6b0e5dd5d116154d286fdde 100644 (file)
@@ -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;
 }
index 5108f58a89a99051077f0eb85b52b4c68abe9088..dbfd064d6618b32c6833966125fca656a9afa13c 100644 (file)
@@ -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;
 }
 
index a4340be950b23614a93563ca5779c82cae6d3003..c2220326b23ad0e76084f20c11c8d7b18f166d4b 100644 (file)
@@ -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;
index 81be16f7be5d17fc69da9a18e2e8cf9682b7de3e..959483379c08a3110276be1fdb1f1e55186ceda5 100644 (file)
@@ -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);
 
index ec676e841abdd0e120196c00c9e8b5e768542e9e..2333680bf4faeab33aaba615ddd3a5df5c555498 100644 (file)
@@ -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;
index 5e06c80318ab8ccb41e218aa249bf3873ce60962..f7c47b4f9beae9e9df16e49e2ed57ca8b8bb3e2f 100644 (file)
@@ -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);
        }
 }
index 7e622408589f4eeee4990411e10c685cb878fb02..7e3ebecc7ffe97972450d66e2520c2cef86ea15f 100644 (file)
@@ -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;
 
index 1e1ceb72a8bd1d5a891cd117f88561fff4afcb0f..f763c41d305abbaeb7005d02e2a200decec6a0df 100644 (file)
@@ -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;
index aae2eb65f3a49ae4aa6470da224be06a88ef799d..5c57ed2f378e822327f74e8b1204058f9427ac04 100644 (file)
@@ -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",
index 0b13f3e7eb57ad57c9e99827ac7d62b34dff3851..c33820f83761f960b8b55dbf8df7e46feda24dc9 100644 (file)
@@ -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;
index 598a6642cd479c09a4f21a981392e24cf621777e..a163a1a53d92e0ef3c8faffb54b853af40e505a2 100644 (file)
@@ -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))
index 732efb053cfc00e439535049b42f93ca747f0d8b..c094cdf97d74b4ef89e5898e1b25a930f7460c74 100644 (file)
@@ -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;