Fossil SCM

Another attempt to adjust JSON session lifecycle.

mistachkin 2020-06-12 20:57 jsonTestsPass
Commit a34c7b37f274b652304160f7ca802785788e38e425d147707f9dc52eea625926
-16
--- src/cgi.c
+++ src/cgi.c
@@ -1109,11 +1109,10 @@
11091109
** we are operating in JSON mode or not. We cannot, however, be
11101110
** certain whether we should/need to be in JSON mode until the
11111111
** PATH_INFO is set up.
11121112
*/
11131113
g.json.isJsonMode = 1;
1114
- json_mode_bootstrap();
11151114
}else{
11161115
assert(!g.json.isJsonMode &&
11171116
"Internal misconfiguration of g.json.isJsonMode");
11181117
}
11191118
#endif
@@ -1813,25 +1812,10 @@
18131812
18141813
for(i=0; zToken[i] && zToken[i]!='?'; i++){}
18151814
if( zToken[i] ) zToken[i++] = 0;
18161815
if( nCycles==0 ){
18171816
cgi_setenv("PATH_INFO", zToken);
1818
-#ifdef FOSSIL_ENABLE_JSON
1819
- if(strncmp("/json",zToken,5)==0
1820
- && (zToken[5]==0 || zToken[5]=='/')){
1821
- /* We need to change some following behaviour depending on whether
1822
- ** we are operating in JSON mode or not. We cannot, however, be
1823
- ** certain whether we should/need to be in JSON mode until the
1824
- ** PATH_INFO is set up.
1825
- */
1826
- g.json.isJsonMode = 1;
1827
- json_mode_bootstrap();
1828
- }else{
1829
- assert(!g.json.isJsonMode &&
1830
- "Internal misconfiguration of g.json.isJsonMode");
1831
- }
1832
-#endif
18331817
}else{
18341818
cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken));
18351819
}
18361820
18371821
/* Get all the optional fields that follow the first line.
18381822
--- src/cgi.c
+++ src/cgi.c
@@ -1109,11 +1109,10 @@
1109 ** we are operating in JSON mode or not. We cannot, however, be
1110 ** certain whether we should/need to be in JSON mode until the
1111 ** PATH_INFO is set up.
1112 */
1113 g.json.isJsonMode = 1;
1114 json_mode_bootstrap();
1115 }else{
1116 assert(!g.json.isJsonMode &&
1117 "Internal misconfiguration of g.json.isJsonMode");
1118 }
1119 #endif
@@ -1813,25 +1812,10 @@
1813
1814 for(i=0; zToken[i] && zToken[i]!='?'; i++){}
1815 if( zToken[i] ) zToken[i++] = 0;
1816 if( nCycles==0 ){
1817 cgi_setenv("PATH_INFO", zToken);
1818 #ifdef FOSSIL_ENABLE_JSON
1819 if(strncmp("/json",zToken,5)==0
1820 && (zToken[5]==0 || zToken[5]=='/')){
1821 /* We need to change some following behaviour depending on whether
1822 ** we are operating in JSON mode or not. We cannot, however, be
1823 ** certain whether we should/need to be in JSON mode until the
1824 ** PATH_INFO is set up.
1825 */
1826 g.json.isJsonMode = 1;
1827 json_mode_bootstrap();
1828 }else{
1829 assert(!g.json.isJsonMode &&
1830 "Internal misconfiguration of g.json.isJsonMode");
1831 }
1832 #endif
1833 }else{
1834 cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken));
1835 }
1836
1837 /* Get all the optional fields that follow the first line.
1838
--- src/cgi.c
+++ src/cgi.c
@@ -1109,11 +1109,10 @@
1109 ** we are operating in JSON mode or not. We cannot, however, be
1110 ** certain whether we should/need to be in JSON mode until the
1111 ** PATH_INFO is set up.
1112 */
1113 g.json.isJsonMode = 1;
 
