Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 1 deletion cfgmgr/buffermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void BufferMgr::readPgProfileLookupFile(string file)
ifstream infile(file);
if (!infile.is_open())
{
m_pgfile_readable = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think m_pgfile_processed a more suitable name for this variable? I would think setting it to false by default, and flip it to true once the file processing is done will serve your purpose better?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose was to check whether the "pg-lookup-file" was there or not, if not, we don't do the buffer settings. It renamed to cover the case where the file somehow not readable.
By looking at the code, there wasn't any exist after this "is_open" check and before the entire function. This means if we had m_pgfile_processed defined, we would have always set it to true after this check. I,E, there was no difference between the current approach and if we had a new naming.
Anyway, I changed it so everybody is happy.

SWSS_LOG_WARN("PG profile lookup file: %s is not readable", file.c_str());
return;
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft May 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log an error here?
SWSS_LOG_ERROR #Closed

Copy link
Copy Markdown
Collaborator Author

@zhenggen-xu zhenggen-xu May 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessarily an error if we don't need this feature. I can put an NOTICE or WARNING log message here. #Closed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are sure the feature is optional, then a WARNING should be ok.


In reply to: 189676820 [](ancestors = 189676820)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assign m_pgfile_exist true here, and you could remove class member initialization in header file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way should do the work, any reason you prefer to put here rather than in the header file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better readability.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any confusion with the initialization in header file. it is easily readable so I kept the code here.


Expand Down Expand Up @@ -211,7 +213,7 @@ void BufferMgr::doTask(Consumer &consumer)
task_status = doCableTask(fvField(i), fvValue(i));
}
// In case of PORT table update, Buffer Manager is interested in speed update only
if (table_name == CFG_PORT_TABLE_NAME && fvField(i) == "speed")
if (m_pgfile_readable && table_name == CFG_PORT_TABLE_NAME && fvField(i) == "speed")
{
// create/update profile for port
task_status = doSpeedUpdateTask(port, fvValue(i));
Expand Down
1 change: 1 addition & 0 deletions cfgmgr/buffermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class BufferMgr : public Orch
Table m_cfgBufferProfileTable;
Table m_cfgBufferPgTable;
Table m_cfgLosslessPgPoolTable;
bool m_pgfile_readable = true;

pg_profile_lookup_t m_pgProfileLookup;
port_cable_length_t m_cableLenLookup;
Expand Down