face: avoid multiple onFail events
refs #1497
Change-Id: I8fda3fea5cd8a314b30eef45da104109e9748afc
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index 75600b4..9d2368b 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -1,11 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014 Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology
+ * Copyright (c) 2014, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -39,6 +40,7 @@
, m_remoteUri(remoteUri)
, m_localUri(localUri)
, m_isOnDemand(false)
+ , m_isFailed(false)
{
onReceiveInterest += bind(&increaseCounter, ref(m_counters.getNInInterests()));
onReceiveData += bind(&increaseCounter, ref(m_counters.getNInDatas()));
@@ -115,4 +117,15 @@
}
}
+void
+Face::fail(const std::string& reason)
+{
+ if (m_isFailed) {
+ return;
+ }
+
+ m_isFailed = true;
+ this->onFail(reason);
+}
+
} //namespace nfd