| 348 | } |
| 349 | |
| 350 | void AuthenticationHashFromFile::ReloadMonitor(int fd, int wd) { |
| 351 | LOG(INFO) << "Started reload thread for authentication key at " << path_; |
| 352 | char buf[sizeof(struct inotify_event) + PATH_MAX + 1] |
| 353 | __attribute__((aligned(__alignof__(struct inotify_event)))); |
| 354 | while (true) { |
| 355 | fd_set readfds; |
| 356 | FD_ZERO(&readfds); |
| 357 | FD_SET(fd, &readfds); |
| 358 | FD_SET(stop_pipe_read_fd_, &readfds); |
| 359 | int maxfd = std::max(fd, stop_pipe_read_fd_) + 1; |
| 360 | int ret = select(maxfd, &readfds, nullptr, nullptr, nullptr); |
| 361 | if (ret < 0) { |
| 362 | if (errno == EINTR) continue; |
| 363 | LOG(FATAL) << "select() failed in reload thread for authentication key at " |
| 364 | << path_ << ": " << strerror(errno); |
| 365 | } |
| 366 | if (FD_ISSET(stop_pipe_read_fd_, &readfds)) { |
| 367 | // Stop signal received. |
| 368 | LOG(INFO) << "Stopping reload thread for authentication key at " << path_; |
| 369 | break; |
| 370 | } |
| 371 | |
| 372 | if (FD_ISSET(fd, &readfds)) { |
| 373 | ssize_t len = read(fd, buf, sizeof(buf)); |
| 374 | if (len > 0) { |
| 375 | // Reload key on any event. |
| 376 | int64_t start = MonotonicSeconds(); |
| 377 | Status stat; |
| 378 | while (!(stat = LoadKey()).ok()) { |
| 379 | if (FLAGS_hash_reload_grace_period_s >= 0 && |
| 380 | MonotonicSeconds() >= start + FLAGS_hash_reload_grace_period_s) { |
| 381 | LOG(FATAL) << "Authentication key reload failed for more than " |
| 382 | << FLAGS_hash_reload_grace_period_s |
| 383 | << " seconds; terminating Impala. Last error: " << stat; |
| 384 | } |
| 385 | LOG(ERROR) << stat; |
| 386 | SleepForMs(1000); |
| 387 | } |
| 388 | } else if (len < 0 && errno != EAGAIN) { |
| 389 | LOG(FATAL) << "Failed to read inotify event: " << strerror(errno); |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | inotify_rm_watch(fd, wd); |
| 394 | close(stop_pipe_read_fd_); |
| 395 | close(fd); |
| 396 | } |
| 397 | |
| 398 | int GetKeyLenForMode(AES_CIPHER_MODE m) { |
| 399 | switch (m) { |
nothing calls this directly
no test coverage detected