Skip to content
Commit 2629414e authored by Harald Sitter's avatar Harald Sitter 🐧
Browse files

connection: don't queue tasks until OOM

bit of an edge case here. I have a crash in discover that takes it down
fairly early on in startup, after KIO HTTP requests have been
dispatched, but before the worker had a chance to talk to the
application and serve that request.
when discover crashes it properly disconnects from the worker and the
worker does properly de-initialize. the problem is that this occurs
while the worker is already trying to get the metadata for the http
request. I'm adding a sample trace for that disconnect for illustration
below.
finally since the connection is now no longer inited the worker
repeatedly fell into the if that queues tasks and would continue to do
so forever (e.g. in the call chain HTTPProtocol::get -> getData ->
KIO::SlaveBase::dataReq)

to deal with this problem we now tell the connection which end it is; if
it is the worker we'll just plain exit in error when trying to send data
on a closed connection. being a passive actor the worker has no business
queuing tasks when disconnected, the next client won't know what to do
with the tasks anyway.

```
#7  0x00007ac397d9e53a in KIO::Connection::close (this=0x5ae3c94734e0)
at /home/me/src/kio/src/core/connection.cpp:114
#8  0x00007ac397d9e450 in KIO::ConnectionPrivate::disconnected
(this=0x5ae3c946a9e0) at /home/me/src/kio/src/core/connection.cpp:50
#9  0x00007ac397d9ffb8 in
KIO::ConnectionPrivate::setBackend(KIO::ConnectionBackend*)::$_1::operator()()
const (this=0x5ae3c9473ec0) at
/home/me/src/kio/src/core/connection.cpp:66
#10 0x00007ac397d9ff66 in
QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>,
void,
KIO::ConnectionPrivate::setBackend(KIO::ConnectionBackend*)::$_1>::call(KIO::ConnectionPrivate::setBackend(KIO::ConnectionBackend*)::$_1&,
void**) (f=..., arg=0x7ffc619d6478) at
/usr/include/qt6/QtCore/qobjectdefs_impl.h:137
#11 0x00007ac397d9ff21 in
QtPrivate::Functor<KIO::ConnectionPrivate::setBackend(KIO::ConnectionBackend*)::$_1,
0>::call<QtPrivate::List<>,
void>(KIO::ConnectionPrivate::setBackend(KIO::ConnectionBackend*)::$_1&,
void*, void**) (f=..., arg=0x7ffc619d6478) at
/usr/include/qt6/QtCore/qobjectdefs_impl.h:339
#12 0x00007ac397d9febe in
QtPrivate::QCallableObject<KIO::ConnectionPrivate::setBackend(KIO::ConnectionBackend*)::$_1,
QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*,
QObject*, void**, bool*) (which=1, this_=0x5ae3c9473eb0,
r=0x5ae3c94734e0, a=0x7ffc619d6478, ret=0x0) at
/usr/include/qt6/QtCore/qobjectdefs_impl.h:522
#13 0x00007ac3975f7599 in ??? () at /usr/lib/libQt6Core.so.6
#14 0x00007ac397d99b62 in KIO::ConnectionBackend::disconnected
(this=0x5ae3c9474240) at
src/core/KF6KIOCore_autogen/include/moc_connectionbackend_p.cpp:222
#15 0x00007ac397d99b2c in KIO::ConnectionBackend::socketDisconnected
(this=0x5ae3c9474240) at
/home/me/src/kio/src/core/connectionbackend.cpp:92
#16 0x00007ac397d9d611 in
QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>,
void, void (KIO::ConnectionBackend::*)()>::call(void
(KIO::ConnectionBackend::*)(), KIO::ConnectionBackend*, void**) (f=(void
(KIO::ConnectionBackend::*)(KIO::ConnectionBackend * const))
0x7ac397d99b10 <KIO::ConnectionBackend::socketDisconnected()>,
o=0x5ae3c9474240, arg=0x7ffc619d66c8) at
/usr/include/qt6/QtCore/qobjectdefs_impl.h:145
#17 0x00007ac397d9d54d in QtPrivate::FunctionPointer<void
(KIO::ConnectionBackend::*)()>::call<QtPrivate::List<>, void>(void
(KIO::ConnectionBackend::*)(), KIO::ConnectionBackend*, void**) (f=(void
(KIO::ConnectionBackend::*)(KIO::ConnectionBackend * const))
0x7ac397d99b10 <KIO::ConnectionBackend::socketDisconnected()>,
o=0x5ae3c9474240, arg=0x7ffc619d66c8) at
/usr/include/qt6/QtCore/qobjectdefs_impl.h:182
#18 0x00007ac397d9d435 in QtPrivate::QCallableObject<void
(KIO::ConnectionBackend::*)(), QtPrivate::List<>, void>::impl(int,
QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1,
this_=0x5ae3c9475b40, r=0x5ae3c9474240, a=0x7ffc619d66c8, ret=0x0) at
/usr/include/qt6/QtCore/qobjectdefs_impl.h:520
#19 0x00007ac3975f7599 in ??? () at /usr/lib/libQt6Core.so.6
#20 0x00007ac3975f789b in ??? () at /usr/lib/libQt6Core.so.6
#21 0x00007ac397c48533 in QAbstractSocket::disconnectFromHost() () at
/usr/lib/libQt6Network.so.6
#22 0x00007ac397c4389d in ??? () at /usr/lib/libQt6Network.so.6
#23 0x00007ac397c47074 in QAbstractSocket::waitForReadyRead(int) () at
/usr/lib/libQt6Network.so.6
#24 0x00007ac397d9a335 in KIO::ConnectionBackend::waitForIncomingTask
(this=0x5ae3c9474240, ms=-1) at
/home/me/src/kio/src/core/connectionbackend.cpp:154
#25 0x00007ac397d9f2de in KIO::Connection::waitForIncomingTask
(this=0x5ae3c94734e0, ms=-1) at
/home/me/src/kio/src/core/connection.cpp:217
#26 0x00007ac397e3414c in KIO::SlaveBase::waitForAnswer
(this=0x5ae3c946c1c0, expected1=100, expected2=0, data=..., pCmd=0x0) at
/home/me/src/kio/src/core/slavebase.cpp:1074
#27 0x00007ac397e343b9 in KIO::SlaveBase::readData (this=0x5ae3c946c1c0,
buffer=...) at /home/me/src/kio/src/core/slavebase.cpp:1098
#28 0x00007ac397e40e69 in KIO::WorkerBase::readData
(this=0x7ffc619d6fb8, buffer=...) at
/home/me/src/kio/src/core/workerbase.cpp:364
#29 0x00007ac392422404 in HTTPProtocol::getData (this=0x7ffc619d6fa8) at
/home/me/src/kio/src/kioworkers/http/http.cpp:607
#30 0x00007ac392422284 in HTTPProtocol::get (this=0x7ffc619d6fa8,
url=...) at /home/me/src/kio/src/kioworkers/http/http.cpp:532
```
parent 5e2850ed
Pipeline #655937 passed with stage
in 11 minutes and 33 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment