summaryrefslogtreecommitdiffstats
path: root/libtransport
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport')
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.cc21
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.h1
-rw-r--r--libtransport/src/utils/epoll_event_reactor.cc7
3 files changed, 22 insertions, 7 deletions
diff --git a/libtransport/src/core/vpp_forwarder_interface.cc b/libtransport/src/core/vpp_forwarder_interface.cc
index 28a2560b3..9f7beeb37 100644
--- a/libtransport/src/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/core/vpp_forwarder_interface.cc
@@ -36,8 +36,6 @@ namespace transport {
namespace core {
-std::mutex VPPForwarderInterface::global_lock_;
-
VPPForwarderInterface::VPPForwarderInterface(MemifConnector &connector)
: ForwarderInterface<VPPForwarderInterface, MemifConnector>(connector),
sw_if_index_(~0),
@@ -112,9 +110,24 @@ void VPPForwarderInterface::producerConnection() {
}
void VPPForwarderInterface::connect(bool is_consumer) {
- std::lock_guard<std::mutex> connection_lock(global_lock_);
+ int retry = 20;
+
+ TRANSPORT_LOGI("Connecting to VPP through vapi.");
+ vapi_error_e ret = vapi_connect_safe(&sock_, 0);
+
+ while (ret != VAPI_OK && retry > 0) {
+ TRANSPORT_LOGE("Error connecting to VPP through vapi. Retrying..");
+ --retry;
+ ret = vapi_connect_safe(&sock_, 0);
+ }
+
+ if (ret != VAPI_OK) {
+ throw std::runtime_error(
+ "Impossible to connect to forwarder. Is VPP running?");
+ }
+
- vapi_connect_safe(&sock_, 0);
+ TRANSPORT_LOGI("Connected to VPP through vapi.");
sw_if_index_ = getMemifConfiguration();
diff --git a/libtransport/src/core/vpp_forwarder_interface.h b/libtransport/src/core/vpp_forwarder_interface.h
index bc83f476e..31d23b40d 100644
--- a/libtransport/src/core/vpp_forwarder_interface.h
+++ b/libtransport/src/core/vpp_forwarder_interface.h
@@ -79,7 +79,6 @@ class VPPForwarderInterface
uint32_t face_id2_;
bool is_consumer_;
vapi_ctx_t sock_;
- static std::mutex global_lock_;
};
} // namespace core
diff --git a/libtransport/src/utils/epoll_event_reactor.cc b/libtransport/src/utils/epoll_event_reactor.cc
index 0e6590d0e..63c08df95 100644
--- a/libtransport/src/utils/epoll_event_reactor.cc
+++ b/libtransport/src/utils/epoll_event_reactor.cc
@@ -104,12 +104,15 @@ void EpollEventReactor::runEventLoop(int timeout) {
while (run_event_loop_) {
memset(&evt, 0, sizeof(evt));
-
en = epoll_pwait(epoll_fd_, evt, 128, timeout, &sigset);
if (TRANSPORT_EXPECT_FALSE(en < 0)) {
TRANSPORT_LOGE("epoll_pwait: %s", strerror(errno));
- return;
+ if (errno == EINTR) {
+ continue;
+ } else {
+ return;
+ }
}
for (int i = 0; i < en; i++) {