mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Try to fix ubsan crash.
This commit is contained in:
parent
263aa88cd9
commit
bf9c945ce2
@ -44,10 +44,11 @@ AsyncTaskQueue::~AsyncTaskQueue()
|
|||||||
|
|
||||||
void AsyncTaskQueue::addTask(size_t thread_number, void * data, int fd)
|
void AsyncTaskQueue::addTask(size_t thread_number, void * data, int fd)
|
||||||
{
|
{
|
||||||
if (tasks.count(data))
|
std::uintptr_t key = reinterpret_cast<uintptr_t>(data);
|
||||||
|
if (tasks.count(key))
|
||||||
throw Exception("Task was already added to task queue", ErrorCodes::LOGICAL_ERROR);
|
throw Exception("Task was already added to task queue", ErrorCodes::LOGICAL_ERROR);
|
||||||
|
|
||||||
tasks[data] = TaskData{thread_number, data, fd};
|
tasks[key] = TaskData{thread_number, data, fd};
|
||||||
|
|
||||||
epoll_event socket_event;
|
epoll_event socket_event;
|
||||||
socket_event.events = EPOLLIN | EPOLLPRI;
|
socket_event.events = EPOLLIN | EPOLLPRI;
|
||||||
@ -80,7 +81,8 @@ AsyncTaskQueue::TaskData AsyncTaskQueue::wait(std::unique_lock<std::mutex> & loc
|
|||||||
if (event.data.ptr == pipe_fd)
|
if (event.data.ptr == pipe_fd)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto it = tasks.find(event.data.ptr);
|
std::uintptr_t key = reinterpret_cast<uintptr_t>(event.data.ptr);
|
||||||
|
auto it = tasks.find(key);
|
||||||
if (it == tasks.end())
|
if (it == tasks.end())
|
||||||
throw Exception("Task was not found in task queue", ErrorCodes::LOGICAL_ERROR);
|
throw Exception("Task was not found in task queue", ErrorCodes::LOGICAL_ERROR);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -26,7 +27,7 @@ private:
|
|||||||
int epoll_fd;
|
int epoll_fd;
|
||||||
int pipe_fd[2];
|
int pipe_fd[2];
|
||||||
std::atomic_bool is_finished = false;
|
std::atomic_bool is_finished = false;
|
||||||
std::unordered_map<void *, TaskData> tasks;
|
std::unordered_map<std::uintptr_t, TaskData> tasks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncTaskQueue();
|
AsyncTaskQueue();
|
||||||
|
Loading…
Reference in New Issue
Block a user