Fossil SCM
Minor code simplification and cleanup for the HTTP server launch in the "fossil ui" and similar commands.
Commit
2f122aac73f6b628be41489c01bb6c7ec454868cf941efd48cd3aca8a92ea837
Parent
a49582b34360444…
1 file changed
+5
-9
+5
-9
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -3122,15 +3122,18 @@ | ||
| 3122 | 3122 | } |
| 3123 | 3123 | pclose(sshIn); |
| 3124 | 3124 | fossil_free(zBrowserCmd); |
| 3125 | 3125 | return; |
| 3126 | 3126 | } |
| 3127 | -#if !defined(_WIN32) | |
| 3128 | - /* Unix implementation */ | |
| 3129 | 3127 | if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY; |
| 3130 | 3128 | if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT; |
| 3131 | 3129 | db_close(1); |
| 3130 | + | |
| 3131 | + /* Start up an HTTP server | |
| 3132 | + */ | |
| 3133 | +#if !defined(_WIN32) | |
| 3134 | + /* Unix implementation */ | |
| 3132 | 3135 | if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){ |
| 3133 | 3136 | fossil_fatal("unable to listen on TCP socket %d", iPort); |
| 3134 | 3137 | } |
| 3135 | 3138 | /* For the parent process, the cgi_http_server() command above never |
| 3136 | 3139 | ** returns (except in the case of an error). Instead, for each incoming |
| @@ -3146,16 +3149,12 @@ | ||
| 3146 | 3149 | }else{ |
| 3147 | 3150 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 3148 | 3151 | } |
| 3149 | 3152 | g.httpIn = stdin; |
| 3150 | 3153 | g.httpOut = stdout; |
| 3151 | - | |
| 3152 | -#if !defined(_WIN32) | |
| 3153 | 3154 | signal(SIGSEGV, sigsegv_handler); |
| 3154 | 3155 | signal(SIGPIPE, sigpipe_handler); |
| 3155 | -#endif | |
| 3156 | - | |
| 3157 | 3156 | if( g.fAnyTrace ){ |
| 3158 | 3157 | fprintf(stderr, "/***** Subprocess %d *****/\n", getpid()); |
| 3159 | 3158 | } |
| 3160 | 3159 | g.cgiOutput = 1; |
| 3161 | 3160 | find_server_repository(2, 0); |
| @@ -3174,13 +3173,10 @@ | ||
| 3174 | 3173 | fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n", |
| 3175 | 3174 | getpid()); |
| 3176 | 3175 | } |
| 3177 | 3176 | #else |
| 3178 | 3177 | /* 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 | 3178 | if( allowRepoList ){ |
| 3183 | 3179 | flags |= HTTP_SERVER_REPOLIST; |
| 3184 | 3180 | } |
| 3185 | 3181 | if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){ |
| 3186 | 3182 | win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile, |
| 3187 | 3183 |
| --- 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 |