Skip to content
Snippets Groups Projects
  1. Mar 01, 2012
  2. Feb 29, 2012
    • Nat Goodspeed's avatar
      When constructing a pipe to child stdin on Posix, ignore SIGPIPE. · 40dc3e0d
      Nat Goodspeed authored
      We can't count on every child process reading everything we try to write to
      it. And if the child terminates with WritePipe data still pending, unless we
      explicitly suppress it, Posix will hit us with SIGPIPE. That would terminate
      the calling process, boom. "Ignoring" it means APR gets the correct errno,
      passes it back to us, we log it, etc.
      40dc3e0d
    • Nat Goodspeed's avatar
      Guarantee LLProcess::Params::postend listener any ReadPipe data. · 3649eda6
      Nat Goodspeed authored
      Previously one might get process-terminated notification but still have to
      wait for the child process's final data to arrive on one or more ReadPipes.
      That required complex consumer timing logic to handle incomplete pending
      ReadPipe data, e.g. a partial last line with no terminating newline. New code
      guarantees that by the time LLProcess sends process-terminated notification,
      all pending pipe data will have been buffered in ReadPipes.
      Document LLProcess::ReadPipe::getPump() notification event; add "eof" key.
      Add LLProcess::ReadPipe::getline() and read() convenience methods.
      Add static LLProcess::getline() and basename() convenience methods, publishing
      logic already present elsewhere.
      Use ReadPipe::getline() and read() in unit tests.
      Add unit test for "eof" event on ReadPipe::getPump().
      Add unit test verifying that final data have been buffered by termination
      notification event.
      3649eda6
  3. Feb 27, 2012
  4. Feb 26, 2012
  5. Feb 24, 2012
    • Nat Goodspeed's avatar
      Get rid of indra/llcommon/tests/setpython.py. · d2faf5d2
      Nat Goodspeed authored
      run_build_test.py already has the capability to set environment variables, and
      we may as well direct it to set PYTHON to the running Python interpreter. That
      completely eliminates one level of process wrapper.
      d2faf5d2
    • Nat Goodspeed's avatar
    • Nat Goodspeed's avatar
    • Nat Goodspeed's avatar
      Add LLStringUtil::getTokens() overload handling quoted substrings. · 025329b6
      Nat Goodspeed authored
      We didn't have any tokenizer suitable for scanning something like a bash
      command line. We do have a couple hacks, e.g. LLExternalEditor::tokenize() and
      LLCommandLineParser::parseCommandLineString(). Both try to work around
      boost::tokenizer limitations; but existing boost::tokenizer support just
      doesn't address this case. Neither of the above is available as a general
      scanner anyway, and parseCommandLineString() fails outright when passed "".
      New getTokens() also distinguishes between "drop delimiters" (e.g. space,
      return, newline) to be discarded from the token stream, versus "keep
      delimiters" (e.g. "+-*/") to be returned as tokens in their own right.
      There's an overload that honors escapes and a more efficient one that doesn't;
      each has a convenience overload that returns the scanned string vector rather
      than requiring a separate declaration.
      Tweak and comment older getTokens() implementation.
      Add unit tests for both old and new getTokens() implementations.
      Break out StringVec and std::ostream << StringVec from
      indra/llcommon/tests/listener.h to StringVec.h: that's coming in handy for a
      number of different TUT test sources.
      025329b6
  6. Feb 23, 2012
    • Nat Goodspeed's avatar
      Tighten up LLProcess pipe support, per Richard's code review. · 14ddc647
      Nat Goodspeed authored
      Clarify wording in some of the doc comments; be a bit more explicit about some
      of the parameter fields.
      Make some query methods 'const'.
      Change default LLProcess::ReadPipe::getLimit() value to 0: don't post any
      incoming data with notification event unless caller requests it. But do post
      pertinent FILESLOT in case caller reuses same listener for both stdout and
      stderr.
      Use more idiomatic, readable syntax for accessing LLProcess::Params data.
      14ddc647
  7. Feb 20, 2012
    • Nat Goodspeed's avatar
      Let LLProcess consumer specify desired description for logging. · 999484a6
      Nat Goodspeed authored
      If caller runs (e.g.) a Python script, it's not very helpful to a human log
      reader to keep seeing LLProcess instances logged as /pathname/to/python (pid).
      If caller is aware, the code can at least use the script name as the desc --
      or maybe even a hint as to the script's purpose.
      If caller doesn't explicitly pass a desc, at least shorten to just the
      basename of the executable.
      999484a6
    • Nat Goodspeed's avatar
      Make LLProcess post termination event to specified pump if desired. · 8b5d5f96
      Nat Goodspeed authored
      This way a caller need not spin on isRunning(); we can just listen for the
      requested termination event.
      Post a similar event containing error message if for any reason
      LLProcess::create() failed to launch the child.
      Add unit tests for both cases.
      8b5d5f96
  8. Feb 18, 2012
  9. Feb 16, 2012
    • Nat Goodspeed's avatar
      Fix typos in a few LLProcess::ReadPipe::find() unit tests. · f52cf4be
      Nat Goodspeed authored
      The typos didn't make for invalid tests, but they made a few tests redundant
      while leaving other (subtly different) cases untested.
      f52cf4be
    • Nat Goodspeed's avatar
    • Nat Goodspeed's avatar
      Fix bug in LLProcess::ReadPipe::peek() substring computation. · a06ba836
      Nat Goodspeed authored
      Add unit tests for peek() with substring args, reimplemented contains(),
      various forms of find().
      (yay unit tests)
      a06ba836
    • Nat Goodspeed's avatar
      4ecf9d6a
    • Nat Goodspeed's avatar
      Add LLProcess::ReadPipe::find() methods, with corresponding npos. · e92c3113
      Nat Goodspeed authored
      If it's useful to have contains() to tell you whether incoming data contains a
      particular substring, and if it's useful for contains() and peek() to accept
      an offset within that data, then it's useful to allow you to get the offset of
      a desired substring within that data. But of course a find() returning offset
      needs something like std::string::npos for "not found"; borrow that
      convention.
      Support both find(const std::string&) and find(char); the latter permits a
      more efficient implementation. In fact, make find(string) recognize a string
      of length 1 and leverage the find(char) implementation.
      Given that, reimplement contains(mumble) as shorthand for find(mumble) != npos.
      Implement find() overloads using std::search() and std::find() on
      boost::asio::streambuf character iterators, rather than copying to std::string
      and then using string search like previous contains() implementation.
      Reimplement WritePipeImpl::tick() and ReadPipeImpl::tick() to write/read
      directly from/to boost::asio::streambuf data, instead of copying to/from a
      temporary flat buffer.
      As long as ReadPipeImpl::tick() keeps successfully filling buffers, keep
      reading. Previous implementation would only handle a long child write over
      successive tick() calls. Stop on read error or when we come up short.
      e92c3113
  10. Feb 15, 2012
    • Nat Goodspeed's avatar
    • Nat Goodspeed's avatar
      Don't be confused by "\r\n" line endings on pipe on Windows. · fc6d70db
      Nat Goodspeed authored
      These are all very well when we just want to dump the output to a log, or
      whatever, but in a unit-test context it matters for comparison.
      fc6d70db
    • Nat Goodspeed's avatar
      Add LLProcess::ReadPipe::size(), peek(), contains(). · 56d93121
      Nat Goodspeed authored
      Also add "len" key to event data on LLProcess::getPump(). If you've used
      setLimit(), event["data"].length() may not reflect the length of the
      accumulated data in the ReadPipe.
      Add unit test with stdin/stdout handshake with child process.
      56d93121
    • Nat Goodspeed's avatar
    • Nat Goodspeed's avatar
      Fix llprocess_test.cpp's exception catching for Linux. · 10ab4adc
      Nat Goodspeed authored
      In the course of re-enabling the indra/test tests last year, Log generalized a
      workaround I'd introduced in llsdmessage_test.cpp. In Linux viewer land, a
      test program trying to catch an expected exception can't seem to catch it by
      its specific class (across the libllcommon.so boundary), but must instead
      catch std::runtime_error and validate the typeid().name() string. Log added a
      macro for this idiom in llevents_tut.cpp. Generalize that macro further for
      normal-case processing as well, move it to a header file of its own and use it
      in all known places -- plus the new exception-catching tests in
      llprocess_test.cpp.
      10ab4adc
    • Nat Goodspeed's avatar
    • Nat Goodspeed's avatar
      Preliminary pipe support for LLProcess. · e239cad1
      Nat Goodspeed authored
      Add LLProcess::FileParam to specify how to construct each child's standard
      file slot, with lots of comments about features designed but not yet
      implemented. The point is to design it with enough flexibility to be able to
      extend to foreseeable use cases.
      Add LLProcess::Params::files to collect up to 3 FileParam items. Naturally
      this extends the accepted LLSD syntax as well.
      Implement type="" (child inherits parent file descriptor) and "pipe" (parent
      constructs anonymous pipe to pass to child).
      Add LLProcess::FILESLOT enum, plus methods:
      getReadPipe(FILESLOT), getOptReadPipe(FILESLOT)
      getWritePipe(), getOptWritePipe()
      getPipeName(FILESLOT): placeholder implementation for now
      Add LLProcess::ReadPipe and WritePipe classes, as returned by get*Pipe().
      WritePipe supports get_ostream() method for streaming to child stdin.
      ReadPipe supports get_istream() method for reading from child stdout/stderr.
      It also provides getPump() returning LLEventPump& so interested parties can
      listen for arrival of new data on the aforementioned std::istream.
      For "pipe" slots, instantiate appropriate *Pipe class.
      ReadPipe and WritePipe classes are pure virtual bases for ReadPipeImpl and
      WritePipeImpl, respectively: all implementation data are hidden in the latter
      classes, visible only in llprocess.cpp. In fact each *PipeImpl class registers
      itself for "mainloop" ticks, attempting nonblocking I/O to the underlying
      apr_file_t on each tick. Data are buffered in a boost::asio::streambuf, which
      bridges between std::[io]stream and the APR I/O calls.
      Sanity-test ReadPipeImpl by using a pipe to absorb the Python "SyntaxError"
      output from the successful syntax_error test, rather than alarming the user.
      Add first few unit tests for validating FileParam. More tests coming!
      e239cad1
  11. Feb 13, 2012
    • Nat Goodspeed's avatar
      Use per-frame ticks on "mainloop" LLEventPump to update LLProcess. · aae61392
      Nat Goodspeed authored
      When we reimplemented LLProcess on APR, necessitating APR's funny callback
      mechanism to sense child-process status, every isRunning() or getStatus() call
      called the APR poll function that calls ALL registered LLProcess callbacks. In
      other words, every time any consumer called any LLProcess::isRunning() method,
      all LLProcess callbacks were redundantly fired. Change that so that the single
      APR poll function is called once per frame, courtesy of the "mainloop"
      LLEventPump. Once per viewer frame should be well within the realtime duration
      in which it's reasonable to expect child-process status to change.
      In effect, this changes LLProcess's public API to introduce a dependency on
      "mainloop" ticks. Add such ticks to llprocess_test.cpp as well.
      aae61392
    • Nat Goodspeed's avatar
      d4f887e4
    • Nat Goodspeed's avatar
  12. Feb 12, 2012
  13. Feb 11, 2012
  14. Feb 10, 2012
    • Nat Goodspeed's avatar
      Eliminate ManifestError for wildcards matching 0 files. · acd46062
      Nat Goodspeed authored
      Turns out that some (many?) wildcard LLManifest.path(wildcard) calls are "just
      in case": sweep up any (e.g.) "*.tga" files there may be, but no problem if
      there are none.
      Change path() logic so it tries the next tree (source, artwork, build) if
      either a specific (non-wildcard) filename doesn't exist, as now, OR if a
      wildcard matches 0 files in the current tree. This continues to support "just
      in case" wildcards, while permitting wildcards to work in the artwork and
      build trees as well as the source tree.
      Use a more specific exception than ManifestError for missing file. Only in
      that case should we try the next tree. Any other ManifestError should
      propagate.
      acd46062
Loading