Fossil SCM

Attempt to make JSON subsystem initialization work better.

mistachkin 2020-06-11 23:40 jsonTestsPass
Commit 920a64286dd5e8792ed03fe85fab57e950bea31628eb11e896ef485420b1a0b6
3 files changed +1 -1 +2 -2 +4
+1 -1
--- src/cgi.c
+++ src/cgi.c
@@ -1065,11 +1065,11 @@
10651065
const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0);
10661066
#endif
10671067
10681068
#ifdef FOSSIL_ENABLE_JSON
10691069
int noJson = P("no_json")!=0;
1070
- if( noJson==0 ){ json_main_bootstrap(); }
1070
+ if( noJson==0 ){ json_main_bootstrap(); json_mode_bootstrap(); }
10711071
#endif
10721072
g.isHTTP = 1;
10731073
cgi_destination(CGI_BODY);
10741074
if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME");
10751075
#ifdef _WIN32
10761076
--- src/cgi.c
+++ src/cgi.c
@@ -1065,11 +1065,11 @@
1065 const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0);
1066 #endif
1067
1068 #ifdef FOSSIL_ENABLE_JSON
1069 int noJson = P("no_json")!=0;
1070 if( noJson==0 ){ json_main_bootstrap(); }
1071 #endif
1072 g.isHTTP = 1;
1073 cgi_destination(CGI_BODY);
1074 if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME");
1075 #ifdef _WIN32
1076
--- src/cgi.c
+++ src/cgi.c
@@ -1065,11 +1065,11 @@
1065 const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0);
1066 #endif
1067
1068 #ifdef FOSSIL_ENABLE_JSON
1069 int noJson = P("no_json")!=0;
1070 if( noJson==0 ){ json_main_bootstrap(); json_mode_bootstrap(); }
1071 #endif
1072 g.isHTTP = 1;
1073 cgi_destination(CGI_BODY);
1074 if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME");
1075 #ifdef _WIN32
1076
+2 -2
--- src/json.c
+++ src/json.c
@@ -942,11 +942,11 @@
942942
** This must be called by the top-level JSON command dispatching code
943943
** before they do any work.
944944
**
945945
** This must only be called once, or an assertion may be triggered.
946946
*/
947
-static void json_mode_bootstrap(){
947
+void json_mode_bootstrap(){
948948
static char once = 0 /* guard against multiple runs */;
949949
char const * zPath = P("PATH_INFO");
950950
assert(g.json.gc.a && "json_main_bootstrap() was not called!");
951951
assert( (0==once) && "json_mode_bootstrap() called too many times!");
952952
if( once ){
@@ -2274,11 +2274,11 @@
22742274
** json_cmd_top().
22752275
*/
22762276
void json_page_top(void){
22772277
char const * zCommand;
22782278
assert(g.json.gc.a && "json_main_bootstrap() was not called!");
2279
- json_mode_bootstrap();
2279
+ assert(g.json.cmd.a && "json_mode_bootstrap() was not called!");
22802280
zCommand = json_command_arg(1);
22812281
if(!zCommand || !*zCommand){
22822282
json_dispatch_missing_args_err( JsonPageDefs,
22832283
"No command (sub-path) specified."
22842284
" Try one of: ");
22852285
--- src/json.c
+++ src/json.c
@@ -942,11 +942,11 @@
942 ** This must be called by the top-level JSON command dispatching code
943 ** before they do any work.
944 **
945 ** This must only be called once, or an assertion may be triggered.
946 */
947 static void json_mode_bootstrap(){
948 static char once = 0 /* guard against multiple runs */;
949 char const * zPath = P("PATH_INFO");
950 assert(g.json.gc.a && "json_main_bootstrap() was not called!");
951 assert( (0==once) && "json_mode_bootstrap() called too many times!");
952 if( once ){
@@ -2274,11 +2274,11 @@
2274 ** json_cmd_top().
2275 */
2276 void json_page_top(void){
2277 char const * zCommand;
2278 assert(g.json.gc.a && "json_main_bootstrap() was not called!");
2279 json_mode_bootstrap();
2280 zCommand = json_command_arg(1);
2281 if(!zCommand || !*zCommand){
2282 json_dispatch_missing_args_err( JsonPageDefs,
2283 "No command (sub-path) specified."
2284 " Try one of: ");
2285
--- src/json.c
+++ src/json.c
@@ -942,11 +942,11 @@
942 ** This must be called by the top-level JSON command dispatching code
943 ** before they do any work.
944 **
945 ** This must only be called once, or an assertion may be triggered.
946 */
947 void json_mode_bootstrap(){
948 static char once = 0 /* guard against multiple runs */;
949 char const * zPath = P("PATH_INFO");
950 assert(g.json.gc.a && "json_main_bootstrap() was not called!");
951 assert( (0==once) && "json_mode_bootstrap() called too many times!");
952 if( once ){
@@ -2274,11 +2274,11 @@
2274 ** json_cmd_top().
2275 */
2276 void json_page_top(void){
2277 char const * zCommand;
2278 assert(g.json.gc.a && "json_main_bootstrap() was not called!");
2279 assert(g.json.cmd.a && "json_mode_bootstrap() was not called!");
2280 zCommand = json_command_arg(1);
2281 if(!zCommand || !*zCommand){
2282 json_dispatch_missing_args_err( JsonPageDefs,
2283 "No command (sub-path) specified."
2284 " Try one of: ");
2285
+4
--- src/main.c
+++ src/main.c
@@ -2554,10 +2554,14 @@
25542554
25552555
/*
25562556
** Process all requests in a single SSH connection if possible.
25572557
*/
25582558
void ssh_request_loop(const char *zIpAddr, Glob *FileGlob){
2559
+#ifdef FOSSIL_ENABLE_JSON
2560
+ int noJson = P("no_json")!=0;
2561
+ if( noJson==0 ){ json_main_bootstrap(); json_mode_bootstrap(); }
2562
+#endif
25592563
blob_zero(&g.cgiIn);
25602564
do{
25612565
cgi_handle_ssh_http_request(zIpAddr);
25622566
process_one_web_page(0, FileGlob, 0);
25632567
blob_reset(&g.cgiIn);
25642568
--- src/main.c
+++ src/main.c
@@ -2554,10 +2554,14 @@
2554
2555 /*
2556 ** Process all requests in a single SSH connection if possible.
2557 */
2558 void ssh_request_loop(const char *zIpAddr, Glob *FileGlob){
 
 
 
 
2559 blob_zero(&g.cgiIn);
2560 do{
2561 cgi_handle_ssh_http_request(zIpAddr);
2562 process_one_web_page(0, FileGlob, 0);
2563 blob_reset(&g.cgiIn);
2564
--- src/main.c
+++ src/main.c
@@ -2554,10 +2554,14 @@
2554
2555 /*
2556 ** Process all requests in a single SSH connection if possible.
2557 */
2558 void ssh_request_loop(const char *zIpAddr, Glob *FileGlob){
2559 #ifdef FOSSIL_ENABLE_JSON
2560 int noJson = P("no_json")!=0;
2561 if( noJson==0 ){ json_main_bootstrap(); json_mode_bootstrap(); }
2562 #endif
2563 blob_zero(&g.cgiIn);
2564 do{
2565 cgi_handle_ssh_http_request(zIpAddr);
2566 process_one_web_page(0, FileGlob, 0);
2567 blob_reset(&g.cgiIn);
2568

Keyboard Shortcuts

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