Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use a thread to implement backoffice work timeouts for Win32. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | win32Proc |
Files: | files | file ages | folders |
SHA3-256: |
a9578f7870ced30545f987a324b1bfb8 |
User & Date: | mistachkin 2018-07-31 00:10:08.663 |
Original Comment: | Use a thread to implement the backoffice for Win32. |
Context
2018-08-02
| ||
01:53 | More Win32 support for the backoffice processing. ... (check-in: f13ae35f user: mistachkin tags: win32Proc) | |
2018-07-31
| ||
00:10 | Use a thread to implement backoffice work timeouts for Win32. ... (check-in: a9578f78 user: mistachkin tags: win32Proc) | |
00:09 | Update the custom MinGW makefile. ... (check-in: d5c41263 user: mistachkin tags: trunk) | |
Changes
Changes to src/backoffice.c.
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ** if the Fossil binary is updated on a system, the backoffice processes ** will restart using the new binary automatically. */ #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 | > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | ** if the Fossil binary is updated on a system, the backoffice processes ** will restart using the new binary automatically. */ #include "config.h" #include "backoffice.h" #include <time.h> #if defined(_WIN32) # include <process.h> # include <windows.h> #else # include <unistd.h> # include <sys/types.h> # include <signal.h> #endif |
︙ | ︙ | |||
169 170 171 172 173 174 175 | } /* ** 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. */ | < | > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > | 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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | } /* ** 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. */ static void backofficeSigalrmHandler(int x){ fossil_panic("backoffice timeout (%d seconds)", x); } #if defined(_WIN32) static void *threadHandle = NULL; static void __stdcall backofficeWin32NoopApcProc(ULONG_PTR pArg){} /* NO-OP */ static void backofficeWin32ThreadCleanup(){ if( threadHandle!=NULL ){ /* Queue no-op asynchronous procedure call to the sleeping * thread. This will cause it to wake up with a non-zero * return value. */ if( QueueUserAPC(backofficeWin32NoopApcProc, threadHandle, 0) ){ /* Wait for the thread to wake up and then exit. */ WaitForSingleObject(threadHandle, INFINITE); } CloseHandle(threadHandle); threadHandle = NULL; } } static unsigned __stdcall backofficeWin32SigalrmThreadProc( void *pArg /* IN: Pointer to integer number of whole seconds. */ ){ int seconds = FOSSIL_PTR_TO_INT(pArg); if( SleepEx((DWORD)seconds * 1000, TRUE)==0 ){ backofficeSigalrmHandler(seconds); } _endthreadex(0); return 0; /* NOT REACHED */ } #endif static void backofficeTimeout(int x){ #if defined(_WIN32) if( threadHandle!=NULL ) return; threadHandle = (void*)_beginthreadex( 0, 0, backofficeWin32SigalrmThreadProc, FOSSIL_INT_TO_PTR(x), 0, 0 ); #else signal(SIGALRM, backofficeSigalrmHandler); alarm(x); #endif } /* |
︙ | ︙ | |||
291 292 293 294 295 296 297 298 299 300 301 302 303 304 | x.idCurrent, (int)(BKOFCE_LEASE_TIME + tmNow - x.tmCurrent)); lastWarning = tmNow; warningDelay *= 2; } sqlite3_sleep(1000); } } return; } /* ** This routine runs to do the backoffice processing. When adding new ** backoffice processing tasks, add them here. */ | > > > | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | x.idCurrent, (int)(BKOFCE_LEASE_TIME + tmNow - x.tmCurrent)); lastWarning = tmNow; warningDelay *= 2; } sqlite3_sleep(1000); } } #if defined(_WIN32) backofficeWin32ThreadCleanup(); #endif return; } /* ** This routine runs to do the backoffice processing. When adding new ** backoffice processing tasks, add them here. */ |
︙ | ︙ |