Skip to content

Commit

Permalink
Clear serverlist prior to rehash
Browse files Browse the repository at this point in the history
Found by: tabb

Because of the new addserver command (instead of old 'set servers {} ), every time a bot is rehashed, the config file is re-read and addserver would again add the already-added servers to the bot's internal server list, causing duplicates to appear.
  • Loading branch information
vanosg committed Feb 28, 2020
1 parent 3522119 commit c87f52c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/mod/server.mod/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,14 @@ static void server_5minutely()

static void server_prerehash()
{
struct server_list *x = serverlist;
char port[7];

strlcpy(oldnick, botname, sizeof oldnick);
for (; x; x = x->next) {
egg_snprintf(port, sizeof port, "%d", x->port);
del_server(x->name, port);
}
}

static void server_postrehash()
Expand Down
4 changes: 2 additions & 2 deletions src/mod/server.mod/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
#define exclusive_binds (*(int *)(server_funcs[39]))
/* 40 - 43 */
#define H_out (*(p_tcl_bind_list *)(server_funcs[40]))
#define addserver ((void(*)(char *))server_funcs[41])
#define delserver ((void(*)(char *))server_funcs[42])
/* Was (briefly!) addserver */
/* Was (briefly!) delserver */
#define net_type_int (*(int *)(server_funcs[43]))
#endif /* MAKING_SERVER */

Expand Down

0 comments on commit c87f52c

Please sign in to comment.