20
20
using namespace std ;
21
21
using namespace swss ;
22
22
23
+ #define DEFAULT_SELECT_TIMEOUT 1000 /* ms */
24
+
23
25
/*
24
26
* This g_portSet contains all the front panel ports that the corresponding
25
27
* host interfaces needed to be created. When this LinkSync class is
@@ -103,16 +105,26 @@ int main(int argc, char **argv)
103
105
{
104
106
Selectable *temps;
105
107
int ret;
106
- ret = s.select (&temps, 1 );
108
+ ret = s.select (&temps, DEFAULT_SELECT_TIMEOUT );
107
109
108
110
if (ret == Select::ERROR)
109
111
{
110
112
cerr << " Error had been returned in select" << endl;
111
113
continue ;
112
114
}
115
+ else if (ret == Select::TIMEOUT)
116
+ {
117
+ continue ;
118
+ }
119
+ else if (ret != Select::OBJECT)
120
+ {
121
+ SWSS_LOG_ERROR (" Unknown return value from Select %d" , ret);
122
+ continue ;
123
+ }
113
124
114
- if (ret == Select::TIMEOUT )
125
+ if (temps == static_cast <Selectable*>(&netlink) )
115
126
{
127
+ /* on netlink message, check if PortInitDone should be sent out */
116
128
if (!g_init && g_portSet.empty ())
117
129
{
118
130
/*
@@ -134,8 +146,7 @@ int main(int argc, char **argv)
134
146
handlePortConfig (p, port_cfg_map);
135
147
}
136
148
}
137
-
138
- if (temps == (Selectable *)&portCfg)
149
+ else if (temps == (Selectable *)&portCfg)
139
150
{
140
151
std::deque<KeyOpFieldsValuesTuple> entries;
141
152
portCfg.pops (entries);
@@ -153,6 +164,11 @@ int main(int argc, char **argv)
153
164
}
154
165
handlePortConfig (p, port_cfg_map);
155
166
}
167
+ else
168
+ {
169
+ SWSS_LOG_ERROR (" Unknown object returned by select" );
170
+ continue ;
171
+ }
156
172
}
157
173
}
158
174
catch (const std::exception & e)
@@ -179,7 +195,9 @@ static void notifyPortConfigDone(ProducerStateTable &p)
179
195
180
196
bool handlePortConfigFromConfigDB (ProducerStateTable &p, DBConnector &cfgDb, bool warm)
181
197
{
182
- cout << " Get port configuration from ConfigDB..." << endl;
198
+ SWSS_LOG_ENTER ();
199
+
200
+ SWSS_LOG_NOTICE (" Getting port configuration from ConfigDB..." );
183
201
184
202
Table table (&cfgDb, CFG_PORT_TABLE_NAME);
185
203
std::vector<FieldValueTuple> ovalues;
0 commit comments