| 275 | } |
| 276 | |
| 277 | void S3KeyReader::close() { |
| 278 | // to interupt downlading thread, we must: (check ChunkBuffer::fill()) |
| 279 | // 1. set condition to ReadyToFill and signal conditional_variable. |
| 280 | // 2. set the shared error status to prevent download thread from continuing. |
| 281 | this->sharedError = true; |
| 282 | |
| 283 | for (uint64_t i = 0; i < this->chunkBuffers.size(); i++) { |
| 284 | UniqueLock lock(this->chunkBuffers[i].getStatMutex()); |
| 285 | this->chunkBuffers[i].setStatus(ReadyToFill); |
| 286 | pthread_cond_signal(this->chunkBuffers[i].getStatCond()); |
| 287 | } |
| 288 | |
| 289 | for (uint64_t i = 0; i < this->threads.size(); i++) { |
| 290 | if (this->threads[i] == 0) { |
| 291 | continue; |
| 292 | } |
| 293 | |
| 294 | pthread_join(this->threads[i], NULL); |
| 295 | |
| 296 | this->threads[i] = 0; |
| 297 | } |
| 298 | |
| 299 | this->reset(); |
| 300 | } |
no test coverage detected