kdelibs/kdelibs-4.2.1-kde#918403.patch

88 lines
2.7 KiB
Diff

Index: kinit/klauncher.cpp
===================================================================
--- kinit/klauncher.cpp (revision 918402)
+++ kinit/klauncher.cpp (revision 918403)
@@ -167,7 +167,7 @@
KLauncher::KLauncher(int _kdeinitSocket)
: QObject(0),
- kdeinitSocket(_kdeinitSocket), dontBlockReading(false)
+ kdeinitSocket(_kdeinitSocket)
{
#ifdef Q_WS_X11
mCached_dpy = NULL;
@@ -276,8 +276,24 @@
{
ssize_t result;
int bytes_left = len;
- while ( bytes_left > 0)
- {
+ while (bytes_left > 0) {
+ // in case we get a request to start an application and data arrive
+ // to kdeinitSocket at the same time, requestStart() will already
+ // call slotKDEInitData(), so we must check there's still something
+ // to read, otherwise this would block
+
+ // Same thing if kdeinit dies without warning.
+
+ fd_set in;
+ timeval tm = { 30, 0 }; // 30 seconds timeout, so we're not stuck in case kdeinit dies on us
+ FD_ZERO ( &in );
+ FD_SET( sock, &in );
+ select( sock + 1, &in, 0, 0, &tm );
+ if( !FD_ISSET( sock, &in )) {
+ kDebug(7016) << "read_socket" << sock << "nothing to read, kdeinit4 must be dead";
+ return -1;
+ }
+
result = read(sock, buffer, bytes_left);
if (result > 0)
{
@@ -298,21 +314,7 @@
{
klauncher_header request_header;
QByteArray requestData;
- if( dontBlockReading )
- {
- // in case we get a request to start an application and data arrive
- // to kdeinitSocket at the same time, requestStart() will already
- // call slotKDEInitData(), so we must check there's still something
- // to read, otherwise this would block
- fd_set in;
- timeval tm = { 0, 0 };
- FD_ZERO ( &in );
- FD_SET( kdeinitSocket, &in );
- select( kdeinitSocket + 1, &in, 0, 0, &tm );
- if( !FD_ISSET( kdeinitSocket, &in ))
- return;
- }
- dontBlockReading = false;
+
int result = read_socket(kdeinitSocket, (char *) &request_header,
sizeof( request_header));
if (result == -1)
@@ -647,17 +649,21 @@
request_header.cmd = LAUNCHER_EXEC_NEW;
#endif
request_header.arg_length = requestData.length();
+
+#ifdef KLAUNCHER_VERBOSE_OUTPUT
+ kDebug(7016) << "Asking kdeinit to start" << request->name << request->arg_list
+ << "cmd=" << commandToString(request_header.cmd);
+#endif
+
write(kdeinitSocket, &request_header, sizeof(request_header));
write(kdeinitSocket, requestData.data(), requestData.length());
// Wait for pid to return.
lastRequest = request;
- dontBlockReading = false;
do {
slotKDEInitData( kdeinitSocket );
}
while (lastRequest != 0);
- dontBlockReading = true;
#endif
}