Fossil SCM
More Win32 support for the backoffice processing.
Commit
f13ae35f5e2cfd1c293c78d43e2590fd88689ce44ee402401fb74766487b9553
Parent
a9578f7870ced30…
1 file changed
+20
-2
+20
-2
| --- src/backoffice.c | ||
| +++ src/backoffice.c | ||
| @@ -132,17 +132,35 @@ | ||
| 132 | 132 | " VALUES('backoffice','%lld %lld %lld %lld',now())", |
| 133 | 133 | pLease->idCurrent, pLease->tmCurrent, |
| 134 | 134 | pLease->idNext, pLease->tmNext); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | +/* | |
| 138 | +** Check to see if the specified Win32 process is still alive. It | |
| 139 | +** should be noted that even if this function returns non-zero, the | |
| 140 | +** process may die before another operation on it can be completed. | |
| 141 | +*/ | |
| 142 | +#if defined(_WIN32) | |
| 143 | +#ifndef PROCESS_QUERY_LIMITED_INFORMATION | |
| 144 | +# define PROCESS_QUERY_LIMITED_INFORMATION (0x1000) | |
| 145 | +#endif | |
| 146 | +static int backofficeWin32ProcessExists(DWORD dwProcessId){ | |
| 147 | + HANDLE hProcess; | |
| 148 | + hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,FALSE,dwProcessId); | |
| 149 | + if( hProcess==NULL ) return 0; | |
| 150 | + CloseHandle(hProcess); | |
| 151 | + return 1; | |
| 152 | +} | |
| 153 | +#endif | |
| 154 | + | |
| 137 | 155 | /* |
| 138 | 156 | ** Check to see if the process identified by selfId is alive. If |
| 139 | 157 | ** we cannot prove the the process is dead, return true. |
| 140 | 158 | */ |
| 141 | 159 | static int backofficeProcessExists(sqlite3_uint64 pid){ |
| 142 | 160 | #if defined(_WIN32) |
| 143 | - return 1; | |
| 161 | + return pid>0 && backofficeWin32ProcessExists((DWORD)pid)!=0; | |
| 144 | 162 | #else |
| 145 | 163 | return pid>0 && kill((pid_t)pid, 0)==0; |
| 146 | 164 | #endif |
| 147 | 165 | } |
| 148 | 166 | |
| @@ -150,11 +168,11 @@ | ||
| 150 | 168 | ** Check to see if the process identified by selfId has finished. If |
| 151 | 169 | ** we cannot prove the the process is still running, return true. |
| 152 | 170 | */ |
| 153 | 171 | static int backofficeProcessDone(sqlite3_uint64 pid){ |
| 154 | 172 | #if defined(_WIN32) |
| 155 | - return 1; | |
| 173 | + return pid<=0 || backofficeWin32ProcessExists((DWORD)pid)==0; | |
| 156 | 174 | #else |
| 157 | 175 | return pid<=0 || kill((pid_t)pid, 0)!=0; |
| 158 | 176 | #endif |
| 159 | 177 | } |
| 160 | 178 | |
| 161 | 179 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -132,17 +132,35 @@ | |
| 132 | " VALUES('backoffice','%lld %lld %lld %lld',now())", |
| 133 | pLease->idCurrent, pLease->tmCurrent, |
| 134 | pLease->idNext, pLease->tmNext); |
| 135 | } |
| 136 | |
| 137 | /* |
| 138 | ** Check to see if the process identified by selfId is alive. If |
| 139 | ** we cannot prove the the process is dead, return true. |
| 140 | */ |
| 141 | static int backofficeProcessExists(sqlite3_uint64 pid){ |
| 142 | #if defined(_WIN32) |
| 143 | return 1; |
| 144 | #else |
| 145 | return pid>0 && kill((pid_t)pid, 0)==0; |
| 146 | #endif |
| 147 | } |
| 148 | |
| @@ -150,11 +168,11 @@ | |
| 150 | ** Check to see if the process identified by selfId has finished. If |
| 151 | ** we cannot prove the the process is still running, return true. |
| 152 | */ |
| 153 | static int backofficeProcessDone(sqlite3_uint64 pid){ |
| 154 | #if defined(_WIN32) |
| 155 | return 1; |
| 156 | #else |
| 157 | return pid<=0 || kill((pid_t)pid, 0)!=0; |
| 158 | #endif |
| 159 | } |
| 160 | |
| 161 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -132,17 +132,35 @@ | |
| 132 | " VALUES('backoffice','%lld %lld %lld %lld',now())", |
| 133 | pLease->idCurrent, pLease->tmCurrent, |
| 134 | pLease->idNext, pLease->tmNext); |
| 135 | } |
| 136 | |
| 137 | /* |
| 138 | ** Check to see if the specified Win32 process is still alive. It |
| 139 | ** should be noted that even if this function returns non-zero, the |
| 140 | ** process may die before another operation on it can be completed. |
| 141 | */ |
| 142 | #if defined(_WIN32) |
| 143 | #ifndef PROCESS_QUERY_LIMITED_INFORMATION |
| 144 | # define PROCESS_QUERY_LIMITED_INFORMATION (0x1000) |
| 145 | #endif |
| 146 | static int backofficeWin32ProcessExists(DWORD dwProcessId){ |
| 147 | HANDLE hProcess; |
| 148 | hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,FALSE,dwProcessId); |
| 149 | if( hProcess==NULL ) return 0; |
| 150 | CloseHandle(hProcess); |
| 151 | return 1; |
| 152 | } |
| 153 | #endif |
| 154 | |
| 155 | /* |
| 156 | ** Check to see if the process identified by selfId is alive. If |
| 157 | ** we cannot prove the the process is dead, return true. |
| 158 | */ |
| 159 | static int backofficeProcessExists(sqlite3_uint64 pid){ |
| 160 | #if defined(_WIN32) |
| 161 | return pid>0 && backofficeWin32ProcessExists((DWORD)pid)!=0; |
| 162 | #else |
| 163 | return pid>0 && kill((pid_t)pid, 0)==0; |
| 164 | #endif |
| 165 | } |
| 166 | |
| @@ -150,11 +168,11 @@ | |
| 168 | ** Check to see if the process identified by selfId has finished. If |
| 169 | ** we cannot prove the the process is still running, return true. |
| 170 | */ |
| 171 | static int backofficeProcessDone(sqlite3_uint64 pid){ |
| 172 | #if defined(_WIN32) |
| 173 | return pid<=0 || backofficeWin32ProcessExists((DWORD)pid)==0; |
| 174 | #else |
| 175 | return pid<=0 || kill((pid_t)pid, 0)!=0; |
| 176 | #endif |
| 177 | } |
| 178 | |
| 179 |