X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=blobdiff_plain;f=ircd%2Fs_bsd.c;h=fb842764a4152c36de12749765db47110bcb908e;hp=00f7d8edc42ddba7005a0037bb8def01a6e72bed;hb=5fc729d47823a57c8e6e0e3b078522eccd120ca7;hpb=98c74ba6a77e8f110f03252eead8cd37e7ecc83e diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index 00f7d8e..fb84276 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -459,6 +459,34 @@ void close_connection(struct Client *cptr) } } +/** + * Switches a client's connection over to a different, zombied client. + * + * @param source client to attach to zombied client + * @param target zombied client + */ +void connection_switch_to_client(struct Client *source, struct Client *target) +{ + assert(IsNotConn(target)); + assert(MyConnect(source)); + assert(-1 < cli_fd(source)); + cli_connect(target) = cli_connect(source); + /* conveniently, this makes it much easier to get rid of source later on */ + cli_from(target) = target; + LocalClientArray[cli_fd(source)] = target; + + /* make main loop remove source soonish */ + SetFlag(source, FLAG_DEADSOCKET); + + /* need to copy over data from old client */ + cli_user(target)->server = cli_user(source)->server; + strcpy(cli_yxx(target), cli_yxx(source)); + cli_hopcount(target) = cli_hopcount(source); + cli_ip(target) = cli_ip(source); + strcpy(cli_username(target), cli_username(source)); + strcpy(cli_user(target)->realhost, cli_user(source)->realhost); +} + /** Close all unregistered connections. * @param source Oper who requested the close. * @return Number of closed connections.