Changeset fb5b0b8


Ignore:
Timestamp:
07/30/14 13:25:32 (7 weeks ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3
Children:
19bab26
Parents:
225746b
Message:

Clean up the syscache client/server connection a bit - now it will function even if a response is broken up (will combine as necessary), and start adding some rudimentary usage information.

Location:
src-sh/syscache
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-sh/syscache/client/syscache-client.cpp

    r0ac3332 rfb5b0b8  
    1212void SysCacheClient::parseInputs(QStringList inputs){ 
    1313  userRequest = inputs; 
     14  if(inputs.isEmpty()){ showUsage(); } 
    1415  //Convert the user request into server request formatting 
    1516  servRequest << inputs; 
    16          
     17   
    1718  //Now start the connection to the server 
    1819  curSock->connectToServer("/var/run/syscache.pipe", QIODevice::ReadWrite | QIODevice::Text); 
     20} 
     21 
     22void SysCacheClient::showUsage(){ 
     23  qDebug() << "[ERROR] Invalid Inputs: (usage text not written yet)"; 
     24 
     25  exit(1);       
    1926} 
    2027 
     
    2633 
    2734void SysCacheClient::requestFinished(){ 
     35  static bool running = false; 
     36  if(running){ return; } //already reading stream 
    2837  //qDebug() << "Client Request Finished"; 
    2938  QTextStream in(curSock); 
    3039  bool finished = false; 
     40  static QString line = ""; 
     41  running = true; 
    3142  while(!in.atEnd()){ 
    32     QString line = in.readLine(); 
     43    QString newline = in.readLine(); 
     44    if(newline.startsWith("[") && !line.isEmpty()){ 
     45      qDebug() << line;  
     46      line.clear(); 
     47      if(newline.startsWith("[INFOSTART]")){ 
     48        newline = newline.remove(0,11); //remove that internal flag  
     49      } 
     50    } 
     51    line.append(newline); 
    3352    if(line=="[FINISHED]"){ finished=true; break;} 
    34     else{ qDebug() << line; } 
    3553  } 
     54  running = false; 
    3655  if(finished){ 
    3756    curSock->disconnectFromServer(); 
  • src-sh/syscache/client/syscache-client.h

    r8c7378d rfb5b0b8  
    2525 
    2626private slots: 
     27        void showUsage(); 
     28 
    2729        //Server/Client connections 
    2830        void startRequest(); 
  • src-sh/syscache/daemon/syscache-daemon.cpp

    r0ac3332 rfb5b0b8  
    5555    //qDebug() << "Request Received:" << req; 
    5656    if(req.join("")=="shutdowndaemon"){ stopdaemon=true; break; } 
    57     else{ out << DATA->fetchInfo(req); } 
     57    else{ out << "[INFOSTART]"+DATA->fetchInfo(req); } 
    5858  } 
    5959  //Now write the output to the socket and disconnect it 
Note: See TracChangeset for help on using the changeset viewer.