| 145 | } |
| 146 | |
| 147 | static void* DownloadThreadFunc(void* data) { |
| 148 | MaskThreadSignals(); |
| 149 | |
| 150 | ChunkBuffer* buffer = static_cast<ChunkBuffer*>(data); |
| 151 | |
| 152 | uint64_t filledSize = 0; |
| 153 | S3DEBUG("Downloading thread starts"); |
| 154 | do { |
| 155 | if (S3QueryIsAbortInProgress()) { |
| 156 | S3INFO("Downloading thread is interrupted"); |
| 157 | |
| 158 | // error is shared between all chunks, so all chunks will stop. |
| 159 | buffer->setSharedError(true, S3QueryAbort("Downloading thread is interrupted")); |
| 160 | |
| 161 | // have to unlock ChunkBuffer::read in some certain conditions, for instance, status is |
| 162 | // not ReadyToRead, and read() is waiting for signal stat_cond. |
| 163 | buffer->setStatus(ReadyToRead); |
| 164 | pthread_cond_signal(buffer->getStatCond()); |
| 165 | |
| 166 | return NULL; |
| 167 | } |
| 168 | |
| 169 | filledSize = buffer->fill(); |
| 170 | |
| 171 | if (filledSize != 0) { |
| 172 | if (buffer->isError()) { |
| 173 | S3DEBUG("Failed to fill downloading buffer"); |
| 174 | break; |
| 175 | } else { |
| 176 | S3DEBUG("Size of filled data is %" PRIu64, filledSize); |
| 177 | } |
| 178 | } |
| 179 | } while (!buffer->isEOF()); |
| 180 | S3DEBUG("Downloading thread ended"); |
| 181 | return NULL; |
| 182 | } |
| 183 | |
| 184 | void S3KeyReader::open(const S3Params& params) { |
| 185 | S3_CHECK_OR_DIE(this->s3Interface != NULL, S3RuntimeError, "s3Interface must not be NULL"); |
nothing calls this directly
no test coverage detected