1114 }else{
1115 assert(!g.json.isJsonMode &&
1116 "Internal misconfiguration of g.json.isJsonMode");
1117 }
1118 #endif
@@ -1813,25 +1812,10 @@
1812
1813 for(i=0; zToken[i] && zToken[i]!='?'; i++){}
1814 if( zToken[i] ) zToken[i++] = 0;
1815 if( nCycles==0 ){
1816 cgi_setenv("PATH_INFO", zToken);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1817 }else{
1818 cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken));
1819 }
1820
1821 /* Get all the optional fields that follow the first line.
1822
+5
--- src/db.c
+++ src/db.c
@@ -78,10 +78,15 @@
7878
va_start(ap, zFormat);
7979
z = vmprintf(zFormat, ap);
8080
va_end(ap);
8181
#ifdef FOSSIL_ENABLE_JSON
8282
if( g.json.isJsonMode ){
83
+ /*
84
+ ** Avoid calling into the JSON support subsystem if it
85
+ ** has not yet been initialized, e.g. early SQLite log
86
+ ** messages, etc.
87
+ */
8388
if( !json_is_main_boostrapped() ) json_main_bootstrap();
8489
json_err( 0, z, 1 );
8590
}
8691
else
8792
#endif /* FOSSIL_ENABLE_JSON */
8893
--- src/db.c
+++ src/db.c
@@ -78,10 +78,15 @@
78 va_start(ap, zFormat);
79 z = vmprintf(zFormat, ap);
80 va_end(ap);
81 #ifdef FOSSIL_ENABLE_JSON
82 if( g.json.isJsonMode ){
 
 
 
 
 
83 if( !json_is_main_boostrapped() ) json_main_bootstrap();
84 json_err( 0, z, 1 );
85 }
86 else
87 #endif /* FOSSIL_ENABLE_JSON */
88
--- src/db.c
+++ src/db.c
@@ -78,10 +78,15 @@
78 va_start(ap, zFormat);
79 z = vmprintf(zFormat, ap);
80 va_end(ap);
81 #ifdef FOSSIL_ENABLE_JSON
82 if( g.json.isJsonMode ){
83 /*
84 ** Avoid calling into the JSON support subsystem if it
85 ** has not yet been initialized, e.g. early SQLite log
86 ** messages, etc.
87 */
88 if( !json_is_main_boostrapped() ) json_main_bootstrap();
89 json_err( 0, z, 1 );
90 }
91 else
92 #endif /* FOSSIL_ENABLE_JSON */
93
+5
--- src/main.c
+++ src/main.c
@@ -1915,10 +1915,15 @@
19151915
@ <h1>Server Configuration Error</h1>
19161916
@ <p>The database schema on the server is out-of-date. Please ask
19171917
@ the administrator to run <b>fossil rebuild</b>.</p>
19181918
}
19191919
}else{
1920
+#ifdef FOSSIL_ENABLE_JSON
1921
+ if( g.json.isJsonMode ){
1922
+ json_mode_bootstrap();
1923
+ }
1924
+#endif
19201925
if( (pCmd->eCmdFlags & CMDFLAG_RAWCONTENT)==0 ){
19211926
cgi_decode_post_parameters();
19221927
}
19231928
if( g.fCgiTrace ){
19241929
fossil_trace("######## Calling %s #########\n", pCmd->zName);
19251930
--- src/main.c
+++ src/main.c
@@ -1915,10 +1915,15 @@
1915 @ <h1>Server Configuration Error</h1>
1916 @ <p>The database schema on the server is out-of-date. Please ask
1917 @ the administrator to run <b>fossil rebuild</b>.</p>
1918 }
1919 }else{
 
 
 
 
 
1920 if( (pCmd->eCmdFlags & CMDFLAG_RAWCONTENT)==0 ){
1921 cgi_decode_post_parameters();
1922 }
1923 if( g.fCgiTrace ){
1924 fossil_trace("######## Calling %s #########\n", pCmd->zName);
1925
--- src/main.c
+++ src/main.c
@@ -1915,10 +1915,15 @@
1915 @ <h1>Server Configuration Error</h1>
1916 @ <p>The database schema on the server is out-of-date. Please ask
1917 @ the administrator to run <b>fossil rebuild</b>.</p>
1918 }
1919 }else{
1920 #ifdef FOSSIL_ENABLE_JSON
1921 if( g.json.isJsonMode ){
1922 json_mode_bootstrap();
1923 }
1924 #endif
1925 if( (pCmd->eCmdFlags & CMDFLAG_RAWCONTENT)==0 ){
1926 cgi_decode_post_parameters();
1927 }
1928 if( g.fCgiTrace ){
1929 fossil_trace("######## Calling %s #########\n", pCmd->zName);
1930
+10 -5
--- src/printf.c
+++ src/printf.c
@@ -1076,10 +1076,15 @@
10761076
** Write error message output
10771077
*/
10781078
static int fossil_print_error(int rc, const char *z){
10791079
#ifdef FOSSIL_ENABLE_JSON
10801080
if( g.json.isJsonMode ){
1081
+ /*
1082
+ ** Avoid calling into the JSON support subsystem if it
1083
+ ** has not yet been initialized, e.g. early SQLite log
1084
+ ** messages, etc.
1085
+ */
10811086
if( !json_is_main_boostrapped() ) json_main_bootstrap();
10821087
json_err( 0, z, 1 );
10831088
if( g.isHTTP && !g.json.preserveRc ){
10841089
rc = 0 /* avoid HTTP 500 */;
10851090
}
@@ -1191,16 +1196,16 @@
11911196
va_start(ap, zFormat);
11921197
z = vmprintf(zFormat, ap);
11931198
va_end(ap);
11941199
fossil_errorlog("warning: %s", z);
11951200
#ifdef FOSSIL_ENABLE_JSON
1196
- /*
1197
- ** Avoid calling into the JSON support subsystem if it
1198
- ** has not yet been initialized, e.g. early SQLite log
1199
- ** messages, etc.
1200
- */
12011201
if(g.json.isJsonMode){
1202
+ /*
1203
+ ** Avoid calling into the JSON support subsystem if it
1204
+ ** has not yet been initialized, e.g. early SQLite log
1205
+ ** messages, etc.
1206
+ */
12021207
if( !json_is_main_boostrapped() ) json_main_bootstrap();
12031208
json_warn( FSL_JSON_W_UNKNOWN, "%s", z );
12041209
}else
12051210
#endif
12061211
{
12071212
--- src/printf.c
+++ src/printf.c
@@ -1076,10 +1076,15 @@
1076 ** Write error message output
1077 */
1078 static int fossil_print_error(int rc, const char *z){
1079 #ifdef FOSSIL_ENABLE_JSON
1080 if( g.json.isJsonMode ){
 
 
 
 
 
1081 if( !json_is_main_boostrapped() ) json_main_bootstrap();
1082 json_err( 0, z, 1 );
1083 if( g.isHTTP && !g.json.preserveRc ){
1084 rc = 0 /* avoid HTTP 500 */;
1085 }
@@ -1191,16 +1196,16 @@
1191 va_start(ap, zFormat);
1192 z = vmprintf(zFormat, ap);
1193 va_end(ap);
1194 fossil_errorlog("warning: %s", z);
1195 #ifdef FOSSIL_ENABLE_JSON
1196 /*
1197 ** Avoid calling into the JSON support subsystem if it
1198 ** has not yet been initialized, e.g. early SQLite log
1199 ** messages, etc.
1200 */
1201 if(g.json.isJsonMode){
 
 
 
 
 
1202 if( !json_is_main_boostrapped() ) json_main_bootstrap();
1203 json_warn( FSL_JSON_W_UNKNOWN, "%s", z );
1204 }else
1205 #endif
1206 {
1207
--- src/printf.c
+++ src/printf.c
@@ -1076,10 +1076,15 @@
1076 ** Write error message output
1077 */
1078 static int fossil_print_error(int rc, const char *z){
1079 #ifdef FOSSIL_ENABLE_JSON
1080 if( g.json.isJsonMode ){
1081 /*
1082 ** Avoid calling into the JSON support subsystem if it
1083 ** has not yet been initialized, e.g. early SQLite log
1084 ** messages, etc.
1085 */
1086 if( !json_is_main_boostrapped() ) json_main_bootstrap();
1087 json_err( 0, z, 1 );
1088 if( g.isHTTP && !g.json.preserveRc ){
1089 rc = 0 /* avoid HTTP 500 */;
1090 }
@@ -1191,16 +1196,16 @@
1196 va_start(ap, zFormat);
1197 z = vmprintf(zFormat, ap);
1198 va_end(ap);
1199 fossil_errorlog("warning: %s", z);
1200 #ifdef FOSSIL_ENABLE_JSON
 
 
 
 
 
1201 if(g.json.isJsonMode){
1202 /*
1203 ** Avoid calling into the JSON support subsystem if it
1204 ** has not yet been initialized, e.g. early SQLite log
1205 ** messages, etc.
1206 */
1207 if( !json_is_main_boostrapped() ) json_main_bootstrap();
1208 json_warn( FSL_JSON_W_UNKNOWN, "%s", z );
1209 }else
1210 #endif
1211 {
1212
--- src/th_main.c
+++ src/th_main.c
@@ -128,10 +128,11 @@
128128
** it for use.
129129
*/
130130
void Th_InitTraceLog(){
131131
g.thTrace = find_option("th-trace", 0, 0)!=0;
132132
if( g.thTrace ){
133
+ g.fAnyTrace = 1;
133134
blob_zero(&g.thLog);
134135
}
135136
}
136137
137138
/*
138139
--- src/th_main.c
+++ src/th_main.c
@@ -128,10 +128,11 @@
128 ** it for use.
129 */
130 void Th_InitTraceLog(){
131 g.thTrace = find_option("th-trace", 0, 0)!=0;
132 if( g.thTrace ){
 
133 blob_zero(&g.thLog);
134 }
135 }
136
137 /*
138
--- src/th_main.c
+++ src/th_main.c
@@ -128,10 +128,11 @@
128 ** it for use.
129 */
130 void Th_InitTraceLog(){
131 g.thTrace = find_option("th-trace", 0, 0)!=0;
132 if( g.thTrace ){
133 g.fAnyTrace = 1;
134 blob_zero(&g.thLog);
135 }
136 }
137
138 /*
139

Keyboard Shortcuts

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