Browse Source

[core] initialize globals at top of main()

initialize globals (including file-scoped static globals) at top of main
personal/stbuehler/mod-csrf
Glenn Strauss 4 years ago
parent
commit
b0c66266d9
  1. 6
      src/chunk.c
  2. 1
      src/chunk.h
  3. 1
      src/fdevent_libev.c
  4. 8
      src/http_auth.c
  5. 2
      src/http_auth.h
  6. 5
      src/http_vhostdb.c
  7. 2
      src/http_vhostdb.h
  8. 17
      src/server.c

6
src/chunk.c

@ -29,6 +29,12 @@
static array *chunkqueue_default_tempdirs = NULL;
static unsigned int chunkqueue_default_tempfile_size = DEFAULT_TEMPFILE_SIZE;
void chunkqueue_set_tempdirs_default_reset (void)
{
chunkqueue_default_tempdirs = NULL;
chunkqueue_default_tempfile_size = DEFAULT_TEMPFILE_SIZE;
}
chunkqueue *chunkqueue_init(void) {
chunkqueue *cq;

1
src/chunk.h

@ -50,6 +50,7 @@ typedef struct {
} chunkqueue;
chunkqueue *chunkqueue_init(void);
void chunkqueue_set_tempdirs_default_reset (void);
void chunkqueue_set_tempdirs_default (array *tempdirs, unsigned int upload_temp_file_size);
void chunkqueue_append_file(chunkqueue *cq, buffer *fn, off_t offset, off_t len); /* copies "fn" */
void chunkqueue_append_file_fd(chunkqueue *cq, buffer *fn, int fd, off_t offset, off_t len); /* copies "fn" */

1
src/fdevent_libev.c

@ -136,6 +136,7 @@ static int fdevent_libev_reset(fdevents *ev) {
int fdevent_libev_init(fdevents *ev) {
struct ev_timer * const timer = &timeout_watcher;
memset(timer, 0, sizeof(*timer));
ev->type = FDEVENT_HANDLER_LIBEV;
#define SET(x) \

8
src/http_auth.c

@ -48,6 +48,14 @@ void http_auth_backend_set (const http_auth_backend_t *backend)
memcpy(http_auth_backends+i, backend, sizeof(http_auth_backend_t));
}
void http_auth_dumbdata_reset (void)
{
memset(http_auth_schemes, 0, sizeof(http_auth_schemes));
memset(http_auth_backends, 0, sizeof(http_auth_backends));
}
http_auth_require_t * http_auth_require_init (void)
{
http_auth_require_t *require = calloc(1, sizeof(http_auth_require_t));

2
src/http_auth.h

@ -4,6 +4,8 @@
#include "base.h"
void http_auth_dumbdata_reset (void);
struct http_auth_scheme_t;
struct http_auth_require_t;
struct http_auth_backend_t;

5
src/http_vhostdb.c

@ -7,6 +7,11 @@
static http_vhostdb_backend_t http_vhostdb_backends[8];
void http_vhostdb_dumbdata_reset (void)
{
memset(http_vhostdb_backends, 0, sizeof(http_vhostdb_backends));
}
const http_vhostdb_backend_t * http_vhostdb_backend_get (const buffer *name)
{
int i = 0;

2
src/http_vhostdb.h

@ -4,6 +4,8 @@
#include "base.h"
void http_vhostdb_dumbdata_reset (void);
struct http_vhostdb_backend_t;
typedef struct http_vhostdb_backend_t {

17
src/server.c

@ -9,7 +9,9 @@
#include "response.h"
#include "request.h"
#include "chunk.h"
#include "http_auth.h"
#include "http_chunk.h"
#include "http_vhostdb.h"
#include "fdevent.h"
#include "connections.h"
#include "stat_cache.h"
@ -752,6 +754,17 @@ int main (int argc, char **argv) {
}
#endif
/* initialize globals (including file-scoped static globals) */
oneshot_fd = 0;
srv_shutdown = 0;
graceful_shutdown = 0;
handle_sig_alarm = 1;
handle_sig_hup = 0;
forwarded_sig_hup = 0;
chunkqueue_set_tempdirs_default_reset();
http_auth_dumbdata_reset();
http_vhostdb_dumbdata_reset();
/* for nice %b handling in strfime() */
setlocale(LC_TIME, "C");
@ -1127,6 +1140,10 @@ int main (int argc, char **argv) {
sigaction(SIGPIPE, &act, NULL);
sigaction(SIGUSR1, &act, NULL);
# if defined(SA_SIGINFO)
last_sighup_info.si_uid = 0,
last_sighup_info.si_pid = 0;
last_sigterm_info.si_uid = 0,
last_sigterm_info.si_pid = 0;
act.sa_sigaction = sigaction_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;

Loading…
Cancel
Save