]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - src/forb.c
forb: Split forb_port_destroy() to stop and destroy phases
[frescor/forb.git] / src / forb.c
index 376651f44c269482d91d28848ae54e1223cf2bbf..309c6602e8f8b5a84b469be748058385e5b76e5e 100644 (file)
@@ -302,13 +302,13 @@ void forb_destroy(forb_orb orb)
        forb_regref_t *regref;
        forb_object obj;
 
-       /* Destroy ports to prevent remote requests from coming */
-       ul_list_for_each_cut(forb_port, forb, port) {
-               forb_destroy_port(port);
+       /* Stop ports to prevent remote requests from coming */
+       ul_list_for_each(forb_port, forb, port) {
+               forb_stop_port(port);
        }
 
-       /* Wait for executors to finish all requests (and thus close
-        * connections to peers). This is very inefficient for big
+       /* Wait for executors to finish all requests (and thus drop
+        * all references to peers). This is very inefficient for big
         * number of objects, but we do not care */
        gavl_cust_for_each(forb_objects_nolock, forb, obj) {
                forb_executor_t *executor;
@@ -317,6 +317,13 @@ void forb_destroy(forb_orb orb)
                        forb_executor_synchronize(executor);
        }
 
+       /* Destroy ports - this should drop all remaining references
+        * to peers and result in closing of all remote
+        * connections. */
+       ul_list_for_each_cut(forb_port, forb, port) {
+               forb_destroy_port(port);
+       }
+
        pthread_cancel(forb->execution_thread.pthread_id);
        pthread_join(forb->execution_thread.pthread_id, NULL);