Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the refactored version of Selectables #470

Merged
merged 3 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cfgmgr/buffermgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ int main(int argc, char **argv)
while (true)
{
Selectable *sel;
int fd, ret;
int ret;

ret = s.select(&sel, &fd, SELECT_TIMEOUT);
ret = s.select(&sel, SELECT_TIMEOUT);
if (ret == Select::ERROR)
{
SWSS_LOG_NOTICE("Error: %s!", strerror(errno));
Expand Down
4 changes: 2 additions & 2 deletions cfgmgr/intfmgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ int main(int argc, char **argv)
while (true)
{
Selectable *sel;
int fd, ret;
int ret;

ret = s.select(&sel, &fd, SELECT_TIMEOUT);
ret = s.select(&sel, SELECT_TIMEOUT);
if (ret == Select::ERROR)
{
SWSS_LOG_NOTICE("Error: %s!", strerror(errno));
Expand Down
4 changes: 2 additions & 2 deletions cfgmgr/vlanmgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ int main(int argc, char **argv)
while (true)
{
Selectable *sel;
int fd, ret;
int ret;

ret = s.select(&sel, &fd, SELECT_TIMEOUT);
ret = s.select(&sel, SELECT_TIMEOUT);
if (ret == Select::ERROR)
{
SWSS_LOG_NOTICE("Error: %s!", strerror(errno));
Expand Down
17 changes: 3 additions & 14 deletions fpmsyncd/fpmlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,12 @@ void FpmLink::accept()
SWSS_LOG_INFO("New connection accepted from: %s\n", inet_ntoa(client_addr.sin_addr));
}

void FpmLink::addFd(fd_set *fd)
int FpmLink::getFd()
{
FD_SET(m_connection_socket, fd);
return m_connection_socket;
}

bool FpmLink::isMe(fd_set *fd)
{
return FD_ISSET(m_connection_socket, fd);
}

int FpmLink::readCache()
{
/* FPM doesn't have any caching */
return NODATA;
}

void FpmLink::readMe()
void FpmLink::readData()
{
fpm_msg_hdr_t *hdr;
size_t msg_len;
Expand Down
7 changes: 2 additions & 5 deletions fpmsyncd/fpmlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ class FpmLink : public Selectable {
/* Wait for connection (blocking) */
void accept();

virtual void addFd(fd_set *fd);
virtual bool isMe(fd_set *fd);
virtual int readCache();
virtual void readMe();

int getFd() override;
void readData() override;
/* readMe throws FpmConnectionClosedException when connection is lost */
class FpmConnectionClosedException : public std::exception
{
Expand Down
5 changes: 2 additions & 3 deletions fpmsyncd/fpmsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ int main(int argc, char **argv)
while (true)
{
Selectable *temps;
int tempfd;
/* Reading FPM messages forever (and calling "readMe" to read them) */
s.select(&temps, &tempfd);
/* Reading FPM messages forever (and calling "readData" to read them) */
s.select(&temps);
pipeline.flush();
SWSS_LOG_DEBUG("Pipeline flushed");
}
Expand Down
3 changes: 1 addition & 2 deletions intfsyncd/intfsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ int main(int argc, char **argv)
while (true)
{
Selectable *temps;
int tempfd;
s.select(&temps, &tempfd);
s.select(&temps);
}
}
catch (const std::exception& e)
Expand Down
3 changes: 1 addition & 2 deletions neighsyncd/neighsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ int main(int argc, char **argv)
while (true)
{
Selectable *temps;
int tempfd;
s.select(&temps, &tempfd);
s.select(&temps);
}
}
catch (const std::exception& e)
Expand Down
9 changes: 5 additions & 4 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ class Executor : public Selectable
virtual ~Executor() { delete m_selectable; }

// Decorating Selectable
virtual void addFd(fd_set *fd) { return m_selectable->addFd(fd); }
virtual bool isMe(fd_set *fd) { return m_selectable->isMe(fd); }
virtual int readCache() { return m_selectable->readCache(); }
virtual void readMe() { return m_selectable->readMe(); }
int getFd() override { return m_selectable->getFd(); }
void readData() override { m_selectable->readData(); }
bool hasCachedData() override { return m_selectable->hasCachedData(); }
bool initializedWithData() override { return m_selectable->initializedWithData(); }
void updateAfterRead() override { m_selectable->updateAfterRead(); }

// Disable copying
Executor(const Executor&) = delete;
Expand Down
4 changes: 2 additions & 2 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ void OrchDaemon::start()
while (true)
{
Selectable *s;
int fd, ret;
int ret;

ret = m_select->select(&s, &fd, SELECT_TIMEOUT);
ret = m_select->select(&s, SELECT_TIMEOUT);

if (ret == Select::ERROR)
{
Expand Down
4 changes: 2 additions & 2 deletions portsyncd/portsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ int main(int argc, char **argv)
while (true)
{
Selectable *temps;
int tempfd, ret;
ret = s.select(&temps, &tempfd, 1);
int ret;
ret = s.select(&temps, 1);

if (ret == Select::ERROR)
{
Expand Down
16 changes: 3 additions & 13 deletions teamsyncd/teamsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,12 @@ int TeamSync::TeamPortSync::teamdHandler(struct team_handle *team, void *arg,
return ((TeamSync::TeamPortSync *)arg)->onChange();
}

void TeamSync::TeamPortSync::addFd(fd_set *fd)
int TeamSync::TeamPortSync::getFd()
{
FD_SET(team_get_event_fd(m_team), fd);
return team_get_event_fd(m_team);
}

bool TeamSync::TeamPortSync::isMe(fd_set *fd)
{
return FD_ISSET(team_get_event_fd(m_team), fd);
}

int TeamSync::TeamPortSync::readCache()
{
return NODATA;
}

void TeamSync::TeamPortSync::readMe()
void TeamSync::TeamPortSync::readData()
{
team_handle_events(m_team);
}
6 changes: 2 additions & 4 deletions teamsyncd/teamsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ class TeamSync : public NetMsg
ProducerStateTable *lagMemberTable);
~TeamPortSync();

virtual void addFd(fd_set *fd);
virtual bool isMe(fd_set *fd);
virtual int readCache();
virtual void readMe();
int getFd() override;
void readData() override;

protected:
int onChange();
Expand Down
3 changes: 1 addition & 2 deletions teamsyncd/teamsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ int main(int argc, char **argv)
while (true)
{
Selectable *temps;
int tempfd;
s.select(&temps, &tempfd);
s.select(&temps);
}
}
catch (const std::exception& e)
Expand Down