/indra/newview/llsrv.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 64 lines · 27 code · 8 blank · 29 comment · 2 complexity · 31f978bd9a1103b35ff42016a2a20136 MD5 · raw file

  1. /**
  2. * @file llsrv.cpp
  3. * @brief Wrapper for DNS SRV record lookups
  4. *
  5. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, 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. #include "llviewerprecompiledheaders.h"
  27. #include "llsrv.h"
  28. #include "llares.h"
  29. struct Responder : public LLAres::UriRewriteResponder
  30. {
  31. std::vector<std::string> mUris;
  32. void rewriteResult(const std::vector<std::string> &uris) {
  33. for (size_t i = 0; i < uris.size(); i++)
  34. {
  35. llinfos << "[" << i << "] " << uris[i] << llendl;
  36. }
  37. mUris = uris;
  38. }
  39. };
  40. std::vector<std::string> LLSRV::rewriteURI(const std::string& uri)
  41. {
  42. LLPointer<Responder> resp = new Responder;
  43. gAres->rewriteURI(uri, resp);
  44. gAres->processAll();
  45. // It's been observed in deployment that c-ares can return control
  46. // to us without firing all of our callbacks, in which case the
  47. // returned vector will be empty, instead of a singleton as we
  48. // might wish.
  49. if (!resp->mUris.empty())
  50. {
  51. return resp->mUris;
  52. }
  53. std::vector<std::string> uris;
  54. uris.push_back(uri);
  55. return uris;
  56. }