#include "exec_req.h"
#include "object.h"
#include <ul_log.h>
+#include <stdio.h>
+#include <pthread.h>
extern UL_LOG_CUST(ulogd_forb_executor);
-int forb_executor_key = -1;
+static pthread_key_t forb_executor_key = -1;
+
+int forb_executor_prepare()
+{
+ return pthread_key_create(&forb_executor_key, NULL);
+}
/**
* Initializes executor.
if (ret) return ret;
forb_exec_req_nolock_init_head(executor);
+
+ forb_syncobj_init(&executor->reply_processed, 0);
return 0;
}
int forb_executor_run(forb_executor_t *executor)
{
int ret;
-
- // initializing thread specific data (FIXME: maybe should be somewhere else)
- if (forb_executor_key == -1) {
- if (ret = fosa_key_create(forb_executor_key))
- goto ret;
- }
+
// setting pointer to executor as thread specific data
- if (ret = fosa_thread_set_specific_data(forb_executor_key,
- fosa_thread_self(), (void *) executor))
+ if ((ret = pthread_setspecific(forb_executor_key, executor)))
goto ret;
fosa_mutex_lock(&executor->mutex);
/**
* Determines the executor we are currently in.
*
- * @param executor Current executor.
+ * @param executor Current executor pointer.
*
* @return Zero in case of success.
*/
-int forb_get_current_executor(forb_executor_t *executor)
+int forb_get_current_executor(forb_executor_t **executor)
{
- int ret;
- ret = fosa_thread_get_specific_data(forb_executor_key,
- fosa_thread_self(), &executor);
+ int ret = 0;
+ *executor = (void *) pthread_getspecific(forb_executor_key);
+
+ if (!(*executor))
+ ret = 1;
return ret;
}