/indra/llmessage/lliopipe.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 120 lines · 72 code · 12 blank · 36 comment · 3 complexity · f328070b50d3a629f579cbf84c458120 MD5 · raw file

  1. /**
  2. * @file lliopipe.cpp
  3. * @author Phoenix
  4. * @date 2004-11-19
  5. * @brief Implementation of the LLIOPipe class
  6. *
  7. * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include "linden_common.h"
  29. #include "lliopipe.h"
  30. #include "llpumpio.h"
  31. static const std::string STATUS_SUCCESS_NAMES[LLIOPipe::STATUS_SUCCESS_COUNT] =
  32. {
  33. std::string("STATUS_OK"),
  34. std::string("STATUS_STOP"),
  35. std::string("STATUS_DONE"),
  36. std::string("STATUS_BREAK"),
  37. std::string("STATUS_NEED_PROCESS"),
  38. };
  39. static const std::string STATUS_ERROR_NAMES[LLIOPipe::STATUS_ERROR_COUNT] =
  40. {
  41. std::string("STATUS_ERROR"),
  42. std::string("STATUS_NOT_IMPLEMENTED"),
  43. std::string("STATUS_PRECONDITION_NOT_MET"),
  44. std::string("STATUS_NO_CONNECTION"),
  45. std::string("STATUS_LOST_CONNECTION"),
  46. std::string("STATUS_EXPIRED"),
  47. };
  48. #ifdef LL_DEBUG_PUMPS
  49. // Debugging schmutz for deadlock
  50. const char *gPumpFile = "";
  51. S32 gPumpLine = 0;
  52. void pump_debug(const char *file, S32 line)
  53. {
  54. gPumpFile = file;
  55. gPumpLine = line;
  56. }
  57. #endif /* LL_DEBUG_PUMPS */
  58. /**
  59. * LLIOPipe
  60. */
  61. LLIOPipe::LLIOPipe() :
  62. mReferenceCount(0)
  63. {
  64. }
  65. LLIOPipe::~LLIOPipe()
  66. {
  67. //lldebugs << "destroying LLIOPipe" << llendl;
  68. }
  69. //virtual
  70. bool LLIOPipe::isValid()
  71. {
  72. return true ;
  73. }
  74. // static
  75. std::string LLIOPipe::lookupStatusString(EStatus status)
  76. {
  77. if((status >= 0) && (status < STATUS_SUCCESS_COUNT))
  78. {
  79. return STATUS_SUCCESS_NAMES[status];
  80. }
  81. else
  82. {
  83. S32 error_code = ((S32)status * -1) - 1;
  84. if(error_code < STATUS_ERROR_COUNT)
  85. {
  86. return STATUS_ERROR_NAMES[error_code];
  87. }
  88. }
  89. std::string rv;
  90. return rv;
  91. }
  92. LLIOPipe::EStatus LLIOPipe::process(
  93. const LLChannelDescriptors& channels,
  94. buffer_ptr_t& buffer,
  95. bool& eos,
  96. LLSD& context,
  97. LLPumpIO* pump)
  98. {
  99. return process_impl(channels, buffer, eos, context, pump);
  100. }
  101. // virtual
  102. LLIOPipe::EStatus LLIOPipe::handleError(
  103. LLIOPipe::EStatus status,
  104. LLPumpIO* pump)
  105. {
  106. // by default, the error is not handled.
  107. return status;
  108. }