Fossil SCM
Add the (undocumented) --debug-nofork option to "fossil ui" and "fossil server", for use in debugging.
Commit
ed4a96d8ece279312e5a0ef9037d12e2d577696e89208109ee17d5d8c03e867e
Parent
89af3b0a4761df7…
2 files changed
+6
-1
+10
+6
-1
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -2265,10 +2265,11 @@ | ||
| 2265 | 2265 | #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ |
| 2266 | 2266 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 2267 | 2267 | #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */ |
| 2268 | 2268 | #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */ |
| 2269 | 2269 | #define HTTP_SERVER_REPOLIST 0x0010 /* Allow repo listing */ |
| 2270 | +#define HTTP_SERVER_NOFORK 0x0020 /* Do not call fork() */ | |
| 2270 | 2271 | |
| 2271 | 2272 | #endif /* INTERFACE */ |
| 2272 | 2273 | |
| 2273 | 2274 | /* |
| 2274 | 2275 | ** Maximum number of child processes that we can have running |
| @@ -2384,11 +2385,15 @@ | ||
| 2384 | 2385 | select( listener+1, &readfds, 0, 0, &delay); |
| 2385 | 2386 | if( FD_ISSET(listener, &readfds) ){ |
| 2386 | 2387 | lenaddr = sizeof(inaddr); |
| 2387 | 2388 | connection = accept(listener, (struct sockaddr*)&inaddr, &lenaddr); |
| 2388 | 2389 | if( connection>=0 ){ |
| 2389 | - child = fork(); | |
| 2390 | + if( flags & HTTP_SERVER_NOFORK ){ | |
| 2391 | + child = 0; | |
| 2392 | + }else{ | |
| 2393 | + child = fork(); | |
| 2394 | + } | |
| 2390 | 2395 | if( child!=0 ){ |
| 2391 | 2396 | if( child>0 ){ |
| 2392 | 2397 | nchildren++; |
| 2393 | 2398 | nRequest++; |
| 2394 | 2399 | } |
| 2395 | 2400 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2265,10 +2265,11 @@ | |
| 2265 | #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ |
| 2266 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 2267 | #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */ |
| 2268 | #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */ |
| 2269 | #define HTTP_SERVER_REPOLIST 0x0010 /* Allow repo listing */ |
| 2270 | |
| 2271 | #endif /* INTERFACE */ |
| 2272 | |
| 2273 | /* |
| 2274 | ** Maximum number of child processes that we can have running |
| @@ -2384,11 +2385,15 @@ | |
| 2384 | select( listener+1, &readfds, 0, 0, &delay); |
| 2385 | if( FD_ISSET(listener, &readfds) ){ |
| 2386 | lenaddr = sizeof(inaddr); |
| 2387 | connection = accept(listener, (struct sockaddr*)&inaddr, &lenaddr); |
| 2388 | if( connection>=0 ){ |
| 2389 | child = fork(); |
| 2390 | if( child!=0 ){ |
| 2391 | if( child>0 ){ |
| 2392 | nchildren++; |
| 2393 | nRequest++; |
| 2394 | } |
| 2395 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2265,10 +2265,11 @@ | |
| 2265 | #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ |
| 2266 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 2267 | #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */ |
| 2268 | #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */ |
| 2269 | #define HTTP_SERVER_REPOLIST 0x0010 /* Allow repo listing */ |
| 2270 | #define HTTP_SERVER_NOFORK 0x0020 /* Do not call fork() */ |
| 2271 | |
| 2272 | #endif /* INTERFACE */ |
| 2273 | |
| 2274 | /* |
| 2275 | ** Maximum number of child processes that we can have running |
| @@ -2384,11 +2385,15 @@ | |
| 2385 | select( listener+1, &readfds, 0, 0, &delay); |
| 2386 | if( FD_ISSET(listener, &readfds) ){ |
| 2387 | lenaddr = sizeof(inaddr); |
| 2388 | connection = accept(listener, (struct sockaddr*)&inaddr, &lenaddr); |
| 2389 | if( connection>=0 ){ |
| 2390 | if( flags & HTTP_SERVER_NOFORK ){ |
| 2391 | child = 0; |
| 2392 | }else{ |
| 2393 | child = fork(); |
| 2394 | } |
| 2395 | if( child!=0 ){ |
| 2396 | if( child>0 ){ |
| 2397 | nchildren++; |
| 2398 | nRequest++; |
| 2399 | } |
| 2400 |
+10
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -3035,10 +3035,20 @@ | ||
| 3035 | 3035 | g.zCkoutAlias = find_option("ckout-alias",0,1); |
| 3036 | 3036 | g.zMainMenuFile = find_option("mainmenu",0,1); |
| 3037 | 3037 | if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){ |
| 3038 | 3038 | fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile); |
| 3039 | 3039 | } |
| 3040 | + | |
| 3041 | + /* Undocumented option: --debug-nofork | |
| 3042 | + ** | |
| 3043 | + ** This sets the HTTP_SERVER_NOFORK flag, which causes only the | |
| 3044 | + ** very first incoming TCP/IP connection to be processed. Used for | |
| 3045 | + ** debugging, since debugging across a fork() can be tricky | |
| 3046 | + */ | |
| 3047 | + if( find_option("debug-nofork",0,0)!=0 ){ | |
| 3048 | + flags |= HTTP_SERVER_NOFORK; | |
| 3049 | + } | |
| 3040 | 3050 | /* We should be done with options.. */ |
| 3041 | 3051 | verify_all_options(); |
| 3042 | 3052 | |
| 3043 | 3053 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 3044 | 3054 | if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){ |
| 3045 | 3055 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3035,10 +3035,20 @@ | |
| 3035 | g.zCkoutAlias = find_option("ckout-alias",0,1); |
| 3036 | g.zMainMenuFile = find_option("mainmenu",0,1); |
| 3037 | if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){ |
| 3038 | fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile); |
| 3039 | } |
| 3040 | /* We should be done with options.. */ |
| 3041 | verify_all_options(); |
| 3042 | |
| 3043 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 3044 | if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){ |
| 3045 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3035,10 +3035,20 @@ | |
| 3035 | g.zCkoutAlias = find_option("ckout-alias",0,1); |
| 3036 | g.zMainMenuFile = find_option("mainmenu",0,1); |
| 3037 | if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){ |
| 3038 | fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile); |
| 3039 | } |
| 3040 | |
| 3041 | /* Undocumented option: --debug-nofork |
| 3042 | ** |
| 3043 | ** This sets the HTTP_SERVER_NOFORK flag, which causes only the |
| 3044 | ** very first incoming TCP/IP connection to be processed. Used for |
| 3045 | ** debugging, since debugging across a fork() can be tricky |
| 3046 | */ |
| 3047 | if( find_option("debug-nofork",0,0)!=0 ){ |
| 3048 | flags |= HTTP_SERVER_NOFORK; |
| 3049 | } |
| 3050 | /* We should be done with options.. */ |
| 3051 | verify_all_options(); |
| 3052 | |
| 3053 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 3054 | if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){ |
| 3055 |