Skip to content

Commit 19ed87b

Browse files
committed
2 parents 4f6d557 + 4383d39 commit 19ed87b

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

orchagent/notifier.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ class Notifier : public Executor {
1414
return static_cast<swss::NotificationConsumer *>(getSelectable());
1515
}
1616

17-
void execute()
17+
void execute() override
1818
{
19-
m_orch->doTask(*getNotificationConsumer());
19+
auto notificationConsumer = getNotificationConsumer();
20+
/* Check before triggering doTask because pop() can throw an exception if there is no data */
21+
if (notificationConsumer->hasData())
22+
{
23+
m_orch->doTask(*notificationConsumer);
24+
}
2025
}
21-
};
26+
27+
void drain() override
28+
{
29+
this->execute();
30+
}
31+
};

orchagent/portsorch.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8382,17 +8382,26 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
83828382
return;
83838383
}
83848384

8385-
std::string op;
8386-
std::string data;
8387-
std::vector<swss::FieldValueTuple> values;
8388-
8389-
consumer.pop(op, data, values);
8390-
83918385
if (&consumer != m_portStatusNotificationConsumer && &consumer != m_portHostTxReadyNotificationConsumer)
83928386
{
83938387
return;
83948388
}
83958389

8390+
std::deque<KeyOpFieldsValuesTuple> entries;
8391+
consumer.pops(entries);
8392+
8393+
for (auto& entry : entries)
8394+
{
8395+
handleNotification(consumer, entry);
8396+
}
8397+
}
8398+
8399+
void PortsOrch::handleNotification(NotificationConsumer &consumer, KeyOpFieldsValuesTuple& entry)
8400+
{
8401+
auto op = kfvOp(entry);
8402+
auto data = kfvKey(entry);
8403+
auto values = kfvFieldsValues(entry);
8404+
83968405
if (&consumer == m_portStatusNotificationConsumer && op == "port_state_change")
83978406
{
83988407
uint32_t count;
@@ -8437,7 +8446,7 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
84378446
if (!m_portHlpr.fecToStr(fec_str, fec_mode))
84388447
{
84398448
SWSS_LOG_ERROR("Error unknown fec mode %d while querying port %s fec mode",
8440-
static_cast<std::int32_t>(fec_mode), port.m_alias.c_str());
8449+
static_cast<std::int32_t>(fec_mode), port.m_alias.c_str());
84418450
fec_str = "N/A";
84428451
}
84438452
updateDbPortOperFec(port,fec_str);
@@ -8476,7 +8485,6 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
84768485
}
84778486
setHostTxReady(p, host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_READY ? "true" : "false");
84788487
}
8479-
84808488
}
84818489

84828490
void PortsOrch::updatePortErrorStatus(Port &port, sai_port_error_status_t errstatus)

orchagent/portsorch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class PortsOrch : public Orch, public Subject
379379
void doTransceiverPresenceCheck(Consumer &consumer);
380380

381381
void doTask(NotificationConsumer &consumer);
382+
void handleNotification(NotificationConsumer &consumer, KeyOpFieldsValuesTuple& entry);
382383
void doTask(swss::SelectableTimer &timer);
383384

384385
void removePortFromLanesMap(string alias);

0 commit comments

Comments
 (0)