Kaynağa Gözat

Handle the case of only one node

Ian Goldberg 1 yıl önce
ebeveyn
işleme
f5a4e83af8
1 değiştirilmiş dosya ile 16 ekleme ve 1 silme
  1. 16 1
      Enclave/comms.cpp

+ 16 - 1
Enclave/comms.cpp

@@ -32,13 +32,28 @@ public:
         pthread_mutex_init(&mutex, NULL);
         completed_handshakes = 0;
         complete_handshake_cbpointer = NULL;
+        if (tot_nodes == 1) {
+            // There's no one to handshake with, so we're already done
+            pthread_mutex_lock(&mutex);
+            void *cbpointer = complete_handshake_cbpointer;
+            complete_handshake_cbpointer = NULL;
+            pthread_mutex_unlock(&mutex);
+            ocall_comms_ready(cbpointer);
+        }
     }
 
     void reset(void *cbpointer) {
         pthread_mutex_lock(&mutex);
         completed_handshakes = 0;
         complete_handshake_cbpointer = cbpointer;
-        pthread_mutex_unlock(&mutex);
+        if (tot_nodes == 1) {
+            // There's no one to handshake with, so we're already done
+            complete_handshake_cbpointer = NULL;
+            pthread_mutex_unlock(&mutex);
+            ocall_comms_ready(cbpointer);
+        } else {
+            pthread_mutex_unlock(&mutex);
+        }
     }
 
     void inc() {