mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 19:03:12 +02:00
Change int rehash() to void request_rehash(), which is a better name
as it REQUESTS to rehash the server, but it may not be done immediately. And making it void makes sure nobody relies on some sort of return value which will differ between with vs without remote includes. Also get rid of sig and loop.rehash_save_sig, as a NULL client already indicates the same (or at least does so now).
This commit is contained in:
+1
-1
@@ -452,7 +452,7 @@ extern void report_dynconf(Client *client);
|
||||
extern void count_memory(Client *cptr, char *nick);
|
||||
extern void list_scache(Client *client);
|
||||
extern char *oflagstr(long oflag);
|
||||
extern int rehash(Client *client, int sig);
|
||||
extern void request_rehash(Client *client);
|
||||
extern void s_die();
|
||||
extern int match_simple(const char *mask, const char *name);
|
||||
extern int match_esc(const char *mask, const char *name);
|
||||
|
||||
@@ -864,7 +864,6 @@ struct LoopStruct {
|
||||
unsigned config_load_failed : 1;
|
||||
unsigned tainted : 1;
|
||||
Client *rehash_save_client;
|
||||
int rehash_save_sig;
|
||||
void (*boot_function)();
|
||||
};
|
||||
|
||||
|
||||
+21
-12
@@ -259,7 +259,7 @@ void update_remote_include(ConfigItem_include *inc, const char *file, int, const
|
||||
int remote_include(ConfigEntry *ce);
|
||||
#endif
|
||||
void free_all_includes(void);
|
||||
int rehash_internal(Client *client, int sig);
|
||||
int rehash_internal(Client *client);
|
||||
int is_blacklisted_module(char *name);
|
||||
|
||||
/** Return the printable string of a 'cep' location, such as set::something::xyz */
|
||||
@@ -10713,42 +10713,51 @@ static void conf_download_complete(const char *url, const char *file, const char
|
||||
* startup loop where it also checks is_config_read_finished().
|
||||
*/
|
||||
if (loop.rehashing && is_config_read_finished())
|
||||
rehash_internal(loop.rehash_save_client, loop.rehash_save_sig);
|
||||
rehash_internal(loop.rehash_save_client);
|
||||
}
|
||||
#endif
|
||||
|
||||
int rehash(Client *client, int sig)
|
||||
/** Request to REHASH the configuration file.
|
||||
* There is no guarantee that the request will be done immediately
|
||||
* (eg: it won't in case of remote includes).
|
||||
* @param client The client requesting the /REHASH.
|
||||
* If this is NULL then the rehash was requested
|
||||
* via a signal to the process or GUI.
|
||||
*/
|
||||
void request_rehash(Client *client)
|
||||
{
|
||||
#ifdef USE_LIBCURL
|
||||
ConfigItem_include *inc;
|
||||
char found_remote = 0;
|
||||
if (loop.rehashing)
|
||||
{
|
||||
if (!sig)
|
||||
if (client)
|
||||
sendnotice(client, "A rehash is already in progress");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
loop.rehashing = 1;
|
||||
loop.rehash_save_client = client;
|
||||
loop.rehash_save_sig = sig;
|
||||
config_read_start();
|
||||
/* If we already have everything, then can we proceed with the rehash */
|
||||
if (is_config_read_finished())
|
||||
return rehash_internal(client, sig);
|
||||
/* Otherwise, return here, I/O events will take care of it later
|
||||
{
|
||||
rehash_internal(client);
|
||||
return;
|
||||
}
|
||||
/* Otherwise, I/O events will take care of it later
|
||||
* after all remote includes have been downloaded.
|
||||
*/
|
||||
return 0;
|
||||
#else
|
||||
loop.rehashing = 1;
|
||||
return rehash_internal(client, sig);
|
||||
rehash_internal(client);
|
||||
#endif
|
||||
}
|
||||
|
||||
int rehash_internal(Client *client, int sig)
|
||||
int rehash_internal(Client *client)
|
||||
{
|
||||
if (sig == 1)
|
||||
/* Log it here if it is by a signal */
|
||||
if (client == NULL)
|
||||
unreal_log(ULOG_INFO, "config", "CONFIG_RELOAD", client, "Rehashing server configuration file [./unrealircd rehash]");
|
||||
|
||||
loop.rehashing = 1; /* double checking.. */
|
||||
|
||||
+1
-1
@@ -1241,7 +1241,7 @@ void SocketLoop(void *dummy)
|
||||
*/
|
||||
if (dorehash)
|
||||
{
|
||||
(void)rehash(&me, 1);
|
||||
request_rehash(NULL);
|
||||
dorehash = 0;
|
||||
}
|
||||
if (dorestart)
|
||||
|
||||
+2
-2
@@ -508,7 +508,7 @@ extern void reinit_resolver(Client *client);
|
||||
*/
|
||||
CMD_FUNC(cmd_rehash)
|
||||
{
|
||||
int x = 0;
|
||||
int x;
|
||||
|
||||
/* This is one of the (few) commands that cannot be handled
|
||||
* by labeled-response accurately in all circumstances.
|
||||
@@ -643,7 +643,7 @@ CMD_FUNC(cmd_rehash)
|
||||
|
||||
/* Normal rehash, rehash motds&rules too, just like the on in the tld block will :p */
|
||||
sendnumeric(client, RPL_REHASHING, configfile);
|
||||
x = rehash(client, 0);
|
||||
request_rehash(client);
|
||||
}
|
||||
|
||||
/** RESTART command - restart the server (discouraged command)
|
||||
|
||||
+2
-3
@@ -581,13 +581,12 @@ LRESULT CALLBACK MainDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case IDM_RHALL:
|
||||
MessageBox(NULL, "Rehashing all files", "Rehashing", MB_OK);
|
||||
sendto_realops("Rehashing all files via the console");
|
||||
rehash(&me,0);
|
||||
reread_motdsandrules();
|
||||
request_rehash(NULL);
|
||||
break;
|
||||
case IDM_RHCONF:
|
||||
MessageBox(NULL, "Rehashing the Config file", "Rehashing", MB_OK);
|
||||
sendto_realops("Rehashing the Config file via the console");
|
||||
rehash(&me,0);
|
||||
request_rehash(NULL);
|
||||
break;
|
||||
case IDM_RHMOTD:
|
||||
{
|
||||
|
||||
@@ -77,8 +77,7 @@ VOID WINAPI IRCDCtrlHandler(DWORD opcode)
|
||||
/* Rehash */
|
||||
else if (opcode == IRCD_SERVICE_CONTROL_REHASH)
|
||||
{
|
||||
rehash(&me,0);
|
||||
reread_motdsandrules();
|
||||
request_rehash(NULL);
|
||||
}
|
||||
|
||||
SetServiceStatus(IRCDStatusHandle, &IRCDStatus);
|
||||
|
||||
Reference in New Issue
Block a user