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

Handle FDB meta data together with FDB data in fdborch to avoid race … #441

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions lib/inc/sairedis.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ typedef enum _sai_redis_switch_attr_t

} sai_redis_switch_attr_t;



void handle_meta_fdb_event(
_In_ uint32_t count,
_In_ sai_fdb_event_notification_data_t *fdbevent);


/*
* Those bulk APIs are provided as static functions since current SAI 0.9.4
* doesn't support bulk API. Also note that SDK don't support bulk route API
Expand Down
34 changes: 18 additions & 16 deletions lib/src/sai_redis_notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,29 @@ void handle_fdb_event(

SWSS_LOG_DEBUG("data: %s", data.c_str());

uint32_t count;
sai_fdb_event_notification_data_t *fdbevent = NULL;

sai_deserialize_fdb_event_ntf(data, count, &fdbevent);

{
std::lock_guard<std::mutex> lock(g_apimutex);

// NOTE: this meta api must be under mutex since
// it will access meta DB and notification comes
// from different thread

meta_sai_on_fdb_event(count, fdbevent);
}

if (sn.on_fdb_event != NULL)
{
uint32_t count;
sai_fdb_event_notification_data_t *fdbevent = NULL;

sai_deserialize_fdb_event_ntf(data, count, &fdbevent);
sn.on_fdb_event(count, fdbevent);
sai_deserialize_free_fdb_event_ntf(count, fdbevent);
}
}

void handle_meta_fdb_event(
Copy link
Collaborator

Choose a reason for hiding this comment

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

where this is called ?

_In_ uint32_t count,
_In_ sai_fdb_event_notification_data_t *fdbevent)
{
SWSS_LOG_ENTER();

std::lock_guard<std::mutex> lock(g_apimutex);
// NOTE: this meta api must be under mutex since
// it will access meta DB and notification comes
// from different thread

sai_deserialize_free_fdb_event_ntf(count, fdbevent);
meta_sai_on_fdb_event(count, fdbevent);
}

void handle_port_state_change(
Expand Down