llcorehttpinternal.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * @file llcorehttpinternal.h
  3. * @brief Implementation constants and magic numbers
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2012, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef _LLCORE_HTTP_INTERNAL_H_
  27. #define _LLCORE_HTTP_INTERNAL_H_
  28. // If you find this included in a public interface header, something wrong is
  29. // probably happening.
  30. // --------------------------------------------------------------------
  31. // General library to-do list
  32. //
  33. // - Implement policy classes. Structure is mostly there just did not need it
  34. // for the first consumer (classes are there but more advanced features, like
  35. // borrowing, are not there yet).
  36. // - Set/get for global policy and policy classes is clumsy. Rework it heading
  37. // in a direction that allows for more dynamic behavior (mostly fixed).
  38. // - Move HttpOpRequest::prepareRequest() to HttpLibcurl for the pedantic.
  39. // - Update downloader and other long-duration services are going to need a
  40. // progress notification. Initial idea is to introduce a 'repeating request'
  41. // which can piggyback on another request and persist until cancelled or
  42. // carrier completes. Current queue structures allow an HttpOperation object
  43. // to be enqueued repeatedly, so...
  44. // - Investigate making c-ares' re-implementation of a resolver library more
  45. // resilient or more intelligent on Mac. Part of the DNS failure lies in
  46. // here. The mechanism also looks a little less dynamic than needed in an
  47. // environments where networking is changing.
  48. // - Global optimizations: 'borrowing' connections from other classes.
  49. // - Dynamic/control system stuff: detect problems and self-adjust. This would
  50. // not help in the face of the router problems we have looked at, however.
  51. // Detect starvation due to UDP activity and provide feedback to it.
  52. // - Change the transfer timeout scheme. We are less interested in absolute
  53. // time, in most cases, than in continuous progress.
  54. // - Many of the policy class settings are currently applied to the entire
  55. // class. Some, like connection limits, would be better applied to each
  56. // destination target making multiple targets independent.
  57. // --------------------------------------------------------------------
  58. namespace LLCore
  59. {
  60. // Maxium number of policy classes that can be defined.
  61. // *TODO: Currently limited to the default class + 1, extend.
  62. // TSN: should this be more dynamically sized ? Is there a reason to hard
  63. // limit the number of policies ?
  64. constexpr int HTTP_POLICY_CLASS_LIMIT = 32;
  65. // Debug/informational tracing. Used both as a global option and in per-request
  66. // traces.
  67. constexpr long HTTP_TRACE_OFF = 0;
  68. constexpr long HTTP_TRACE_LOW = 1;
  69. constexpr long HTTP_TRACE_CURL_HEADERS = 2;
  70. constexpr long HTTP_TRACE_CURL_BODIES = 3;
  71. constexpr long HTTP_TRACE_MIN = HTTP_TRACE_OFF;
  72. constexpr long HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES;
  73. // Request retry limits
  74. // At a minimum, retries need to extend past any throttling window we're
  75. // expecting from central services. In the case of Linden services running
  76. // through the caps routers, there's a five-second or so window for
  77. // throttling with some spillover. We want to span a few windows to allow
  78. // transport to slow after onset of the throttles and then recover without a
  79. // final failure. Other systems may need other constants.
  80. constexpr int HTTP_RETRY_COUNT_DEFAULT = 8;
  81. constexpr int HTTP_RETRY_COUNT_MIN = 0;
  82. constexpr int HTTP_RETRY_COUNT_MAX = 100;
  83. constexpr int HTTP_REDIRECTS_DEFAULT = 10;
  84. // Timeout value used for both connect and protocol exchange. Retries and
  85. // time-on-queue are not included and are not accounted for.
  86. constexpr long HTTP_REQUEST_TIMEOUT_DEFAULT = 30L;
  87. constexpr long HTTP_REQUEST_XFER_TIMEOUT_DEFAULT = 0L;
  88. constexpr long HTTP_REQUEST_TIMEOUT_MIN = 0L;
  89. constexpr long HTTP_REQUEST_TIMEOUT_MAX = 3600L;
  90. // Limits on connection counts
  91. constexpr int HTTP_CONNECTION_LIMIT_DEFAULT = 8;
  92. constexpr int HTTP_CONNECTION_LIMIT_MIN = 1;
  93. constexpr int HTTP_CONNECTION_LIMIT_MAX = 256;
  94. // Pipelining limits
  95. constexpr long HTTP_PIPELINING_DEFAULT = 0L;
  96. constexpr long HTTP_PIPELINING_MAX = 20L;
  97. // Miscellaneous defaults
  98. constexpr bool HTTP_USE_RETRY_AFTER_DEFAULT = true;
  99. constexpr long HTTP_THROTTLE_RATE_DEFAULT = 0L;
  100. // Tuning parameters
  101. // Time worker thread sleeps after a pass through the request, ready and active
  102. // queues.
  103. constexpr int HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS = 2;
  104. }
  105. #endif // _LLCORE_HTTP_INTERNAL_H_