Skip to content

Commit 688fdbd

Browse files
committed
Revert "Fix possible race condition in EventListener"
This reverts commit 6631382.
1 parent 5fec3dc commit 688fdbd

2 files changed

Lines changed: 0 additions & 19 deletions

File tree

src/fb-cpp/EventListener.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ EventListener::EventListener(Attachment& attachment, const std::vector<std::stri
111111
&statusWrapper, &firebirdCallback, static_cast<unsigned>(eventBuffer.size()), eventBuffer.data()));
112112

113113
dispatcher = std::thread{&EventListener::dispatchLoop, this};
114-
115-
{ // scope
116-
std::unique_lock mutexGuard{mutex};
117-
condition.wait(mutexGuard, [this] { return initialized || !listening; });
118-
}
119114
}
120115

121116
bool EventListener::isListening() noexcept
@@ -191,7 +186,6 @@ void EventListener::handleEvent(unsigned length, const std::uint8_t* events)
191186
unsigned copyLength = 0;
192187
bool notify = false;
193188
bool shouldRequeue = false;
194-
bool notifyInitialized = false;
195189

196190
{ // scope
197191
std::lock_guard mutexGuard{mutex};
@@ -249,7 +243,6 @@ void EventListener::handleEvent(unsigned length, const std::uint8_t* events)
249243
if (listening)
250244
{
251245
listening = false;
252-
initialized = true;
253246
condition.notify_all();
254247
}
255248

@@ -274,7 +267,6 @@ void EventListener::handleEvent(unsigned length, const std::uint8_t* events)
274267
return;
275268

276269
listening = false;
277-
initialized = true;
278270
condition.notify_all();
279271
}
280272

@@ -290,17 +282,8 @@ void EventListener::handleEvent(unsigned length, const std::uint8_t* events)
290282
{
291283
previousHandle = std::move(eventsHandle);
292284
eventsHandle = std::move(newHandle);
293-
294-
if (!initialized)
295-
{
296-
initialized = true;
297-
notifyInitialized = true;
298-
}
299285
}
300286
}
301-
302-
if (notifyInitialized)
303-
condition.notify_all();
304287
}
305288
catch (...)
306289
{
@@ -313,7 +296,6 @@ void EventListener::handleEvent(unsigned length, const std::uint8_t* events)
313296
if (listening)
314297
{
315298
listening = false;
316-
initialized = true;
317299
condition.notify_all();
318300
}
319301
}

src/fb-cpp/EventListener.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ namespace fbcpp
168168
bool listening = false;
169169
bool running = false;
170170
bool first = false;
171-
bool initialized = false;
172171
};
173172
} // namespace fbcpp
174173

0 commit comments

Comments
 (0)