From de121d0f66a66295f43844443a619db8b2baad3c Mon Sep 17 00:00:00 2001 From: me_desk Date: Sun, 15 Dec 2013 17:58:48 +0000 Subject: skip timer event if write_mutex is locked git-svn-id: svn://localhost/project_picapica/trunk@303 fb96df88-216d-11de-830c-f3023f12d8ac --- pica-client/skynet.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'pica-client') diff --git a/pica-client/skynet.cpp b/pica-client/skynet.cpp index 7770388..e868903 100644 --- a/pica-client/skynet.cpp +++ b/pica-client/skynet.cpp @@ -153,26 +153,27 @@ void SkyNet::verify_peer_cert(QByteArray peer_id, QString cert_pem, bool *verifi void SkyNet::timerEvent(QTimerEvent *e) { -if (self_aware) + if (self_aware) { - QList c2c_peer_ids = msgqueues.keys(); - - write_mutex.lock(); + if (write_mutex.tryLock(10)) + { + QList c2c_peer_ids = msgqueues.keys(); - c2c_peer_ids = filter_existing_chans(c2c_peer_ids); + c2c_peer_ids = filter_existing_chans(c2c_peer_ids); - for (int i = 0; i < c2c_peer_ids.size(); i++) - { - int ret; + for (int i = 0; i < c2c_peer_ids.size(); i++) + { + int ret; - struct PICA_chaninfo *chan = NULL; + struct PICA_chaninfo *chan = NULL; - ret = PICA_create_channel(nodelink, (const unsigned char*)c2c_peer_ids[i].constData(), &chan); + ret = PICA_create_channel(nodelink, (const unsigned char*)c2c_peer_ids[i].constData(), &chan); - qDebug()<<"restoring channel to "<