Skip to content

Commit

Permalink
Fix cpplint errors in src/io
Browse files Browse the repository at this point in the history
All production C++ code under src/io pass cleanly with these changes

Change-Id: I7fb24437dd502d7ef36f82d5b5a12dfdb4ab901e
Partial-Bug: 1602347
  • Loading branch information
ananth-at-camphor-networks committed Aug 10, 2016
1 parent b7bc1f2 commit 335b84a
Show file tree
Hide file tree
Showing 41 changed files with 356 additions and 345 deletions.
4 changes: 2 additions & 2 deletions src/analytics/collector.cc
Expand Up @@ -372,10 +372,10 @@ void Collector::GetGeneratorUVEInfo(vector<ModuleServerState> &genlist) {
if (session) {
ginfo.set_session_stats(session->GetStats());
SocketIOStats rx_stats;
session->GetRxSocketStats(rx_stats);
session->GetRxSocketStats(&rx_stats);
ginfo.set_session_rx_socket_stats(rx_stats);
SocketIOStats tx_stats;
session->GetTxSocketStats(tx_stats);
session->GetTxSocketStats(&tx_stats);
ginfo.set_session_tx_socket_stats(tx_stats);
}

Expand Down
4 changes: 2 additions & 2 deletions src/analytics/ipfix_collector.cc
Expand Up @@ -26,7 +26,7 @@ static map<string,string> uflowfields_ = boost::assign::map_list_of(
"ingressInterface","pifindex");


void IpfixCollector::HandleReceive(boost::asio::const_buffer& buffer,
void IpfixCollector::HandleReceive(const boost::asio::const_buffer& buffer,
boost::asio::ip::udp::endpoint remote_endpoint,
size_t bytes_transferred,
const boost::system::error_code& error) {
Expand Down Expand Up @@ -81,7 +81,7 @@ void IpfixCollector::Shutdown() {
}
}

void IpfixCollector::ProcessIpfixPacket(boost::asio::const_buffer& buffer,
void IpfixCollector::ProcessIpfixPacket(const boost::asio::const_buffer& buffer,
size_t length,
boost::asio::ip::udp::endpoint generator_ip) {
num_packets_++;
Expand Down
8 changes: 4 additions & 4 deletions src/analytics/ipfix_collector.h
Expand Up @@ -45,13 +45,13 @@ class IpfixCollector : public UdpServer {
std::map<std::string,std::string> uflowfields_;
boost::scoped_ptr<ipfix_col_info> colinfo_;

void HandleReceive(boost::asio::const_buffer& buffer,
void HandleReceive(const boost::asio::const_buffer& buffer,
boost::asio::ip::udp::endpoint remote_endpoint,
size_t bytes_transferred,
const boost::system::error_code& error);
void ProcessIpfixPacket(boost::asio::const_buffer& buffer,
size_t length,
boost::asio::ip::udp::endpoint generator_ip);
void ProcessIpfixPacket(const boost::asio::const_buffer& buffer,
size_t length,
boost::asio::ip::udp::endpoint generator_ip);

int RegisterCb(void);

Expand Down
4 changes: 2 additions & 2 deletions src/analytics/main.cc
Expand Up @@ -114,10 +114,10 @@ bool CollectorSummaryLogger(Collector *collector, const string & hostname,

// Get socket stats
SocketIOStats rx_stats;
collector->GetRxSocketStats(rx_stats);
collector->GetRxSocketStats(&rx_stats);
state.set_rx_socket_stats(rx_stats);
SocketIOStats tx_stats;
collector->GetTxSocketStats(tx_stats);
collector->GetTxSocketStats(&tx_stats);
state.set_tx_socket_stats(tx_stats);

CollectorInfo::Send(state);
Expand Down
22 changes: 11 additions & 11 deletions src/analytics/protobuf_server.cc
Expand Up @@ -383,7 +383,7 @@ void ProcessProtobufMessage(const Message& message,
} // namespace impl

class ProtobufServer::ProtobufServerImpl {
public:
public:
ProtobufServerImpl(EventManager *evm, uint16_t udp_server_port,
StatWalker::StatTableInsertFn stat_db_callback) :
udp_server_(new ProtobufUdpServer(evm, udp_server_port,
Expand Down Expand Up @@ -417,12 +417,12 @@ class ProtobufServer::ProtobufServerImpl {
return udp_server_->GetReceivedMessageStatistics(v_rx_msg_stats);
}

private:
private:
//
// ProtobufUdpServer
//
class ProtobufUdpServer : public UdpServer {
public:
public:
ProtobufUdpServer(EventManager *evm, uint16_t port,
StatWalker::StatTableInsertFn stat_db_callback) :
UdpServer(evm, kBufferSize),
Expand All @@ -447,7 +447,7 @@ class ProtobufServer::ProtobufServerImpl {
return true;
}

virtual void OnRead(boost::asio::const_buffer &recv_buffer,
virtual void OnRead(const boost::asio::const_buffer &recv_buffer,
const boost::asio::ip::udp::endpoint &remote_endpoint) {
uint64_t timestamp;
Message *message = NULL;
Expand Down Expand Up @@ -476,12 +476,12 @@ class ProtobufServer::ProtobufServerImpl {
std::vector<SocketEndpointMessageStats> *v_rx_msg_stats) {
if (v_tx_stats != NULL) {
SocketIOStats tx_stats;
GetTxSocketStats(tx_stats);
GetTxSocketStats(&tx_stats);
v_tx_stats->push_back(tx_stats);
}
if (v_rx_stats != NULL) {
SocketIOStats rx_stats;
GetRxSocketStats(rx_stats);
GetRxSocketStats(&rx_stats);
v_rx_stats->push_back(rx_stats);
}
if (v_rx_msg_stats != NULL) {
Expand All @@ -494,12 +494,12 @@ class ProtobufServer::ProtobufServerImpl {
msg_stats_.GetRx(v_rx_msg_stats);
}

private:
private:
//
// MessageStatistics
//
class MessageStatistics {
public:
public:
void UpdateRx(
const boost::asio::ip::udp::endpoint &remote_endpoint,
const std::string &message_name,
Expand All @@ -519,7 +519,7 @@ class ProtobufServer::ProtobufServerImpl {
std::vector<SocketEndpointMessageStats> *semsv) {
GetRxInternal(semsv, false);
}
private:
private:
class MessageInfo;

void GetRxInternal(
Expand Down Expand Up @@ -567,7 +567,7 @@ class ProtobufServer::ProtobufServerImpl {
// MessageInfo
//
class MessageInfo {
public:
public:
MessageInfo() :
messages_(0),
bytes_(0),
Expand Down Expand Up @@ -598,7 +598,7 @@ class ProtobufServer::ProtobufServerImpl {
sems->set_last_timestamp(last_timestamp_);
}

private:
private:
uint64_t messages_;
uint64_t bytes_;
uint64_t errors_;
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/sflow_collector.cc
Expand Up @@ -35,7 +35,7 @@ void SFlowCollector::Shutdown() {
}
}

void SFlowCollector::HandleReceive(boost::asio::const_buffer& buffer,
void SFlowCollector::HandleReceive(const boost::asio::const_buffer& buffer,
boost::asio::ip::udp::endpoint remote_endpoint,
size_t bytes_transferred,
const boost::system::error_code& error) {
Expand All @@ -47,7 +47,7 @@ void SFlowCollector::HandleReceive(boost::asio::const_buffer& buffer,
}
}

void SFlowCollector::ProcessSFlowPacket(boost::asio::const_buffer& buffer,
void SFlowCollector::ProcessSFlowPacket(const boost::asio::const_buffer& buffer,
size_t length,
const std::string& generator_ip) {
num_packets_++;
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/sflow_collector.h
Expand Up @@ -24,11 +24,11 @@ class SFlowCollector : public UdpServer {
virtual void Shutdown();

private:
void HandleReceive(boost::asio::const_buffer& buffer,
void HandleReceive(const boost::asio::const_buffer& buffer,
boost::asio::ip::udp::endpoint remote_endpoint,
size_t bytes_transferred,
const boost::system::error_code& error);
void ProcessSFlowPacket(boost::asio::const_buffer& buffer,
void ProcessSFlowPacket(const boost::asio::const_buffer& buffer,
size_t length,
const std::string& generator_ip);
SFlowGenerator* GetSFlowGenerator(const std::string& generator_ip);
Expand Down
2 changes: 1 addition & 1 deletion src/analytics/sflow_generator.cc
Expand Up @@ -33,7 +33,7 @@ SFlowGenerator::SFlowGenerator(const std::string& ip_address,
SFlowGenerator::~SFlowGenerator() {
}

bool SFlowGenerator::EnqueueSFlowPacket(boost::asio::const_buffer& buffer,
bool SFlowGenerator::EnqueueSFlowPacket(const boost::asio::const_buffer& buffer,
size_t length, uint64_t timestamp) {
num_packets_++;
time_last_pkt_seen_ = timestamp;
Expand Down
2 changes: 1 addition & 1 deletion src/analytics/sflow_generator.h
Expand Up @@ -28,7 +28,7 @@ class SFlowGenerator {
SFlowCollector* sflow_collector,
DbHandlerPtr db_handler);
~SFlowGenerator();
bool EnqueueSFlowPacket(boost::asio::const_buffer& buffer,
bool EnqueueSFlowPacket(const boost::asio::const_buffer& buffer,
size_t length, uint64_t timestamp);
private:
bool ProcessSFlowPacket(boost::shared_ptr<SFlowQueueEntry>);
Expand Down
8 changes: 4 additions & 4 deletions src/analytics/syslog_collector.cc
Expand Up @@ -63,7 +63,7 @@ class SyslogTcpSession : public TcpSession
typedef boost::intrusive_ptr<SyslogTcpSession> SyslogTcpSessionPtr;

SyslogTcpSession (SyslogTcpListener *server, Socket *socket);
virtual void OnRead (boost::asio::const_buffer buf);
virtual void OnRead (const boost::asio::const_buffer buf);
};

class TCPSyslogQueueEntry : public SyslogQueueEntry
Expand Down Expand Up @@ -91,7 +91,7 @@ class UDPSyslogQueueEntry : public SyslogQueueEntry
public:

UDPSyslogQueueEntry (SyslogUDPListener* svr, udp::endpoint ep,
boost::asio::const_buffer &d, size_t l):
const boost::asio::const_buffer &d, size_t l):
SyslogQueueEntry (d, l, ep.address ().to_string (), ep.port ()),
ep_ (ep), b_(d), server_ (svr)
{
Expand Down Expand Up @@ -612,7 +612,7 @@ void SyslogUDPListener::Start (std::string ipaddress, int port)
}

void SyslogUDPListener::HandleReceive (
boost::asio::const_buffer &recv_buffer,
const boost::asio::const_buffer &recv_buffer,
udp::endpoint remote_endpoint,
std::size_t bytes_transferred,
const boost::system::error_code& error)
Expand Down Expand Up @@ -705,7 +705,7 @@ SyslogTcpSession::SyslogTcpSession (SyslogTcpListener *server, Socket *socket) :
//set_observer(boost::bind(&SyslogTcpSession::OnEvent, this, _1, _2));
}
void
SyslogTcpSession::OnRead (boost::asio::const_buffer buf)
SyslogTcpSession::OnRead (const boost::asio::const_buffer buf)
{
boost::system::error_code ec;
// TODO: handle error
Expand Down
2 changes: 1 addition & 1 deletion src/analytics/syslog_collector.h
Expand Up @@ -56,7 +56,7 @@ class SyslogUDPListener: public UdpServer
virtual void Shutdown ();

private:
void HandleReceive (boost::asio::const_buffer &recv_buffer,
void HandleReceive(const boost::asio::const_buffer &recv_buffer,
boost::asio::ip::udp::endpoint remote_endpoint,
std::size_t bytes_transferred,
const boost::system::error_code& error);
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/viz_collector.cc
Expand Up @@ -272,10 +272,10 @@ class ShowCollectorServerHandler {
// Socket statistics
SocketIOStats rx_socket_stats;
Collector *collector(vsc->Analytics()->GetCollector());
collector->GetRxSocketStats(rx_socket_stats);
collector->GetRxSocketStats(&rx_socket_stats);
resp->set_rx_socket_stats(rx_socket_stats);
SocketIOStats tx_socket_stats;
collector->GetTxSocketStats(tx_socket_stats);
collector->GetTxSocketStats(&tx_socket_stats);
resp->set_tx_socket_stats(tx_socket_stats);
// Collector statistics
resp->set_stats(vsc->Analytics()->GetCollector()->GetStats());
Expand Down
2 changes: 1 addition & 1 deletion src/bfd/bfd_udp_connection.cc
Expand Up @@ -26,7 +26,7 @@ void UDPConnectionManager::UDPRecvServer::RegisterCallback(
}

void UDPConnectionManager::UDPRecvServer::HandleReceive(
boost::asio::const_buffer &recv_buffer,
const boost::asio::const_buffer &recv_buffer,
boost::asio::ip::udp::endpoint remote_endpoint,
std::size_t bytes_transferred,
const boost::system::error_code& error) {
Expand Down
2 changes: 1 addition & 1 deletion src/bfd/bfd_udp_connection.h
Expand Up @@ -35,7 +35,7 @@ class UDPConnectionManager : public Connection {
public:
UDPRecvServer(EventManager *evm, int recvPort);
void RegisterCallback(RecvCallback callback);
void HandleReceive(boost::asio::const_buffer &recv_buffer,
void HandleReceive(const boost::asio::const_buffer &recv_buffer,
boost::asio::ip::udp::endpoint remote_endpoint,
std::size_t bytes_transferred,
const boost::system::error_code& error);
Expand Down
4 changes: 2 additions & 2 deletions src/bgp/bgp_sandesh.cc
Expand Up @@ -407,10 +407,10 @@ class ShowBgpServerHandler {

ShowBgpServerResp *resp = new ShowBgpServerResp;
SocketIOStats peer_socket_stats;
bsc->bgp_server->session_manager()->GetRxSocketStats(peer_socket_stats);
bsc->bgp_server->session_manager()->GetRxSocketStats(&peer_socket_stats);
resp->set_rx_socket_stats(peer_socket_stats);

bsc->bgp_server->session_manager()->GetTxSocketStats(peer_socket_stats);
bsc->bgp_server->session_manager()->GetTxSocketStats(&peer_socket_stats);
resp->set_tx_socket_stats(peer_socket_stats);

resp->set_context(req->context());
Expand Down
8 changes: 4 additions & 4 deletions src/io/event_manager.cc
Expand Up @@ -4,11 +4,13 @@

#include "Thrift.h"

#include <string>

#include "io/event_manager.h"
#include "base/logging.h"
#include "io/io_log.h"

using namespace boost::asio;
using boost::asio::io_service;

SandeshTraceBufferPtr IOTraceBuf(SandeshTraceBufferCreate(IO_TRACE_BUF, 1000));

Expand All @@ -18,13 +20,11 @@ EventManager::EventManager() {

void EventManager::Shutdown() {
shutdown_ = true;

// TODO: make sure that are no users of this event manager.
io_service_.stop();
}

void EventManager::Run() {
using namespace apache::thrift;
using apache::thrift::TException;

assert(mutex_.try_lock());
io_service::work work(io_service_);
Expand Down
7 changes: 6 additions & 1 deletion src/io/event_manager.h
Expand Up @@ -2,10 +2,13 @@
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/

#ifndef SRC_IO_EVENT_MANAGER_H_
#define SRC_IO_EVENT_MANAGER_H_

#pragma once

#include <boost/asio/io_service.hpp>
#include <tbb/spin_mutex.h>
#include <boost/asio/io_service.hpp>

#include "base/util.h"

Expand Down Expand Up @@ -42,3 +45,5 @@ class EventManager {

DISALLOW_COPY_AND_ASSIGN(EventManager);
};

#endif // SRC_IO_EVENT_MANAGER_H_
6 changes: 3 additions & 3 deletions src/io/io_log.h
Expand Up @@ -2,9 +2,9 @@
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/

#ifndef __IO_LOG_H__
#ifndef SRC_IO_IO_LOG_H_

#define __IO_LOG_H__
#define SRC_IO_IO_LOG_H_

#include "base/logging.h"
#include "sandesh/sandesh_types.h"
Expand Down Expand Up @@ -180,5 +180,5 @@ do { \
#define UDP_UT_LOG_DEBUG(arg) \
IO_UT_LOG_DEBUG(UdpMessage, "UDP", UDP_DIR_NA, arg)

#endif // __IO_LOG_H__
#endif // SRC_IO_IO_LOG_H_

0 comments on commit 335b84a

Please sign in to comment.