| 1020 | } |
| 1021 | |
| 1022 | THREAD_ENTRY_DECLARE process_thread(THREAD_ENTRY_PARAM arg) |
| 1023 | { |
| 1024 | AutoPtr<Target> target(static_cast<Target*>(arg)); |
| 1025 | const auto config = target->getConfig(); |
| 1026 | const auto dbName = config->dbName.c_str(); |
| 1027 | |
| 1028 | AutoMemoryPool workingPool(MemoryPool::createPool()); |
| 1029 | ContextPoolHolder threadContext(workingPool); |
| 1030 | |
| 1031 | target->verbose("Started replication for database %s", dbName); |
| 1032 | |
| 1033 | while (!shutdownFlag) |
| 1034 | { |
| 1035 | const ProcessStatus ret = process_archive(*workingPool, target); |
| 1036 | |
| 1037 | if (ret == PROCESS_CONTINUE) |
| 1038 | continue; |
| 1039 | |
| 1040 | target->shutdown(); |
| 1041 | |
| 1042 | if (ret != PROCESS_SHUTDOWN) |
| 1043 | { |
| 1044 | const ULONG timeout = |
| 1045 | (ret == PROCESS_SUSPEND) ? config->applyIdleTimeout : config->applyErrorTimeout; |
| 1046 | |
| 1047 | shutdownSemaphore.tryEnter(timeout); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | target->verbose("Finished replication for database %s", dbName); |
| 1052 | --activeThreads; |
| 1053 | |
| 1054 | return 0; |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | |