This is a multi-part message in MIME format. --===============0284637378911970572== Content-Type: multipart/alternative; boundary="nextPart21289991.gLxTKuM6O7" Content-Transfer-Encoding: 7Bit This is a multi-part message in MIME format. --nextPart21289991.gLxTKuM6O7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" O Martes, 5 de Marzo de 2013 11:53:13 Frank Reininghaus escribiu: > I'm not a network expert, and I don't know what the cause of the > problem is, but I noticed two things: >=20 > 1. I think the access to "m_request" in FakeServer::*Request() needs > to be protected by locking m_mutex. Doing that does not seem to fix > the issue, but not protecting it might lead to other problems at some= > point. >=20 > 2. The class FakeServer follows the "You're doing it wrong" pattern > (it contains the line "moveToThread(this);") , see >=20 > http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ > http://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html >=20 > This might or might not be part of the problem. Many thanks for the input! I think I=E2=80=99ve solve both issues, but the race condition persists= . I=E2=80=99ve uploaded a tar.xz with the current state of the test files= to Gitorious: https://gitorious.org/libmediawiki/libmediawiki/blobs/ra= w/gallaecio/examples/raceissue/2ndAttemptToAvoidRaceCondition.tar.xz The files can also be found at https://gitorious.org/libmediawiki/libme= diawiki/trees/gallaecio/examples/raceissue I followed the lead of the Qt documentation, and the main function look= s like this now: int main(int argc, char* argv[]) { QCoreApplication a(argc, argv); QThread *serverThread =3D new QThread(); FakeServer *fakeserver =3D new FakeServer; QObject::connect(serverThread, SIGNAL(started()), fakeserver, SLOT(= run())); QObject::connect(serverThread, SIGNAL(finished()), fakeserver, SLOT= (deleteLater())); fakeserver->moveToThread(serverThread); serverThread->start(); for (int i =3D 0; i < 10000; i++) { Job job; job.exec(); QList requests =3D fakeserver->getRequest(= ); if (requests.size() !=3D 1) qDebug() << requests.size() << "? W= TF?"; else qDebug() << requests.size() << ", as = expected."; fakeserver->clearRequest(); } serverThread->quit(); return 0; } --nextPart21289991.gLxTKuM6O7 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

O M= artes, 5 de Marzo de 2013 11:53:13 Frank Reininghaus escribiu:

>= ; I'm not a network expert, and I don't know what the cause of the

>= ; problem is, but I noticed two things:

>= ;

>= ; 1. I think the access to "m_request" in FakeServer::*Reques= t() needs

>= ; to be protected by locking m_mutex. Doing that does not seem to fix

>= ; the issue, but not protecting it might lead to other problems at some=

>= ; point.

>= ;

>= ; 2. The class FakeServer follows the "You're doing it wrong"= pattern

>= ; (it contains the line "moveToThread(this);") , see

>= ;

>= ; http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/

>= ; http://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html

>= ;

>= ; This might or might not be part of the problem.

 

Man= y thanks for the input!

 

I t= hink I=E2=80=99ve solve both issues, but the race condition persists.

 

I=E2= =80=99ve uploaded a tar.xz with the current state of the test files to = Gitorious: https://gitorious.org/libmediawiki/libmediawiki/blobs/raw/ga= llaecio/examples/raceissue/2ndAttemptToAvoidRaceCondition.tar.xz

 

The= files can also be found at https://gitorious.org/libmediawiki/libmedia= wiki/trees/gallaecio/examples/raceissue

 

I f= ollowed the lead of the Qt documentation, and the main function looks l= ike this now:

 

int main(int argc, char* argv[])=

{

QCoreApplication a(argc, arg= v);

 

QThread *serverThread =3D ne= w QThread();

FakeServer *fakeserver =3D n= ew FakeServer;

QObject::connect(serverThrea= d, SIGNAL(started()), fakeserver, SLOT(run()));

QObject::connect(serverThrea= d, SIGNAL(finished()), fakeserver, SLOT(deleteLater()));

fakeserver->moveToThread(= serverThread);

serverThread->start();

 

for (int i =3D 0; i < 100= 00; i++) {

 

Job job;

job.exec();

 

QList<FakeServer::Req= uest> requests =3D fakeserver->getRequest();

if (requests.size() !=3D= 1) qDebug() << requests.size() << "? WTF?";

else = qDebug() << requests.size() << ", as expected."= ;

 

fakeserver->clearRequ= est();

}

 

serverThread->quit();

 

return 0;

}

 

 

--nextPart21289991.gLxTKuM6O7-- --===============0284637378911970572== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --===============0284637378911970572==--