Fossil SCM

Add the (undocumented) --debug-nofork option to "fossil ui" and "fossil server", for use in debugging.

drh 2021-12-26 20:53 ssl-server
Commit ed4a96d8ece279312e5a0ef9037d12e2d577696e89208109ee17d5d8c03e867e
2 files changed +6 -1 +10
+6 -1
--- src/cgi.c
+++ src/cgi.c
@@ -2265,10 +2265,11 @@
22652265
#define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */
22662266
#define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */
22672267
#define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */
22682268
#define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */
22692269
#define HTTP_SERVER_REPOLIST 0x0010 /* Allow repo listing */
2270
+#define HTTP_SERVER_NOFORK 0x0020 /* Do not call fork() */
22702271
22712272
#endif /* INTERFACE */
22722273
22732274
/*
22742275
** Maximum number of child processes that we can have running
@@ -2384,11 +2385,15 @@
23842385
select( listener+1, &readfds, 0, 0, &delay);
23852386
if( FD_ISSET(listener, &readfds) ){
23862387
lenaddr = sizeof(inaddr);
23872388
connection = accept(listener, (struct sockaddr*)&inaddr, &lenaddr);
23882389
if( connection>=0 ){
2389
- child = fork();
2390
+ if( flags & HTTP_SERVER_NOFORK ){
2391
+ child = 0;
2392
+ }else{
2393
+ child = fork();
2394
+ }
23902395
if( child!=0 ){
23912396
if( child>0 ){
23922397
nchildren++;
23932398
nRequest++;
23942399
}
23952400
--- 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 @@
30353035
g.zCkoutAlias = find_option("ckout-alias",0,1);
30363036
g.zMainMenuFile = find_option("mainmenu",0,1);
30373037
if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){
30383038
fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile);
30393039
}
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
+ }
30403050
/* We should be done with options.. */
30413051
verify_all_options();
30423052
30433053
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
30443054
if( isUiCmd && 3==g.argc && file_isdir(g.argv[2], ExtFILE)>0 ){
30453055
--- 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

Keyboard Shortcuts

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