Andrew Wong has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/17990 )

Change subject: KUDU-1959 - Add tests for /startup page and metrics for tservers
......................................................................


Patch Set 13:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/17990/13/src/kudu/server/webserver.cc
File src/kudu/server/webserver.cc:

http://gerrit.cloudera.org:8080/#/c/17990/13/src/kudu/server/webserver.cc@815
PS13, Line 815:   {
              :     static simple_spinlock pathHandlerLock_;
              :     std::lock_guard<simple_spinlock> l(pathHandlerLock_);
              :     for (const PathHandlerMap::value_type &handler: 
path_handlers_) {
              :       if (handler.second->is_on_nav_bar()) {
              :         EasyJson path_handler = 
path_handlers.PushBack(EasyJson::kObject);
              :         path_handler["path"] = handler.first;
              :         path_handler["alias"] = handler.second->alias();
              :       }
              :     }
              :   }
Introducing a new static lock has some code smell. It's true, there's typically 
only one webserver per Kudu process, but it's pretty surprising to have such a 
limitation that all Webserver instances share this lock.

Instead, how about we copy the pointers in 'path_handlers_' while under the 
lock we already have, something like

...
vector<pair<string, PathHandler*> paths_and_handlers;
{
  shared_lock<RWMutex> l(lock_);
  ej["footer_html"] = footer_html_;
  paths_and_handlers.reserve(path_handlers.size());
  for (const auto& [path, handler] : path_handlers_) {
    paths_and_handlers.emplace_back(path, handler);
  }
}
EasyJson path_handlers = ej.Set("path_handlers", EasyJson::kArray);
for (const auto& [path, handler] : paths_and_handlers) {
  if (handler.second->is_on_nav_bar()) {
    EasyJson path_handler = path_handlers.PushBack(EasyJson::kObject);
    path_handler["path"] = path;
    path_handler["alias"] = handler->alias();
  }
}



--
To view, visit http://gerrit.cloudera.org:8080/17990
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9f432b4eb813e51214b4d6b3c5b7b4c89426f47f
Gerrit-Change-Number: 17990
Gerrit-PatchSet: 13
Gerrit-Owner: Abhishek Chennaka <[email protected]>
Gerrit-Reviewer: Abhishek Chennaka <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Attila Bukor <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Mon, 29 Nov 2021 06:00:04 +0000
Gerrit-HasComments: Yes

Reply via email to