Changeset 20 for trunk/stoposclient.cpp


Ignore:
Timestamp:
04/01/14 12:59:46 (9 years ago)
Author:
willem
Message:

willem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stoposclient.cpp

    r14 r20  
    2323#include "shellenv.h"
    2424#include "stopos.h"
     25#define  CONNECT_ERROR_MSG "ERROR: Cannot connect to server"
     26#define  CONNECT_ERROR_RETRIES 10
    2527
    2628struct returnvalue
     
    121123int handle_add(wrequest &w,const std::string &fname,returnvalue &r, const bool quiet)
    122124{
    123   size_t number_of_lines;
     125  size_t number_of_lines=0;
    124126
    125127  bool read_from_stdin = 0;
     
    171173    w.set_value(line);
    172174
    173     rc = w.send_message(body,header);
    174 
     175    for (int i=0; i<CONNECT_ERROR_RETRIES; i++)
     176    {
     177      rc = w.send_message(body,header);
     178      if (rc == 0) break;
     179      sleep(1);
     180    }
    175181    if (rc != 0)
    176182    {
    177       r.msg = "ERROR: Cannot connect to server";
     183      r.msg = CONNECT_ERROR_MSG;
    178184      return 1;
    179185    }
     186
    180187    r.parse(body);
    181188    if (r.msg != "OK")
     
    420427    std::string body,header;
    421428
    422     rc = w.send_message(body,header);
    423 
     429    for (int i=0; i<CONNECT_ERROR_RETRIES; i++)
     430    {
     431      rc = w.send_message(body,header);
     432      if (rc == 0) break;
     433      sleep(1);
     434    }
    424435    if (rc != 0)
    425       r.msg = "ERROR: Cannot connect to server";
     436      r.msg = CONNECT_ERROR_MSG;
    426437    else
    427438      r.parse(body);
Note: See TracChangeset for help on using the changeset viewer.