mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
avoid closing local sockets before writing is finished
This commit is contained in:
parent
9ce0da721e
commit
b0b1a5e98c
@ -62,6 +62,8 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
|
||||
return false;
|
||||
}
|
||||
|
||||
localSocket->waitForBytesWritten(2000);
|
||||
|
||||
//QByteArray data;
|
||||
tries = 0;
|
||||
int dataAvailable = 0;
|
||||
@ -128,6 +130,7 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
|
||||
localSocket->connectToServer(YACREADERLIBRARY_GUID);
|
||||
if(localSocket->isOpen())
|
||||
{
|
||||
//QLOG_INFO() << "Connection opened for sending ComicInfo";
|
||||
QByteArray block;
|
||||
QDataStream out(&block, QIODevice::WriteOnly);
|
||||
out.setVersion(QDataStream::Qt_4_8);
|
||||
@ -148,7 +151,9 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
|
||||
tries++;
|
||||
previousWritten = written;
|
||||
}
|
||||
localSocket->waitForBytesWritten(2000);
|
||||
localSocket->close();
|
||||
//QLOG_INFO() << QString("Sending Comic Info : writen data (%1,%2)").arg(written).arg(block.size());
|
||||
if(tries == 100 && written != block.size())
|
||||
{
|
||||
emit finished();
|
||||
|
@ -110,7 +110,7 @@ void YACReaderClientConnectionWorker::run()
|
||||
}
|
||||
if(tries == 20)
|
||||
{
|
||||
QLOG_ERROR() << "Local connection: unable to read the message size";
|
||||
QLOG_ERROR() << "Local connection: unable to read the message size" << clientConnection->errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -163,6 +163,7 @@ void YACReaderClientConnectionWorker::run()
|
||||
while(written != block.size() && tries < 200)
|
||||
{
|
||||
int ret = clientConnection->write(block);
|
||||
clientConnection->waitForBytesWritten(10);
|
||||
if(ret != -1)
|
||||
{
|
||||
written += ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user