Fossil SCM

Per /chat discussion, replace load_control() calls in selective pages with nice() and move load_control() into process_one_web_page(). There is still work to do here, e.g. allowing certain pages through (namely /chat, to facilitate coordination of site defense) and perhaps checking credentials if the load is too high and always allowing admin users.

stephan 2022-04-14 16:58 trunk
Commit 9b0ebcaf23572a78e4a842dcde6dba4022af9a38f0cf51e1fad6dbaf64462e0a
+1 -1
--- src/diff.c
+++ src/diff.c
@@ -3594,11 +3594,11 @@
35943594
35953595
/* Gather query parameters */
35963596
login_check_credentials();
35973597
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
35983598
if( exclude_spiders() ) return;
3599
- load_control();
3599
+ fossil_nice_default();
36003600
zFilename = P("filename");
36013601
zRevision = PD("checkin",0);
36023602
zOrigin = P("origin");
36033603
zLimit = P("limit");
36043604
showLog = PB("log");
36053605
--- src/diff.c
+++ src/diff.c
@@ -3594,11 +3594,11 @@
3594
3595 /* Gather query parameters */
3596 login_check_credentials();
3597 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
3598 if( exclude_spiders() ) return;
3599 load_control();
3600 zFilename = P("filename");
3601 zRevision = PD("checkin",0);
3602 zOrigin = P("origin");
3603 zLimit = P("limit");
3604 showLog = PB("log");
3605
--- src/diff.c
+++ src/diff.c
@@ -3594,11 +3594,11 @@
3594
3595 /* Gather query parameters */
3596 login_check_credentials();
3597 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
3598 if( exclude_spiders() ) return;
3599 fossil_nice_default();
3600 zFilename = P("filename");
3601 zRevision = PD("checkin",0);
3602 zOrigin = P("origin");
3603 zLimit = P("limit");
3604 showLog = PB("log");
3605
+1 -1
--- src/info.c
+++ src/info.c
@@ -1182,11 +1182,11 @@
11821182
int bInvert = PB("inv");
11831183
11841184
login_check_credentials();
11851185
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
11861186
login_anonymous_available();
1187
- load_control();
1187
+ fossil_nice_default();
11881188
blob_init(&qp, 0, 0);
11891189
diffType = preferred_diff_type();
11901190
zRe = P("regex");
11911191
if( zRe ) re_compile(&pRe, zRe, 0);
11921192
zBranch = P("branch");
11931193
--- src/info.c
+++ src/info.c
@@ -1182,11 +1182,11 @@
1182 int bInvert = PB("inv");
1183
1184 login_check_credentials();
1185 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1186 login_anonymous_available();
1187 load_control();
1188 blob_init(&qp, 0, 0);
1189 diffType = preferred_diff_type();
1190 zRe = P("regex");
1191 if( zRe ) re_compile(&pRe, zRe, 0);
1192 zBranch = P("branch");
1193
--- src/info.c
+++ src/info.c
@@ -1182,11 +1182,11 @@
1182 int bInvert = PB("inv");
1183
1184 login_check_credentials();
1185 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1186 login_anonymous_available();
1187 fossil_nice_default();
1188 blob_init(&qp, 0, 0);
1189 diffType = preferred_diff_type();
1190 zRe = P("regex");
1191 if( zRe ) re_compile(&pRe, zRe, 0);
1192 zBranch = P("branch");
1193
+2 -2
--- src/json.c
+++ src/json.c
@@ -739,11 +739,11 @@
739739
** been called. In general, this function should be used sparingly,
740740
** e.g. from low-level support functions like fossil_warning() where
741741
** there is genuine uncertainty about whether (or not) the JSON setup
742742
** has already been called.
743743
*/
744
-int json_is_bootstrapped_early(){
744
+int json_is_bootstrapped_early(void){
745745
return ((g.json.gc.v != NULL) && (g.json.gc.a != NULL));
746746
}
747747
748748
/*
749749
** Initializes some JSON bits which need to be initialized relatively
@@ -758,11 +758,11 @@
758758
** up. e.g. it must not use cgi_parameter() and friends because this
759759
** must be called before those data are initialized.
760760
**
761761
** If called multiple times, calls after the first are a no-op.
762762
*/
763
-void json_bootstrap_early(){
763
+void json_bootstrap_early(void){
764764
cson_value * v;
765765
766766
if(g.json.gc.v!=NULL){
767767
/* Avoid multiple bootstrappings. */
768768
return;
769769
--- src/json.c
+++ src/json.c
@@ -739,11 +739,11 @@
739 ** been called. In general, this function should be used sparingly,
740 ** e.g. from low-level support functions like fossil_warning() where
741 ** there is genuine uncertainty about whether (or not) the JSON setup
742 ** has already been called.
743 */
744 int json_is_bootstrapped_early(){
745 return ((g.json.gc.v != NULL) && (g.json.gc.a != NULL));
746 }
747
748 /*
749 ** Initializes some JSON bits which need to be initialized relatively
@@ -758,11 +758,11 @@
758 ** up. e.g. it must not use cgi_parameter() and friends because this
759 ** must be called before those data are initialized.
760 **
761 ** If called multiple times, calls after the first are a no-op.
762 */
763 void json_bootstrap_early(){
764 cson_value * v;
765
766 if(g.json.gc.v!=NULL){
767 /* Avoid multiple bootstrappings. */
768 return;
769
--- src/json.c
+++ src/json.c
@@ -739,11 +739,11 @@
739 ** been called. In general, this function should be used sparingly,
740 ** e.g. from low-level support functions like fossil_warning() where
741 ** there is genuine uncertainty about whether (or not) the JSON setup
742 ** has already been called.
743 */
744 int json_is_bootstrapped_early(void){
745 return ((g.json.gc.v != NULL) && (g.json.gc.a != NULL));
746 }
747
748 /*
749 ** Initializes some JSON bits which need to be initialized relatively
@@ -758,11 +758,11 @@
758 ** up. e.g. it must not use cgi_parameter() and friends because this
759 ** must be called before those data are initialized.
760 **
761 ** If called multiple times, calls after the first are a no-op.
762 */
763 void json_bootstrap_early(void){
764 cson_value * v;
765
766 if(g.json.gc.v!=NULL){
767 /* Avoid multiple bootstrappings. */
768 return;
769
+1 -1
--- src/main.c
+++ src/main.c
@@ -1872,11 +1872,11 @@
18721872
}
18731873
18741874
/* At this point, the appropriate repository database file will have
18751875
** been opened.
18761876
*/
1877
-
1877
+ load_control();
18781878
18791879
/*
18801880
** Check to see if the first term of PATH_INFO specifies an
18811881
** alternative skin. This will be the case if the first term of
18821882
** PATH_INFO begins with "draftN/" where N is an integer between 1
18831883
--- src/main.c
+++ src/main.c
@@ -1872,11 +1872,11 @@
1872 }
1873
1874 /* At this point, the appropriate repository database file will have
1875 ** been opened.
1876 */
1877
1878
1879 /*
1880 ** Check to see if the first term of PATH_INFO specifies an
1881 ** alternative skin. This will be the case if the first term of
1882 ** PATH_INFO begins with "draftN/" where N is an integer between 1
1883
--- src/main.c
+++ src/main.c
@@ -1872,11 +1872,11 @@
1872 }
1873
1874 /* At this point, the appropriate repository database file will have
1875 ** been opened.
1876 */
1877 load_control();
1878
1879 /*
1880 ** Check to see if the first term of PATH_INFO specifies an
1881 ** alternative skin. This will be the case if the first term of
1882 ** PATH_INFO begins with "draftN/" where N is an integer between 1
1883
+1 -1
--- src/stat.c
+++ src/stat.c
@@ -963,11 +963,11 @@
963963
*/
964964
if( !g.perm.Write && !db_get_boolean("artifact_stats_enable",0) ){
965965
login_needed(g.anon.Write);
966966
return;
967967
}
968
- load_control();
968
+ fossil_nice_default();
969969
970970
style_set_current_feature("stat");
971971
style_header("Artifact Statistics");
972972
style_submenu_element("Repository Stats", "stat");
973973
style_submenu_element("Artifact List", "bloblist");
974974
--- src/stat.c
+++ src/stat.c
@@ -963,11 +963,11 @@
963 */
964 if( !g.perm.Write && !db_get_boolean("artifact_stats_enable",0) ){
965 login_needed(g.anon.Write);
966 return;
967 }
968 load_control();
969
970 style_set_current_feature("stat");
971 style_header("Artifact Statistics");
972 style_submenu_element("Repository Stats", "stat");
973 style_submenu_element("Artifact List", "bloblist");
974
--- src/stat.c
+++ src/stat.c
@@ -963,11 +963,11 @@
963 */
964 if( !g.perm.Write && !db_get_boolean("artifact_stats_enable",0) ){
965 login_needed(g.anon.Write);
966 return;
967 }
968 fossil_nice_default();
969
970 style_set_current_feature("stat");
971 style_header("Artifact Statistics");
972 style_submenu_element("Repository Stats", "stat");
973 style_submenu_element("Artifact List", "bloblist");
974
+1 -1
--- src/tar.c
+++ src/tar.c
@@ -756,11 +756,11 @@
756756
Blob tarball; /* Tarball accumulated here */
757757
const char *z;
758758
759759
login_check_credentials();
760760
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
761
- load_control();
761
+ fossil_nice_default();
762762
zName = fossil_strdup(PD("name",""));
763763
z = P("r");
764764
if( z==0 ) z = P("uuid");
765765
if( z==0 ) z = tar_uuid_from_name(&zName);
766766
if( z==0 ) z = "trunk";
767767
--- src/tar.c
+++ src/tar.c
@@ -756,11 +756,11 @@
756 Blob tarball; /* Tarball accumulated here */
757 const char *z;
758
759 login_check_credentials();
760 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
761 load_control();
762 zName = fossil_strdup(PD("name",""));
763 z = P("r");
764 if( z==0 ) z = P("uuid");
765 if( z==0 ) z = tar_uuid_from_name(&zName);
766 if( z==0 ) z = "trunk";
767
--- src/tar.c
+++ src/tar.c
@@ -756,11 +756,11 @@
756 Blob tarball; /* Tarball accumulated here */
757 const char *z;
758
759 login_check_credentials();
760 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
761 fossil_nice_default();
762 zName = fossil_strdup(PD("name",""));
763 z = P("r");
764 if( z==0 ) z = P("uuid");
765 if( z==0 ) z = tar_uuid_from_name(&zName);
766 if( z==0 ) z = "trunk";
767
+19
--- src/util.c
+++ src/util.c
@@ -896,5 +896,24 @@
896896
}
897897
}
898898
#endif
899899
return zBrowser;
900900
}
901
+
902
+/*
903
+** On non-Windows systems, calls nice(2) with the given level. Errors
904
+** are ignored. On Windows this is a no-op.
905
+*/
906
+void fossil_nice(int level){
907
+#ifndef _WIN32
908
+ nice(level);
909
+#else
910
+ (void)level;
911
+#endif
912
+}
913
+
914
+/*
915
+** Calls fossil_nice() with a default level.
916
+*/
917
+void fossil_nice_default(void){
918
+ fossil_nice(20);
919
+}
901920
--- src/util.c
+++ src/util.c
@@ -896,5 +896,24 @@
896 }
897 }
898 #endif
899 return zBrowser;
900 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
901
--- src/util.c
+++ src/util.c
@@ -896,5 +896,24 @@
896 }
897 }
898 #endif
899 return zBrowser;
900 }
901
902 /*
903 ** On non-Windows systems, calls nice(2) with the given level. Errors
904 ** are ignored. On Windows this is a no-op.
905 */
906 void fossil_nice(int level){
907 #ifndef _WIN32
908 nice(level);
909 #else
910 (void)level;
911 #endif
912 }
913
914 /*
915 ** Calls fossil_nice() with a default level.
916 */
917 void fossil_nice_default(void){
918 fossil_nice(20);
919 }
920
+1 -1
--- src/zip.c
+++ src/zip.c
@@ -921,11 +921,11 @@
921921
zType = "SQL";
922922
}else{
923923
eType = ARCHIVE_ZIP;
924924
zType = "ZIP";
925925
}
926
- load_control();
926
+ fossil_nice_default();
927927
zName = fossil_strdup(PD("name",""));
928928
z = P("r");
929929
if( z==0 ) z = P("uuid");
930930
if( z==0 ) z = tar_uuid_from_name(&zName);
931931
if( z==0 ) z = "trunk";
932932
--- src/zip.c
+++ src/zip.c
@@ -921,11 +921,11 @@
921 zType = "SQL";
922 }else{
923 eType = ARCHIVE_ZIP;
924 zType = "ZIP";
925 }
926 load_control();
927 zName = fossil_strdup(PD("name",""));
928 z = P("r");
929 if( z==0 ) z = P("uuid");
930 if( z==0 ) z = tar_uuid_from_name(&zName);
931 if( z==0 ) z = "trunk";
932
--- src/zip.c
+++ src/zip.c
@@ -921,11 +921,11 @@
921 zType = "SQL";
922 }else{
923 eType = ARCHIVE_ZIP;
924 zType = "ZIP";
925 }
926 fossil_nice_default();
927 zName = fossil_strdup(PD("name",""));
928 z = P("r");
929 if( z==0 ) z = P("uuid");
930 if( z==0 ) z = tar_uuid_from_name(&zName);
931 if( z==0 ) z = "trunk";
932

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button