Fossil SCM

Minor code simplification and cleanup for the HTTP server launch in the "fossil ui" and similar commands.

drh 2021-08-26 13:41 trunk
Commit 2f122aac73f6b628be41489c01bb6c7ec454868cf941efd48cd3aca8a92ea837
1 file changed +5 -9
+5 -9
--- src/main.c
+++ src/main.c
@@ -3122,15 +3122,18 @@
31223122
}
31233123
pclose(sshIn);
31243124
fossil_free(zBrowserCmd);
31253125
return;
31263126
}
3127
-#if !defined(_WIN32)
3128
- /* Unix implementation */
31293127
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
31303128
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
31313129
db_close(1);
3130
+
3131
+ /* Start up an HTTP server
3132
+ */
3133
+#if !defined(_WIN32)
3134
+ /* Unix implementation */
31323135
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
31333136
fossil_fatal("unable to listen on TCP socket %d", iPort);
31343137
}
31353138
/* For the parent process, the cgi_http_server() command above never
31363139
** returns (except in the case of an error). Instead, for each incoming
@@ -3146,16 +3149,12 @@
31463149
}else{
31473150
fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT);
31483151
}
31493152
g.httpIn = stdin;
31503153
g.httpOut = stdout;
3151
-
3152
-#if !defined(_WIN32)
31533154
signal(SIGSEGV, sigsegv_handler);
31543155
signal(SIGPIPE, sigpipe_handler);
3155
-#endif
3156
-
31573156
if( g.fAnyTrace ){
31583157
fprintf(stderr, "/***** Subprocess %d *****/\n", getpid());
31593158
}
31603159
g.cgiOutput = 1;
31613160
find_server_repository(2, 0);
@@ -3174,13 +3173,10 @@
31743173
fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
31753174
getpid());
31763175
}
31773176
#else
31783177
/* Win32 implementation */
3179
- if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3180
- if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3181
- db_close(1);
31823178
if( allowRepoList ){
31833179
flags |= HTTP_SERVER_REPOLIST;
31843180
}
31853181
if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
31863182
win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile,
31873183
--- src/main.c
+++ src/main.c
@@ -3122,15 +3122,18 @@
3122 }
3123 pclose(sshIn);
3124 fossil_free(zBrowserCmd);
3125 return;
3126 }
3127 #if !defined(_WIN32)
3128 /* Unix implementation */
3129 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3130 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3131 db_close(1);
 
 
 
 
 
3132 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3133 fossil_fatal("unable to listen on TCP socket %d", iPort);
3134 }
3135 /* For the parent process, the cgi_http_server() command above never
3136 ** returns (except in the case of an error). Instead, for each incoming
@@ -3146,16 +3149,12 @@
3146 }else{
3147 fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT);
3148 }
3149 g.httpIn = stdin;
3150 g.httpOut = stdout;
3151
3152 #if !defined(_WIN32)
3153 signal(SIGSEGV, sigsegv_handler);
3154 signal(SIGPIPE, sigpipe_handler);
3155 #endif
3156
3157 if( g.fAnyTrace ){
3158 fprintf(stderr, "/***** Subprocess %d *****/\n", getpid());
3159 }
3160 g.cgiOutput = 1;
3161 find_server_repository(2, 0);
@@ -3174,13 +3173,10 @@
3174 fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
3175 getpid());
3176 }
3177 #else
3178 /* Win32 implementation */
3179 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3180 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3181 db_close(1);
3182 if( allowRepoList ){
3183 flags |= HTTP_SERVER_REPOLIST;
3184 }
3185 if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
3186 win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile,
3187
--- src/main.c
+++ src/main.c
@@ -3122,15 +3122,18 @@
3122 }
3123 pclose(sshIn);
3124 fossil_free(zBrowserCmd);
3125 return;
3126 }
 
 
3127 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3128 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3129 db_close(1);
3130
3131 /* Start up an HTTP server
3132 */
3133 #if !defined(_WIN32)
3134 /* Unix implementation */
3135 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3136 fossil_fatal("unable to listen on TCP socket %d", iPort);
3137 }
3138 /* For the parent process, the cgi_http_server() command above never
3139 ** returns (except in the case of an error). Instead, for each incoming
@@ -3146,16 +3149,12 @@
3149 }else{
3150 fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT);
3151 }
3152 g.httpIn = stdin;
3153 g.httpOut = stdout;
 
 
3154 signal(SIGSEGV, sigsegv_handler);
3155 signal(SIGPIPE, sigpipe_handler);
 
 
3156 if( g.fAnyTrace ){
3157 fprintf(stderr, "/***** Subprocess %d *****/\n", getpid());
3158 }
3159 g.cgiOutput = 1;
3160 find_server_repository(2, 0);
@@ -3174,13 +3173,10 @@
3173 fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
3174 getpid());
3175 }
3176 #else
3177 /* Win32 implementation */
 
 
 
3178 if( allowRepoList ){
3179 flags |= HTTP_SERVER_REPOLIST;
3180 }
3181 if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
3182 win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile,
3183

Keyboard Shortcuts

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