~jonathon-goldsmith/libmemcached/fix_sasl_configure

« back to all changes in this revision

Viewing changes to libtest/server.cc

  • Committer: Continuous Integration
  • Date: 2012-04-08 17:57:40 UTC
  • mfrom: (994.2.1 workspace)
  • Revision ID: ci@tangent.org-20120408175740-s8qf8vzo34xzljo8
jenkins-promote-staging-trunk-libmemcached-7

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include <cassert>
27
27
#include <cerrno>
 
28
#include <climits>
28
29
#include <cstdlib>
29
30
#include <iostream>
30
31
 
31
32
#include <algorithm> 
32
33
#include <functional> 
33
34
#include <locale>
 
35
#include <unistd.h>
34
36
 
35
37
// trim from end 
36
38
static inline std::string &rtrim(std::string &s)
159
161
  }
160
162
#endif
161
163
 
162
 
  if (getenv("YATL_VALGRIND_SERVER"))
 
164
  if (getenv("YATL_PTRCHECK_SERVER"))
 
165
  {
 
166
    _app.use_ptrcheck();
 
167
  }
 
168
  else if (getenv("YATL_VALGRIND_SERVER"))
163
169
  {
164
170
    _app.use_valgrind();
165
171
  }
166
 
  else if (args(_app) == false)
 
172
 
 
173
  if (args(_app) == false)
167
174
  {
168
175
    Error << "Could not build command()";
169
176
    return false;
182
189
    dream(5, 50000);
183
190
  }
184
191
 
185
 
  if (pid_file().empty() == false)
 
192
  size_t repeat= 5;
 
193
  _app.slurp();
 
194
  while (--repeat)
186
195
  {
187
 
    Wait wait(pid_file(), 8);
188
 
 
189
 
    if (wait.successful() == false)
 
196
    if (pid_file().empty() == false)
190
197
    {
191
 
      throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
192
 
                           "Unable to open pidfile for: %s",
193
 
                           _running.c_str());
 
198
      Wait wait(pid_file(), 8);
 
199
 
 
200
      if (wait.successful() == false)
 
201
      {
 
202
        if (_app.check())
 
203
        {
 
204
          continue;
 
205
        }
 
206
 
 
207
        char buf[PATH_MAX];
 
208
        getcwd(buf, sizeof(buf));
 
209
        throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
 
210
                             "Unable to open pidfile in %s for: %s stderr:%s",
 
211
                             buf,
 
212
                             _running.c_str(),
 
213
                             _app.stderr_c_str());
 
214
      }
194
215
    }
195
216
  }
196
217
 
220
241
  if (pinged == false)
221
242
  {
222
243
    // If we happen to have a pid file, lets try to kill it
223
 
    if (pid_file().empty() == false)
 
244
    if ((pid_file().empty() == false) and (access(pid_file().c_str(), R_OK) == 0))
224
245
    {
 
246
      _app.slurp();
225
247
      if (kill_file(pid_file()) == false)
226
248
      {
227
 
        throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "Failed to kill off server after startup occurred, when pinging failed: %s", pid_file().c_str());
 
249
        throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
 
250
                             "Failed to kill off server after startup occurred, when pinging failed: %s stderr:%s",
 
251
                             pid_file().c_str(),
 
252
                             _app.stderr_c_str());
228
253
      }
229
 
      Error << "Failed to ping(), waited:" << this_wait 
230
 
        << " server started, having pid_file. exec:" << _running 
231
 
        << " error:" << _app.stderr_result();
 
254
 
 
255
      throw libtest::fatal(LIBYATL_DEFAULT_PARAM, 
 
256
                           "Failed to ping(), waited: %u server started, having pid_file. exec: %s stderr:%s",
 
257
                           this_wait, _running.c_str(), 
 
258
                           _app.stderr_c_str());
232
259
    }
233
260
    else
234
261
    {
235
 
      Error << "Failed to ping() server started. exec:" << _running;
 
262
      throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
 
263
                           "Failed to ping() server started. exec: %s stderr:%s",
 
264
                           _running.c_str(),
 
265
                           _app.stderr_c_str());
236
266
    }
237
267
    _running.clear();
238
268
    return false;
307
337
  int fd;
308
338
  if ((fd= mkstemp(file_buffer)) == -1)
309
339
  {
310
 
    perror(file_buffer);
311
 
    return false;
 
340
    throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "mkstemp() failed on %s with %s", file_buffer, strerror(errno));
312
341
  }
313
342
  close(fd);
314
343
  unlink(file_buffer);