Fossil SCM
Attempt to make JSON subsystem initialization work better.
Commit
920a64286dd5e8792ed03fe85fab57e950bea31628eb11e896ef485420b1a0b6
Parent
ad0679cabf78e2b…
3 files changed
+1
-1
+2
-2
+4
+1
-1
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -1065,11 +1065,11 @@ | ||
| 1065 | 1065 | const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0); |
| 1066 | 1066 | #endif |
| 1067 | 1067 | |
| 1068 | 1068 | #ifdef FOSSIL_ENABLE_JSON |
| 1069 | 1069 | int noJson = P("no_json")!=0; |
| 1070 | - if( noJson==0 ){ json_main_bootstrap(); } | |
| 1070 | + if( noJson==0 ){ json_main_bootstrap(); json_mode_bootstrap(); } | |
| 1071 | 1071 | #endif |
| 1072 | 1072 | g.isHTTP = 1; |
| 1073 | 1073 | cgi_destination(CGI_BODY); |
| 1074 | 1074 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 1075 | 1075 | #ifdef _WIN32 |
| 1076 | 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(); } |
| 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 @@ | ||
| 942 | 942 | ** This must be called by the top-level JSON command dispatching code |
| 943 | 943 | ** before they do any work. |
| 944 | 944 | ** |
| 945 | 945 | ** This must only be called once, or an assertion may be triggered. |
| 946 | 946 | */ |
| 947 | -static void json_mode_bootstrap(){ | |
| 947 | +void json_mode_bootstrap(){ | |
| 948 | 948 | static char once = 0 /* guard against multiple runs */; |
| 949 | 949 | char const * zPath = P("PATH_INFO"); |
| 950 | 950 | assert(g.json.gc.a && "json_main_bootstrap() was not called!"); |
| 951 | 951 | assert( (0==once) && "json_mode_bootstrap() called too many times!"); |
| 952 | 952 | if( once ){ |
| @@ -2274,11 +2274,11 @@ | ||
| 2274 | 2274 | ** json_cmd_top(). |
| 2275 | 2275 | */ |
| 2276 | 2276 | void json_page_top(void){ |
| 2277 | 2277 | char const * zCommand; |
| 2278 | 2278 | 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!"); | |
| 2280 | 2280 | zCommand = json_command_arg(1); |
| 2281 | 2281 | if(!zCommand || !*zCommand){ |
| 2282 | 2282 | json_dispatch_missing_args_err( JsonPageDefs, |
| 2283 | 2283 | "No command (sub-path) specified." |
| 2284 | 2284 | " Try one of: "); |
| 2285 | 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 | 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 @@ | ||
| 2554 | 2554 | |
| 2555 | 2555 | /* |
| 2556 | 2556 | ** Process all requests in a single SSH connection if possible. |
| 2557 | 2557 | */ |
| 2558 | 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 | |
| 2559 | 2563 | blob_zero(&g.cgiIn); |
| 2560 | 2564 | do{ |
| 2561 | 2565 | cgi_handle_ssh_http_request(zIpAddr); |
| 2562 | 2566 | process_one_web_page(0, FileGlob, 0); |
| 2563 | 2567 | blob_reset(&g.cgiIn); |
| 2564 | 2568 |
| --- 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 |