lliopipe.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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=viewergpl$
  8. *
  9. * Copyright (c) 2004-2009, Linden Research, Inc.
  10. *
  11. * Second Life Viewer Source Code
  12. * The source code in this file ("Source Code") is provided by Linden Lab
  13. * to you under the terms of the GNU General Public License, version 2.0
  14. * ("GPL"), unless you have obtained a separate licensing agreement
  15. * ("Other License"), formally executed by you and Linden Lab. Terms of
  16. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  17. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  18. *
  19. * There are special exceptions to the terms and conditions of the GPL as
  20. * it is applied to this Source Code. View the full text of the exception
  21. * in the file doc/FLOSS-exception.txt in this software distribution, or
  22. * online at
  23. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  24. *
  25. * By copying, modifying or distributing this software, you acknowledge
  26. * that you have read and understood your obligations described above,
  27. * and agree to abide by those obligations.
  28. *
  29. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  30. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  31. * COMPLETENESS OR PERFORMANCE.
  32. * $/LicenseInfo$
  33. */
  34. #include "linden_common.h"
  35. #include "lliopipe.h"
  36. #include "llpumpio.h"
  37. static const std::string STATUS_SUCCESS_NAMES[LLIOPipe::STATUS_SUCCESS_COUNT] =
  38. {
  39. std::string("STATUS_OK"),
  40. std::string("STATUS_STOP"),
  41. std::string("STATUS_DONE"),
  42. std::string("STATUS_BREAK"),
  43. std::string("STATUS_NEED_PROCESS"),
  44. };
  45. static const std::string STATUS_ERROR_NAMES[LLIOPipe::STATUS_ERROR_COUNT] =
  46. {
  47. std::string("STATUS_ERROR"),
  48. std::string("STATUS_NOT_IMPLEMENTED"),
  49. std::string("STATUS_PRECONDITION_NOT_MET"),
  50. std::string("STATUS_NO_CONNECTION"),
  51. std::string("STATUS_LOST_CONNECTION"),
  52. std::string("STATUS_EXPIRED"),
  53. };
  54. #ifdef LL_DEBUG_PUMPS
  55. // Debugging schmutz for deadlock
  56. const char* gPumpFile = "";
  57. S32 gPumpLine = 0;
  58. void pump_debug(const char *file, S32 line)
  59. {
  60. gPumpFile = file;
  61. gPumpLine = line;
  62. }
  63. #endif /* LL_DEBUG_PUMPS */
  64. /**
  65. * LLIOPipe
  66. */
  67. LLIOPipe::LLIOPipe()
  68. : mReferenceCount(0)
  69. {
  70. }
  71. LLIOPipe::~LLIOPipe()
  72. {
  73. //lldebugs << "destroying LLIOPipe" << llendl;
  74. }
  75. //virtual
  76. bool LLIOPipe::isValid()
  77. {
  78. return true;
  79. }
  80. // static
  81. std::string LLIOPipe::lookupStatusString(EStatus status)
  82. {
  83. if (status >= 0 && status < STATUS_SUCCESS_COUNT)
  84. {
  85. return STATUS_SUCCESS_NAMES[status];
  86. }
  87. else
  88. {
  89. S32 error_code = ((S32)status * -1) - 1;
  90. if (error_code < STATUS_ERROR_COUNT)
  91. {
  92. return STATUS_ERROR_NAMES[error_code];
  93. }
  94. }
  95. std::string rv;
  96. return rv;
  97. }
  98. LLIOPipe::EStatus LLIOPipe::process(const LLChannelDescriptors& channels,
  99. buffer_ptr_t& buffer,
  100. bool& eos,
  101. LLSD& context,
  102. LLPumpIO* pump)
  103. {
  104. return process_impl(channels, buffer, eos, context, pump);
  105. }
  106. // virtual
  107. LLIOPipe::EStatus LLIOPipe::handleError(LLIOPipe::EStatus status,
  108. LLPumpIO* pump)
  109. {
  110. // by default, the error is not handled.
  111. return status;
  112. }