aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
authorGravatar Lukas Fleischer <cgit@cryptocrack.de>2014-01-16 05:53:15 (JST)
committerGravatar Jason A. Donenfeld <Jason@zx2c4.com>2014-01-17 08:44:54 (JST)
commitf60ffa143cca61e9729ac71033e1a556cf422871 (patch)
treeff9122fef2779ddea8e37806cc66dc67b63df99f /cgit.c
parenta431326e8fab8153905fbde036dd3c9fb4cc8eaa (diff)
downloadcgit-f60ffa143cca61e9729ac71033e1a556cf422871.zip
cgit-f60ffa143cca61e9729ac71033e1a556cf422871.tar.gz
Switch to exclusively using global ctx
Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c322
1 files changed, 161 insertions, 161 deletions
diff --git a/cgit.c b/cgit.c
index 994957f..ec8f69c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -322,82 +322,82 @@ static void querystring_cb(const char *name, const char *value)
322 } 322 }
323} 323}
324 324
325static void prepare_context(struct cgit_context *ctx) 325static void prepare_context(void)
326{ 326{
327 memset(ctx, 0, sizeof(*ctx)); 327 memset(&ctx, 0, sizeof(ctx));
328 ctx->cfg.agefile = "info/web/last-modified"; 328 ctx.cfg.agefile = "info/web/last-modified";
329 ctx->cfg.nocache = 0; 329 ctx.cfg.nocache = 0;
330 ctx->cfg.cache_size = 0; 330 ctx.cfg.cache_size = 0;
331 ctx->cfg.cache_max_create_time = 5; 331 ctx.cfg.cache_max_create_time = 5;
332 ctx->cfg.cache_root = CGIT_CACHE_ROOT; 332 ctx.cfg.cache_root = CGIT_CACHE_ROOT;
333 ctx->cfg.cache_about_ttl = 15; 333 ctx.cfg.cache_about_ttl = 15;
334 ctx->cfg.cache_repo_ttl = 5; 334 ctx.cfg.cache_repo_ttl = 5;
335 ctx->cfg.cache_root_ttl = 5; 335 ctx.cfg.cache_root_ttl = 5;
336 ctx->cfg.cache_scanrc_ttl = 15; 336 ctx.cfg.cache_scanrc_ttl = 15;
337 ctx->cfg.cache_dynamic_ttl = 5; 337 ctx.cfg.cache_dynamic_ttl = 5;
338 ctx->cfg.cache_static_ttl = -1; 338 ctx.cfg.cache_static_ttl = -1;
339 ctx->cfg.case_sensitive_sort = 1; 339 ctx.cfg.case_sensitive_sort = 1;
340 ctx->cfg.branch_sort = 0; 340 ctx.cfg.branch_sort = 0;
341 ctx->cfg.commit_sort = 0; 341 ctx.cfg.commit_sort = 0;
342 ctx->cfg.css = "/cgit.css"; 342 ctx.cfg.css = "/cgit.css";
343 ctx->cfg.logo = "/cgit.png"; 343 ctx.cfg.logo = "/cgit.png";
344 ctx->cfg.favicon = "/favicon.ico"; 344 ctx.cfg.favicon = "/favicon.ico";
345 ctx->cfg.local_time = 0; 345 ctx.cfg.local_time = 0;
346 ctx->cfg.enable_http_clone = 1; 346 ctx.cfg.enable_http_clone = 1;
347 ctx->cfg.enable_index_owner = 1; 347 ctx.cfg.enable_index_owner = 1;
348 ctx->cfg.enable_tree_linenumbers = 1; 348 ctx.cfg.enable_tree_linenumbers = 1;
349 ctx->cfg.enable_git_config = 0; 349 ctx.cfg.enable_git_config = 0;
350 ctx->cfg.max_repo_count = 50; 350 ctx.cfg.max_repo_count = 50;
351 ctx->cfg.max_commit_count = 50; 351 ctx.cfg.max_commit_count = 50;
352 ctx->cfg.max_lock_attempts = 5; 352 ctx.cfg.max_lock_attempts = 5;
353 ctx->cfg.max_msg_len = 80; 353 ctx.cfg.max_msg_len = 80;
354 ctx->cfg.max_repodesc_len = 80; 354 ctx.cfg.max_repodesc_len = 80;
355 ctx->cfg.max_blob_size = 0; 355 ctx.cfg.max_blob_size = 0;
356 ctx->cfg.max_stats = 0; 356 ctx.cfg.max_stats = 0;
357 ctx->cfg.project_list = NULL; 357 ctx.cfg.project_list = NULL;
358 ctx->cfg.renamelimit = -1; 358 ctx.cfg.renamelimit = -1;
359 ctx->cfg.remove_suffix = 0; 359 ctx.cfg.remove_suffix = 0;
360 ctx->cfg.robots = "index, nofollow"; 360 ctx.cfg.robots = "index, nofollow";
361 ctx->cfg.root_title = "Git repository browser"; 361 ctx.cfg.root_title = "Git repository browser";
362 ctx->cfg.root_desc = "a fast webinterface for the git dscm"; 362 ctx.cfg.root_desc = "a fast webinterface for the git dscm";
363 ctx->cfg.scan_hidden_path = 0; 363 ctx.cfg.scan_hidden_path = 0;
364 ctx->cfg.script_name = CGIT_SCRIPT_NAME; 364 ctx.cfg.script_name = CGIT_SCRIPT_NAME;
365 ctx->cfg.section = ""; 365 ctx.cfg.section = "";
366 ctx->cfg.repository_sort = "name"; 366 ctx.cfg.repository_sort = "name";
367 ctx->cfg.section_sort = 1; 367 ctx.cfg.section_sort = 1;
368 ctx->cfg.summary_branches = 10; 368 ctx.cfg.summary_branches = 10;
369 ctx->cfg.summary_log = 10; 369 ctx.cfg.summary_log = 10;
370 ctx->cfg.summary_tags = 10; 370 ctx.cfg.summary_tags = 10;
371 ctx->cfg.max_atom_items = 10; 371 ctx.cfg.max_atom_items = 10;
372 ctx->cfg.ssdiff = 0; 372 ctx.cfg.ssdiff = 0;
373 ctx->env.cgit_config = getenv("CGIT_CONFIG"); 373 ctx.env.cgit_config = getenv("CGIT_CONFIG");
374 ctx->env.http_host = getenv("HTTP_HOST"); 374 ctx.env.http_host = getenv("HTTP_HOST");
375 ctx->env.https = getenv("HTTPS"); 375 ctx.env.https = getenv("HTTPS");
376 ctx->env.no_http = getenv("NO_HTTP"); 376 ctx.env.no_http = getenv("NO_HTTP");
377 ctx->env.path_info = getenv("PATH_INFO"); 377 ctx.env.path_info = getenv("PATH_INFO");
378 ctx->env.query_string = getenv("QUERY_STRING"); 378 ctx.env.query_string = getenv("QUERY_STRING");
379 ctx->env.request_method = getenv("REQUEST_METHOD"); 379 ctx.env.request_method = getenv("REQUEST_METHOD");
380 ctx->env.script_name = getenv("SCRIPT_NAME"); 380 ctx.env.script_name = getenv("SCRIPT_NAME");
381 ctx->env.server_name = getenv("SERVER_NAME"); 381 ctx.env.server_name = getenv("SERVER_NAME");
382 ctx->env.server_port = getenv("SERVER_PORT"); 382 ctx.env.server_port = getenv("SERVER_PORT");
383 ctx->env.http_cookie = getenv("HTTP_COOKIE"); 383 ctx.env.http_cookie = getenv("HTTP_COOKIE");
384 ctx->env.http_referer = getenv("HTTP_REFERER"); 384 ctx.env.http_referer = getenv("HTTP_REFERER");
385 ctx->env.content_length = getenv("CONTENT_LENGTH") ? strtoul(getenv("CONTENT_LENGTH"), NULL, 10) : 0; 385 ctx.env.content_length = getenv("CONTENT_LENGTH") ? strtoul(getenv("CONTENT_LENGTH"), NULL, 10) : 0;
386 ctx->env.authenticated = 0; 386 ctx.env.authenticated = 0;
387 ctx->page.mimetype = "text/html"; 387 ctx.page.mimetype = "text/html";
388 ctx->page.charset = PAGE_ENCODING; 388 ctx.page.charset = PAGE_ENCODING;
389 ctx->page.filename = NULL; 389 ctx.page.filename = NULL;
390 ctx->page.size = 0; 390 ctx.page.size = 0;
391 ctx->page.modified = time(NULL); 391 ctx.page.modified = time(NULL);
392 ctx->page.expires = ctx->page.modified; 392 ctx.page.expires = ctx.page.modified;
393 ctx->page.etag = NULL; 393 ctx.page.etag = NULL;
394 memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); 394 memset(&ctx.cfg.mimetypes, 0, sizeof(struct string_list));
395 if (ctx->env.script_name) 395 if (ctx.env.script_name)
396 ctx->cfg.script_name = xstrdup(ctx->env.script_name); 396 ctx.cfg.script_name = xstrdup(ctx.env.script_name);
397 if (ctx->env.query_string) 397 if (ctx.env.query_string)
398 ctx->qry.raw = xstrdup(ctx->env.query_string); 398 ctx.qry.raw = xstrdup(ctx.env.query_string);
399 if (!ctx->env.cgit_config) 399 if (!ctx.env.cgit_config)
400 ctx->env.cgit_config = CGIT_CONFIG; 400 ctx.env.cgit_config = CGIT_CONFIG;
401} 401}
402 402
403struct refmatch { 403struct refmatch {
@@ -527,14 +527,14 @@ static void choose_readme(struct cgit_repo *repo)
527 string_list_append(&repo->readme, filename)->util = ref; 527 string_list_append(&repo->readme, filename)->util = ref;
528} 528}
529 529
530static int prepare_repo_cmd(struct cgit_context *ctx) 530static int prepare_repo_cmd(void)
531{ 531{
532 unsigned char sha1[20]; 532 unsigned char sha1[20];
533 int nongit = 0; 533 int nongit = 0;
534 int rc; 534 int rc;
535 535
536 /* The path to the git repository. */ 536 /* The path to the git repository. */
537 setenv("GIT_DIR", ctx->repo->path, 1); 537 setenv("GIT_DIR", ctx.repo->path, 1);
538 538
539 /* Do not look in /etc/ for gitconfig and gitattributes. */ 539 /* Do not look in /etc/ for gitconfig and gitattributes. */
540 setenv("GIT_CONFIG_NOSYSTEM", "1", 1); 540 setenv("GIT_CONFIG_NOSYSTEM", "1", 1);
@@ -549,69 +549,69 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
549 init_display_notes(NULL); 549 init_display_notes(NULL);
550 550
551 if (nongit) { 551 if (nongit) {
552 const char *name = ctx->repo->name; 552 const char *name = ctx.repo->name;
553 rc = errno; 553 rc = errno;
554 ctx->page.title = fmtalloc("%s - %s", ctx->cfg.root_title, 554 ctx.page.title = fmtalloc("%s - %s", ctx.cfg.root_title,
555 "config error"); 555 "config error");
556 ctx->repo = NULL; 556 ctx.repo = NULL;
557 cgit_print_http_headers(ctx); 557 cgit_print_http_headers();
558 cgit_print_docstart(ctx); 558 cgit_print_docstart();
559 cgit_print_pageheader(ctx); 559 cgit_print_pageheader();
560 cgit_print_error("Failed to open %s: %s", name, 560 cgit_print_error("Failed to open %s: %s", name,
561 rc ? strerror(rc) : "Not a valid git repository"); 561 rc ? strerror(rc) : "Not a valid git repository");
562 cgit_print_docend(); 562 cgit_print_docend();
563 return 1; 563 return 1;
564 } 564 }
565 ctx->page.title = fmtalloc("%s - %s", ctx->repo->name, ctx->repo->desc); 565 ctx.page.title = fmtalloc("%s - %s", ctx.repo->name, ctx.repo->desc);
566 566
567 if (!ctx->repo->defbranch) 567 if (!ctx.repo->defbranch)
568 ctx->repo->defbranch = guess_defbranch(); 568 ctx.repo->defbranch = guess_defbranch();
569 569
570 if (!ctx->qry.head) { 570 if (!ctx.qry.head) {
571 ctx->qry.nohead = 1; 571 ctx.qry.nohead = 1;
572 ctx->qry.head = find_default_branch(ctx->repo); 572 ctx.qry.head = find_default_branch(ctx.repo);
573 } 573 }
574 574
575 if (!ctx->qry.head) { 575 if (!ctx.qry.head) {
576 cgit_print_http_headers(ctx); 576 cgit_print_http_headers();
577 cgit_print_docstart(ctx); 577 cgit_print_docstart();
578 cgit_print_pageheader(ctx); 578 cgit_print_pageheader();
579 cgit_print_error("Repository seems to be empty"); 579 cgit_print_error("Repository seems to be empty");
580 cgit_print_docend(); 580 cgit_print_docend();
581 return 1; 581 return 1;
582 } 582 }
583 583
584 if (get_sha1(ctx->qry.head, sha1)) { 584 if (get_sha1(ctx.qry.head, sha1)) {
585 char *tmp = xstrdup(ctx->qry.head); 585 char *tmp = xstrdup(ctx.qry.head);
586 ctx->qry.head = ctx->repo->defbranch; 586 ctx.qry.head = ctx.repo->defbranch;
587 ctx->page.status = 404; 587 ctx.page.status = 404;
588 ctx->page.statusmsg = "Not found"; 588 ctx.page.statusmsg = "Not found";
589 cgit_print_http_headers(ctx); 589 cgit_print_http_headers();
590 cgit_print_docstart(ctx); 590 cgit_print_docstart();
591 cgit_print_pageheader(ctx); 591 cgit_print_pageheader();
592 cgit_print_error("Invalid branch: %s", tmp); 592 cgit_print_error("Invalid branch: %s", tmp);
593 cgit_print_docend(); 593 cgit_print_docend();
594 return 1; 594 return 1;
595 } 595 }
596 sort_string_list(&ctx->repo->submodules); 596 sort_string_list(&ctx.repo->submodules);
597 cgit_prepare_repo_env(ctx->repo); 597 cgit_prepare_repo_env(ctx.repo);
598 choose_readme(ctx->repo); 598 choose_readme(ctx.repo);
599 return 0; 599 return 0;
600} 600}
601 601
602static inline void open_auth_filter(struct cgit_context *ctx, const char *function) 602static inline void open_auth_filter(const char *function)
603{ 603{
604 cgit_open_filter(ctx->cfg.auth_filter, function, 604 cgit_open_filter(ctx.cfg.auth_filter, function,
605 ctx->env.http_cookie ? ctx->env.http_cookie : "", 605 ctx.env.http_cookie ? ctx.env.http_cookie : "",
606 ctx->env.request_method ? ctx->env.request_method : "", 606 ctx.env.request_method ? ctx.env.request_method : "",
607 ctx->env.query_string ? ctx->env.query_string : "", 607 ctx.env.query_string ? ctx.env.query_string : "",
608 ctx->env.http_referer ? ctx->env.http_referer : "", 608 ctx.env.http_referer ? ctx.env.http_referer : "",
609 ctx->env.path_info ? ctx->env.path_info : "", 609 ctx.env.path_info ? ctx.env.path_info : "",
610 ctx->env.http_host ? ctx->env.http_host : "", 610 ctx.env.http_host ? ctx.env.http_host : "",
611 ctx->env.https ? ctx->env.https : "", 611 ctx.env.https ? ctx.env.https : "",
612 ctx->qry.repo ? ctx->qry.repo : "", 612 ctx.qry.repo ? ctx.qry.repo : "",
613 ctx->qry.page ? ctx->qry.page : "", 613 ctx.qry.page ? ctx.qry.page : "",
614 ctx->qry.url ? ctx->qry.url : "", 614 ctx.qry.url ? ctx.qry.url : "",
615 cgit_loginurl()); 615 cgit_loginurl());
616} 616}
617 617
@@ -622,107 +622,106 @@ static inline void open_auth_filter(struct cgit_context *ctx, const char *functi
622 * will complain on the mailing list, and we'll increase it as needed. */ 622 * will complain on the mailing list, and we'll increase it as needed. */
623#define MAX_AUTHENTICATION_POST_BYTES 4096 623#define MAX_AUTHENTICATION_POST_BYTES 4096
624/* The filter is expected to spit out "Status: " and all headers. */ 624/* The filter is expected to spit out "Status: " and all headers. */
625static inline void authenticate_post(struct cgit_context *ctx) 625static inline void authenticate_post(void)
626{ 626{
627 char buffer[MAX_AUTHENTICATION_POST_BYTES]; 627 char buffer[MAX_AUTHENTICATION_POST_BYTES];
628 int len; 628 int len;
629 629
630 open_auth_filter(ctx, "authenticate-post"); 630 open_auth_filter("authenticate-post");
631 len = ctx->env.content_length; 631 len = ctx.env.content_length;
632 if (len > MAX_AUTHENTICATION_POST_BYTES) 632 if (len > MAX_AUTHENTICATION_POST_BYTES)
633 len = MAX_AUTHENTICATION_POST_BYTES; 633 len = MAX_AUTHENTICATION_POST_BYTES;
634 if (read(STDIN_FILENO, buffer, len) < 0) 634 if (read(STDIN_FILENO, buffer, len) < 0)
635 die_errno("Could not read POST from stdin"); 635 die_errno("Could not read POST from stdin");
636 if (write(STDOUT_FILENO, buffer, len) < 0) 636 if (write(STDOUT_FILENO, buffer, len) < 0)
637 die_errno("Could not write POST to stdout"); 637 die_errno("Could not write POST to stdout");
638 cgit_close_filter(ctx->cfg.auth_filter); 638 cgit_close_filter(ctx.cfg.auth_filter);
639 exit(0); 639 exit(0);
640} 640}
641 641
642static inline void authenticate_cookie(struct cgit_context *ctx) 642static inline void authenticate_cookie(void)
643{ 643{
644 /* If we don't have an auth_filter, consider all cookies valid, and thus return early. */ 644 /* If we don't have an auth_filter, consider all cookies valid, and thus return early. */
645 if (!ctx->cfg.auth_filter) { 645 if (!ctx.cfg.auth_filter) {
646 ctx->env.authenticated = 1; 646 ctx.env.authenticated = 1;
647 return; 647 return;
648 } 648 }
649 649
650 /* If we're having something POST'd to /login, we're authenticating POST, 650 /* If we're having something POST'd to /login, we're authenticating POST,
651 * instead of the cookie, so call authenticate_post and bail out early. 651 * instead of the cookie, so call authenticate_post and bail out early.
652 * This pattern here should match /?p=login with POST. */ 652 * This pattern here should match /?p=login with POST. */
653 if (ctx->env.request_method && ctx->qry.page && !ctx->repo && \ 653 if (ctx.env.request_method && ctx.qry.page && !ctx.repo && \
654 !strcmp(ctx->env.request_method, "POST") && !strcmp(ctx->qry.page, "login")) { 654 !strcmp(ctx.env.request_method, "POST") && !strcmp(ctx.qry.page, "login")) {
655 authenticate_post(ctx); 655 authenticate_post();
656 return; 656 return;
657 } 657 }
658 658
659 /* If we've made it this far, we're authenticating the cookie for real, so do that. */ 659 /* If we've made it this far, we're authenticating the cookie for real, so do that. */
660 open_auth_filter(ctx, "authenticate-cookie"); 660 open_auth_filter("authenticate-cookie");
661 ctx->env.authenticated = cgit_close_filter(ctx->cfg.auth_filter); 661 ctx.env.authenticated = cgit_close_filter(ctx.cfg.auth_filter);
662} 662}
663 663
664static void process_request(void *cbdata) 664static void process_request(void)
665{ 665{
666 struct cgit_context *ctx = cbdata;
667 struct cgit_cmd *cmd; 666 struct cgit_cmd *cmd;
668 667
669 /* If we're not yet authenticated, no matter what page we're on, 668 /* If we're not yet authenticated, no matter what page we're on,
670 * display the authentication body from the auth_filter. This should 669 * display the authentication body from the auth_filter. This should
671 * never be cached. */ 670 * never be cached. */
672 if (!ctx->env.authenticated) { 671 if (!ctx.env.authenticated) {
673 ctx->page.title = "Authentication Required"; 672 ctx.page.title = "Authentication Required";
674 cgit_print_http_headers(ctx); 673 cgit_print_http_headers();
675 cgit_print_docstart(ctx); 674 cgit_print_docstart();
676 cgit_print_pageheader(ctx); 675 cgit_print_pageheader();
677 open_auth_filter(ctx, "body"); 676 open_auth_filter("body");
678 cgit_close_filter(ctx->cfg.auth_filter); 677 cgit_close_filter(ctx.cfg.auth_filter);
679 cgit_print_docend(); 678 cgit_print_docend();
680 return; 679 return;
681 } 680 }
682 681
683 cmd = cgit_get_cmd(ctx); 682 cmd = cgit_get_cmd();
684 if (!cmd) { 683 if (!cmd) {
685 ctx->page.title = "cgit error"; 684 ctx.page.title = "cgit error";
686 ctx->page.status = 404; 685 ctx.page.status = 404;
687 ctx->page.statusmsg = "Not found"; 686 ctx.page.statusmsg = "Not found";
688 cgit_print_http_headers(ctx); 687 cgit_print_http_headers();
689 cgit_print_docstart(ctx); 688 cgit_print_docstart();
690 cgit_print_pageheader(ctx); 689 cgit_print_pageheader();
691 cgit_print_error("Invalid request"); 690 cgit_print_error("Invalid request");
692 cgit_print_docend(); 691 cgit_print_docend();
693 return; 692 return;
694 } 693 }
695 694
696 if (!ctx->cfg.enable_http_clone && cmd->is_clone) { 695 if (!ctx.cfg.enable_http_clone && cmd->is_clone) {
697 html_status(404, "Not found", 0); 696 html_status(404, "Not found", 0);
698 return; 697 return;
699 } 698 }
700 699
701 /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual" 700 /* If cmd->want_vpath is set, assume ctx.qry.path contains a "virtual"
702 * in-project path limit to be made available at ctx->qry.vpath. 701 * in-project path limit to be made available at ctx.qry.vpath.
703 * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL). 702 * Otherwise, no path limit is in effect (ctx.qry.vpath = NULL).
704 */ 703 */
705 ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL; 704 ctx.qry.vpath = cmd->want_vpath ? ctx.qry.path : NULL;
706 705
707 if (cmd->want_repo && !ctx->repo) { 706 if (cmd->want_repo && !ctx.repo) {
708 cgit_print_http_headers(ctx); 707 cgit_print_http_headers();
709 cgit_print_docstart(ctx); 708 cgit_print_docstart();
710 cgit_print_pageheader(ctx); 709 cgit_print_pageheader();
711 cgit_print_error("No repository selected"); 710 cgit_print_error("No repository selected");
712 cgit_print_docend(); 711 cgit_print_docend();
713 return; 712 return;
714 } 713 }
715 714
716 if (ctx->repo && prepare_repo_cmd(ctx)) 715 if (ctx.repo && prepare_repo_cmd())
717 return; 716 return;
718 717
719 if (cmd->want_layout) { 718 if (cmd->want_layout) {
720 cgit_print_http_headers(ctx); 719 cgit_print_http_headers();
721 cgit_print_docstart(ctx); 720 cgit_print_docstart();
722 cgit_print_pageheader(ctx); 721 cgit_print_pageheader();
723 } 722 }
724 723
725 cmd->fn(ctx); 724 cmd->fn();
726 725
727 if (cmd->want_layout) 726 if (cmd->want_layout)
728 cgit_print_docend(); 727 cgit_print_docend();
@@ -995,7 +994,7 @@ int main(int argc, const char **argv)
995 cgit_init_filters(); 994 cgit_init_filters();
996 atexit(cgit_cleanup_filters); 995 atexit(cgit_cleanup_filters);
997 996
998 prepare_context(&ctx); 997 prepare_context();
999 cgit_repolist.length = 0; 998 cgit_repolist.length = 0;
1000 cgit_repolist.count = 0; 999 cgit_repolist.count = 0;
1001 cgit_repolist.repos = NULL; 1000 cgit_repolist.repos = NULL;
@@ -1034,7 +1033,7 @@ int main(int argc, const char **argv)
1034 /* Before we go any further, we set ctx.env.authenticated by checking to see 1033 /* Before we go any further, we set ctx.env.authenticated by checking to see
1035 * if the supplied cookie is valid. All cookies are valid if there is no 1034 * if the supplied cookie is valid. All cookies are valid if there is no
1036 * auth_filter. If there is an auth_filter, the filter decides. */ 1035 * auth_filter. If there is an auth_filter, the filter decides. */
1037 authenticate_cookie(&ctx); 1036 authenticate_cookie();
1038 1037
1039 ttl = calc_ttl(); 1038 ttl = calc_ttl();
1040 if (ttl < 0) 1039 if (ttl < 0)
@@ -1046,7 +1045,8 @@ int main(int argc, const char **argv)
1046 if (ctx.cfg.nocache) 1045 if (ctx.cfg.nocache)
1047 ctx.cfg.cache_size = 0; 1046 ctx.cfg.cache_size = 0;
1048 err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root, 1047 err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root,
1049 ctx.qry.raw, ttl, process_request, &ctx); 1048 ctx.qry.raw, ttl, process_request);
1049 cgit_cleanup_filters();
1050 if (err) 1050 if (err)
1051 cgit_print_error("Error processing page: %s (%d)", 1051 cgit_print_error("Error processing page: %s (%d)",
1052 strerror(err), err); 1052 strerror(err), err);