mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Reload the configuration atomically
A reload reads the file into a new configuration, allocated from the defaults, and prepares its services without starting them. Only if the whole file is read without an error does it come into force: the old configuration's services stop accepting, the new ones start. On an error everything prepared is dropped and the old configuration, which never stopped, stays in force. Each service holds its configuration until it is freed, after its last client; a configuration no longer in force is released when the last holder lets go (confhold/confput). freeconf() now only releases what a configuration holds, touching nothing global. What runs without a service of its own reads the configuration in force, runconf, rather than conf, which a reload points at the one being read: the resolver, which holds it while it waits (a client resolves with its own service's), the log, the thread pool, the admin pages, which walk the services under config_mutex, and the signal handlers. The users table, havelog and the resolver choice are per configuration now, the resolver applied when the configuration comes into force, so a refused file leaves the users as they were. The log file, the configuration file name, the string table, daemon mode and the filter list belong to the process and are handed from one configuration to the next. Settings left out of a new file go back to their defaults, where before they kept the old values. The gap between the old and the new listening sockets remains: a connection queued on an old service's socket when it closes is reset. Handing the socket over is the next phase. A test case reloads a broken file (nothing changes, alice still gets in, bob from the refused file does not) and a good one (bob only, the service on its new port, the old one closed, a download through the old service finishing whole). 40 reloads, a third refused, under load show no memory errors under AddressSanitizer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
796e9f8156
commit
21ba6e9d0c
14 files changed
+399
-112
No files matched your search
+6
-2
@@ -225,7 +225,11 @@ extern time_t basetime;
|
||||
extern int timetoexit, needreload;
|
||||
extern time_t curtime; /* the clock, kept by the main thread */
|
||||
|
||||
extern struct extparam *conf;
|
||||
extern struct extparam *conf, *runconf;
|
||||
extern _3proxy_mutex_t confref_mutex;
|
||||
struct extparam * confget(void);
|
||||
void confhold(struct extparam *c);
|
||||
void confput(struct extparam *c);
|
||||
extern const struct extparam confdefaults;
|
||||
extern struct extparam confboot;
|
||||
|
||||
@@ -383,7 +387,6 @@ int parseconnusername(char *username, struct clientparam *param, int extpasswd,
|
||||
int ACLmatches(struct ace* acentry, struct clientparam * param);
|
||||
int checkACL(struct clientparam * param);
|
||||
char * aceaction (int action);
|
||||
extern int havelog;
|
||||
uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_t *retttl, struct clientparam* param, int makeauth);
|
||||
|
||||
struct ace * copyacl (struct ace *ac);
|
||||
@@ -393,6 +396,7 @@ void freeacl(struct ace *ac);
|
||||
void freeauth(struct auth *);
|
||||
void freefilter(struct filter *filter);
|
||||
void freeconf(struct extparam *confp);
|
||||
void confbegin(void);
|
||||
struct passwords * copypwl (struct passwords *pwl);
|
||||
void freepwl(struct passwords *pw);
|
||||
int copyfilter(struct filter *, struct srvparam *srv);
|
||||
|
||||
Reference in new issue
Block a user