| 1005 | |
| 1006 | |
| 1007 | void Service::shutdownServices() |
| 1008 | { |
| 1009 | svcShutdown = true; |
| 1010 | |
| 1011 | MutexLockGuard guard(globalServicesMutex, FB_FUNCTION); |
| 1012 | AllServices& all(allServices); |
| 1013 | |
| 1014 | unsigned int pos; |
| 1015 | |
| 1016 | // signal once for every still running service |
| 1017 | for (pos = 0; pos < all.getCount(); pos++) |
| 1018 | { |
| 1019 | if (!(all[pos]->svc_flags & SVC_finished)) |
| 1020 | all[pos]->svc_detach_sem.release(); |
| 1021 | if (all[pos]->svc_stdin_size_requested) |
| 1022 | all[pos]->svc_stdin_semaphore.release(); |
| 1023 | } |
| 1024 | |
| 1025 | for (pos = 0; pos < all.getCount(); ) |
| 1026 | { |
| 1027 | if (!(all[pos]->svc_flags & SVC_finished)) |
| 1028 | { |
| 1029 | globalServicesMutex->leave(); |
| 1030 | Thread::sleep(1); |
| 1031 | globalServicesMutex->enter(FB_FUNCTION); |
| 1032 | pos = 0; |
| 1033 | continue; |
| 1034 | } |
| 1035 | |
| 1036 | ++pos; |
| 1037 | } |
| 1038 | |
| 1039 | threadCollect->join(); |
| 1040 | } |
| 1041 | |
| 1042 | |
| 1043 | ISC_STATUS Service::query2(thread_db* /*tdbb*/, |