static void *
forb_execution_thread(void *arg)
{
- forb_orb orb = arg;
-
- forb_execute_object(orb);
+ forb_executor_t *executor = arg;
+ forb_executor_run(executor);
return NULL;
}
memset(&forb->attr, 0, sizeof(forb->attr));
}
+ sem_init(&forb->server_ready, 0, 0);
+
if (forb_server_id_empty(&forb->attr.fixed_server_id)) {
forb_server_id_init(&forb->server_id);
} else {
* can accept remote request to our new ORB. */
forb_objects_nolock_insert(forb, orb);
+ ret = forb_executor_init(&forb->default_executor);
+ if (ret) goto err2;
+ ret = forb_executor_register_object(&forb->default_executor, orb);
+ if (ret) goto err3;
+
ret = fosa_thread_create(&forb->execution_thread, NULL,
- forb_execution_thread, orb);
+ forb_execution_thread, &forb->default_executor);
if (ret != 0)
- goto err2;
+ goto err3;
/* FIXME: I do not know how to deregister the exit handler if
* forb_destroy() is called manually. */
}
err_free_unix:
free(port);
- goto err2;
+ goto err3;
unix_ok:;
}
#endif
}
err_free_inet:
free(port);
- goto err2;
+ goto err3;
inet_ok:;
hack_register_fcb(orb, port);
}
#endif
return orb;
+err3: forb_executor_destroy(&forb->default_executor);
err2: forb_free(forb);
err: return NULL;
}
return 0;
}
+
+/**
+ * Wait for the server to be ready. Internal function intended forb
+ * forbrun.
+ *
+ * @param orb ORB.
+ *
+ * @return Zero on success; on error -1 is returned, and errno is set
+ * to indicate the error.
+ */
+int forb_wait_for_server_ready(forb_orb orb)
+{
+ forb_t *forb = forb_object_to_forb(orb);
+ return sem_wait(&forb->server_ready);
+}
+
+/**
+ * Signal the the FORB core that the server is ready for accepting
+ * requests.
+ *
+ * This function should be called at the initialization of server
+ * implementation at the time when all objects are registered with
+ * executors. All other servers in the same address space are
+ * initialized after this function is called which allows the other
+ * servers to use the services provided by the calling server.
+ *
+ * @param orb ORB object.
+ *
+ * @return Zero on success; on error -1 is returned, and errno is set
+ * to indicate the error.
+ */
+int forb_signal_server_ready(forb_orb orb)
+{
+ forb_t *forb = forb_object_to_forb(orb);
+ return sem_post(&forb->server_ready);
+}