Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Backoffice processing improvements: Set a timer on the backoffice to prevent it from running too long. Report errors on failed attempts to open /dev/null. Use "NUL" instead of "/dev/null" on Windows. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
07356e44c1a8cf7bee5617dfb692bb3f |
User & Date: | drh 2018-07-30 13:25:56.079 |
Context
2018-07-31
| ||
00:09 | Fix harmless compiler warnings. ... (check-in: ea2e5151 user: mistachkin tags: trunk) | |
2018-07-30
| ||
13:34 | Merge backoffice enhancements from trunk. ... (check-in: bb50f0dc user: drh tags: forum-v2) | |
13:25 | Backoffice processing improvements: Set a timer on the backoffice to prevent it from running too long. Report errors on failed attempts to open /dev/null. Use "NUL" instead of "/dev/null" on Windows. ... (check-in: 07356e44 user: drh tags: trunk) | |
2018-07-25
| ||
13:20 | Add the 'D' Debug user capability. This is designed to show additional information and controls on webpages for debugging purposes. Also take steps to avoid trying to generate a webpage error message after the webpage has already gone out. ... (check-in: fd319832 user: drh tags: trunk) | |
Changes
Changes to src/backoffice.c.
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | */ #include "config.h" #include "backoffice.h" #include <time.h> #if defined(_WIN32) # include <windows.h> #else # include <sys/types.h> # include <signal.h> #endif /* ** The BKOFCE_LEASE_TIME is the amount of time for which a single backoffice ** processing run is valid. Each backoffice run monopolizes the lease for | > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | */ #include "config.h" #include "backoffice.h" #include <time.h> #if defined(_WIN32) # include <windows.h> #else # include <unistd.h> # include <sys/types.h> # include <signal.h> #endif /* ** The BKOFCE_LEASE_TIME is the amount of time for which a single backoffice ** processing run is valid. Each backoffice run monopolizes the lease for |
︙ | ︙ | |||
162 163 164 165 166 167 168 169 170 171 172 173 174 175 | static sqlite3_uint64 backofficeProcessId(void){ #if defined(_WIN32) return (sqlite3_uint64)GetCurrentProcessId(); #else return (sqlite3_uint64)getpid(); #endif } /* ** COMMAND: test-process-id ** ** Usage: %fossil [--sleep N] PROCESS-ID ... ** ** Show the current process id, and also tell whether or not all other | > > > > > > > > > > > > > > > > > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | static sqlite3_uint64 backofficeProcessId(void){ #if defined(_WIN32) return (sqlite3_uint64)GetCurrentProcessId(); #else return (sqlite3_uint64)getpid(); #endif } /* ** Set an alarm to cause the process to exit after "x" seconds. This ** prevents any kind of bug from keeping a backoffice process running ** indefinitely. */ #if !defined(_WIN32) static void backofficeSigalrmHandler(int x){ fossil_panic("backoffice timeout"); } #endif static void backofficeTimeout(int x){ #if !defined(_WIN32) signal(SIGALRM, backofficeSigalrmHandler); alarm(x); #endif } /* ** COMMAND: test-process-id ** ** Usage: %fossil [--sleep N] PROCESS-ID ... ** ** Show the current process id, and also tell whether or not all other |
︙ | ︙ | |||
212 213 214 215 216 217 218 219 220 221 222 223 224 225 | if( g.db==0 ){ fossil_panic("database not open for backoffice processing"); } if( db_transaction_nesting_depth()!=0 ){ fossil_panic("transaction %s not closed prior to backoffice processing", db_transaction_start_point()); } idSelf = backofficeProcessId(); while(1){ tmNow = time(0); db_begin_write(); backofficeReadLease(&x); if( x.tmNext>=tmNow && x.idNext!=idSelf | > | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | if( g.db==0 ){ fossil_panic("database not open for backoffice processing"); } if( db_transaction_nesting_depth()!=0 ){ fossil_panic("transaction %s not closed prior to backoffice processing", db_transaction_start_point()); } backofficeTimeout(BKOFCE_LEASE_TIME*2); idSelf = backofficeProcessId(); while(1){ tmNow = time(0); db_begin_write(); backofficeReadLease(&x); if( x.tmNext>=tmNow && x.idNext!=idSelf |
︙ | ︙ | |||
255 256 257 258 259 260 261 262 263 264 265 266 267 268 | } /* This process needs to queue up and wait for the current lease ** to expire before continuing. */ x.idNext = idSelf; x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME; backofficeWriteLease(&x); db_end_transaction(0); if( x.tmCurrent >= tmNow ){ sqlite3_sleep(1000*(x.tmCurrent - tmNow + 1)); }else{ if( lastWarning+warningDelay < tmNow ){ fossil_warning( "backoffice process %lld still running after %d seconds", x.idCurrent, (int)(BKOFCE_LEASE_TIME + tmNow - x.tmCurrent)); | > > > | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | } /* This process needs to queue up and wait for the current lease ** to expire before continuing. */ x.idNext = idSelf; x.tmNext = (tmNow>x.tmCurrent ? tmNow : x.tmCurrent) + BKOFCE_LEASE_TIME; backofficeWriteLease(&x); db_end_transaction(0); if( g.fAnyTrace ){ fprintf(stderr, "/***** Backoffice On-deck %d *****/\n", getpid()); } if( x.tmCurrent >= tmNow ){ sqlite3_sleep(1000*(x.tmCurrent - tmNow + 1)); }else{ if( lastWarning+warningDelay < tmNow ){ fossil_warning( "backoffice process %lld still running after %d seconds", x.idCurrent, (int)(BKOFCE_LEASE_TIME + tmNow - x.tmCurrent)); |
︙ | ︙ |
Changes to src/cgi.c.
︙ | ︙ | |||
344 345 346 347 348 349 350 351 | /* After the webpage has been sent, do any useful background ** processing. */ g.cgiOutput = 2; if( g.db!=0 && iReplyStatus==200 ){ fclose(g.httpOut); g.httpOut = fossil_fopen("/dev/null", "wb"); | > > > > > > > | > | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | /* After the webpage has been sent, do any useful background ** processing. */ g.cgiOutput = 2; if( g.db!=0 && iReplyStatus==200 ){ fclose(g.httpOut); #ifdef _WIN32 g.httpOut = fossil_fopen("NUL", "wb"); #else g.httpOut = fossil_fopen("/dev/null", "wb"); #endif if( g.httpOut==0 ){ fossil_warning("failed ot open /dev/null"); }else{ backoffice_run(); } } } /* ** Do a redirect request to the URL given in the argument. ** ** The URL must be relative to the base of the fossil server. |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
2480 2481 2482 2483 2484 2485 2486 | #endif #endif /* ** Send a time-out reply */ void sigalrm_handler(int x){ | | < < | 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 | #endif #endif /* ** Send a time-out reply */ void sigalrm_handler(int x){ fossil_panic("TIMEOUT"); } /* ** COMMAND: server* ** COMMAND: ui ** ** Usage: %fossil server ?OPTIONS? ?REPOSITORY? |
︙ | ︙ |