Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
fix uninitialized field (valgrind)
[src/app-framework-binder.git]
/
src
/
afb-apis.c
diff --git
a/src/afb-apis.c
b/src/afb-apis.c
index
735649c
..
9b2df3f
100644
(file)
--- a/
src/afb-apis.c
+++ b/
src/afb-apis.c
@@
-41,8
+41,12
@@
#include "afb-plugin.h"
#include "afb-req-itf.h"
#include "afb-plugin.h"
#include "afb-req-itf.h"
+#include "afb-poll-itf.h"
+
#include "session.h"
#include "afb-apis.h"
#include "session.h"
#include "afb-apis.h"
+#include "verbose.h"
+#include "utils-upoll.h"
struct api_desc {
struct AFB_plugin *plugin; /* descriptor */
struct api_desc {
struct AFB_plugin *plugin; /* descriptor */
@@
-58,6
+62,14
@@
static int apis_count = 0;
static const char plugin_register_function[] = "pluginRegister";
static const char plugin_register_function[] = "pluginRegister";
+static const struct afb_poll_itf upoll_itf = {
+ .on_readable = (void*)upoll_on_readable,
+ .on_writable = (void*)upoll_on_writable,
+ .on_hangup = (void*)upoll_on_hangup,
+ .close = (void*)upoll_close
+};
+
+
int afb_apis_count()
{
return apis_count;
int afb_apis_count()
{
return apis_count;
@@
-75,6
+87,15
@@
void afb_apis_free_context(int apiidx, void *context)
free(context);
}
free(context);
}
+static struct afb_poll itf_poll_open(int fd, void *closure)
+{
+ struct afb_poll result;
+ result.data = upoll_open(fd, closure);
+ result.itf = result.data ? &upoll_itf : NULL;
+ return result;
+}
+
+
int afb_apis_add_plugin(const char *path)
{
struct api_desc *apis;
int afb_apis_add_plugin(const char *path)
{
struct api_desc *apis;
@@
-97,7
+118,7
@@
int afb_apis_add_plugin(const char *path)
fprintf(stderr, "[%s] not an AFB plugin, continuing...\n", path);
goto error2;
}
fprintf(stderr, "[%s] not an AFB plugin, continuing...\n", path);
goto error2;
}
- if (verbos
e
)
+ if (verbos
ity
)
fprintf(stderr, "[%s] is a valid AFB plugin\n", path);
/* allocates enough memory */
fprintf(stderr, "[%s] is a valid AFB plugin\n", path);
/* allocates enough memory */
@@
-114,8
+135,9
@@
int afb_apis_add_plugin(const char *path)
fprintf(stderr, "ERROR: plugin [%s] memory missing. continuing...\n", path);
goto error2;
}
fprintf(stderr, "ERROR: plugin [%s] memory missing. continuing...\n", path);
goto error2;
}
- interface->verbos
e
= 0;
+ interface->verbos
ity
= 0;
interface->mode = AFB_MODE_LOCAL;
interface->mode = AFB_MODE_LOCAL;
+ interface->poll_open = itf_poll_open;
/* init the plugin */
plugin = pluginRegisterFct(interface);
/* init the plugin */
plugin = pluginRegisterFct(interface);
@@
-151,7
+173,7
@@
int afb_apis_add_plugin(const char *path)
}
/* record the plugin */
}
/* record the plugin */
- if (verbos
e
)
+ if (verbos
ity
)
fprintf(stderr, "Loading plugin[%lu] prefix=[%s] info=%s\n", (unsigned long)apis_count, plugin->prefix, plugin->info);
apis = &apis_array[apis_count];
apis->plugin = plugin;
fprintf(stderr, "Loading plugin[%lu] prefix=[%s] info=%s\n", (unsigned long)apis_count, plugin->prefix, plugin->info);
apis = &apis_array[apis_count];
apis->plugin = plugin;
@@
-184,7
+206,7
@@
static int adddirs(char path[PATH_MAX], size_t end)
fprintf(stderr, "ERROR in scanning plugin directory %s, %m\n", path);
return -1;
}
fprintf(stderr, "ERROR in scanning plugin directory %s, %m\n", path);
return -1;
}
- if (verbos
e
)
+ if (verbos
ity
)
fprintf(stderr, "Scanning dir=[%s] for plugins\n", path);
/* scan each entry */
fprintf(stderr, "Scanning dir=[%s] for plugins\n", path);
/* scan each entry */
@@
-289,6
+311,7
@@
static void trapping_handle(struct afb_req req, void(*cb)(struct afb_req))
timerset = 1; /* TODO: check statuses */
sevp.sigev_notify = SIGEV_THREAD_ID;
sevp.sigev_signo = SIGALRM;
timerset = 1; /* TODO: check statuses */
sevp.sigev_notify = SIGEV_THREAD_ID;
sevp.sigev_signo = SIGALRM;
+ sevp.sigev_value.sival_ptr = NULL;
#if defined(sigev_notify_thread_id)
sevp.sigev_notify_thread_id = (pid_t)syscall(SYS_gettid);
#else
#if defined(sigev_notify_thread_id)
sevp.sigev_notify_thread_id = (pid_t)syscall(SYS_gettid);
#else
@@
-347,9
+370,8
@@
int afb_apis_handle(struct afb_req req, struct AFB_clientCtx *context, const cha
v = a->plugin->apis;
for (j = 0 ; v->name ; j++, v++) {
if (!strncasecmp(v->name, verb, lenverb) && !v->name[lenverb]) {
v = a->plugin->apis;
for (j = 0 ; v->name ; j++, v++) {
if (!strncasecmp(v->name, verb, lenverb) && !v->name[lenverb]) {
- req.context = context->contexts[i];
+ req.context =
&
context->contexts[i];
handle(req, v);
handle(req, v);
- context->contexts[i] = req.context;
return 1;
}
}
return 1;
}
}