MCPcopy Create free account
hub / github.com/BaseXdb/basex / run

Method run

basex-api/src/main/qt/basexthread.cpp:39–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39void BaseXThread::run(){
40
41 if (firstRun){
42 socket = new QTcpSocket();
43 firstRun=false;
44 }
45
46 while(!quit){
47
48 mutex.lock();
49 QString actualQuery = requestQueue.dequeue();
50 mutex.unlock();
51
52 if(!socket->isOpen()){
53
54 socket->connectToHost(hostName, port);
55
56 if (!socket->waitForConnected(Timeout)) {
57 emit socketError(socket->error(), socket->errorString());
58 return;
59 }
60
61
62 if(!connectToBasex()) {
63 return;
64 }
65
66
67
68 }
69
70 char* q = actualQuery.toUtf8().data();
71 QByteArray * ts = new QByteArray();
72
73 socket->write(q, strlen(q)+1);
74 if (!socket->waitForBytesWritten(Timeout)) {
75 emit socketError(socket->error(), socket->errorString());
76 //return false;
77 }else{
78 bool leave = false;
79 bool xqueryError = false;
80 while (!leave) {
81 if (!socket->waitForReadyRead(Timeout)) {
82 emit socketError(socket->error(), socket->errorString());
83
84 }else{
85 ts->append(socket->readAll());
86 if (ts->endsWith(END_RES)) leave=true;
87 if (ts->endsWith(RES_FAIL)){
88 leave=true;
89 xqueryError=true;
90 }
91 }
92 }
93// QString resString(*ts);
94// qDebug()<<"res: "<<(xqueryError?"error:":"")<<resString;
95 if (xqueryError) emit socketError(1001, "BaseX Error in request: \n"+actualQuery);
96 }

Callers

nothing calls this directly

Calls 9

isOpenMethod · 0.80
appendMethod · 0.65
sizeMethod · 0.65
lockMethod · 0.45
errorMethod · 0.45
dataMethod · 0.45
writeMethod · 0.45
endsWithMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected