summaryrefslogtreecommitdiffstats
path: root/server/infopipe
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-02-25 09:15:06 -0500
committerSimo Sorce <ssorce@redhat.com>2009-02-25 10:59:53 -0500
commite3b806485bf3d7b9d05591d9974a399ad92be2d3 (patch)
tree1f9c3a247c219fbea47a43ecd678d086d1779f2d /server/infopipe
parent857a38bb601f45116b4f9f963024a3eb9343329e (diff)
downloadsssd-e3b806485bf3d7b9d05591d9974a399ad92be2d3.tar.gz
sssd-e3b806485bf3d7b9d05591d9974a399ad92be2d3.tar.xz
sssd-e3b806485bf3d7b9d05591d9974a399ad92be2d3.zip
Store the InfoPipe introspection XML for subsequent requests.
Right now, the introspection XML file is read in every time a client service requests it. Since the XML cannot change during process lifetime, we'll store it on the infp_ctx object so we don't need to hit the filesystem for requests after the first.
Diffstat (limited to 'server/infopipe')
-rw-r--r--server/infopipe/infopipe.c23
-rw-r--r--server/infopipe/infopipe_private.h8
2 files changed, 18 insertions, 13 deletions
diff --git a/server/infopipe/infopipe.c b/server/infopipe/infopipe.c
index e6df36d78..02e431296 100644
--- a/server/infopipe/infopipe.c
+++ b/server/infopipe/infopipe.c
@@ -32,12 +32,7 @@
#include "infopipe/infopipe.h"
#include "infopipe/infopipe_private.h"
-struct infp_ctx {
- struct event_context *ev;
- struct confdb_ctx *cdb;
- struct service_sbus_ctx *ss_ctx;
- struct sysbus_ctx *sysbus;
-};
+struct infp_ctx;
static int service_identity(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
@@ -157,7 +152,8 @@ int infp_introspect(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
DBusMessage *reply;
FILE *xml_stream;
- char *introspect_xml = NULL;
+ struct infp_ctx *infp;
+ char *introspect_xml;
char *chunk;
TALLOC_CTX *tmp_ctx;
unsigned long xml_size;
@@ -170,8 +166,8 @@ int infp_introspect(DBusMessage *message, struct sbus_conn_ctx *sconn)
return ENOMEM;
}
- /* currently always null, to be retrieved form a private pointer later */
- if (introspect_xml == NULL) {
+ infp = talloc_get_type(sbus_conn_get_private_data(sconn), struct infp_ctx);
+ if (infp->introspect_xml == NULL) {
/* Read in the Introspection XML the first time */
xml_stream = fopen(SSSD_INTROSPECT_PATH"/"INFP_INTROSPECT_XML, "r");
if(xml_stream == NULL) {
@@ -189,7 +185,7 @@ int infp_introspect(DBusMessage *message, struct sbus_conn_ctx *sconn)
introspect_xml = NULL;
do {
chunk_size = fread(chunk, 1, INTROSPECT_CHUNK_SIZE, xml_stream);
- introspect_xml = talloc_realloc_size(tmp_ctx, introspect_xml, xml_size+chunk_size+1);
+ introspect_xml = talloc_realloc_size(infp, introspect_xml, xml_size+chunk_size+1);
if (introspect_xml == NULL) {
ret = ENOMEM;
goto done;
@@ -200,7 +196,8 @@ int infp_introspect(DBusMessage *message, struct sbus_conn_ctx *sconn)
introspect_xml[xml_size] = '\0';
talloc_free(chunk);
- /* TODO: Store the instrospection XML for future calls */
+ /* Copy the introspection XML to the infp_ctx */
+ infp->introspect_xml = introspect_xml;
}
/* Return the Introspection XML */
@@ -210,7 +207,7 @@ int infp_introspect(DBusMessage *message, struct sbus_conn_ctx *sconn)
goto done;
}
dbret = dbus_message_append_args(reply,
- DBUS_TYPE_STRING, &introspect_xml,
+ DBUS_TYPE_STRING, &infp->introspect_xml,
DBUS_TYPE_INVALID);
if (!dbret) {
ret = ENOMEM;
@@ -221,7 +218,7 @@ int infp_introspect(DBusMessage *message, struct sbus_conn_ctx *sconn)
sbus_conn_send_reply(sconn, reply);
dbus_message_unref(reply);
- DEBUG(9, ("%s\n", introspect_xml));
+ DEBUG(9, ("%s\n", infp->introspect_xml));
ret = EOK;
done:
diff --git a/server/infopipe/infopipe_private.h b/server/infopipe/infopipe_private.h
index afac334b6..1ceb426f0 100644
--- a/server/infopipe/infopipe_private.h
+++ b/server/infopipe/infopipe_private.h
@@ -22,6 +22,14 @@
#ifndef INFOPIPE_PRIVATE_H_
#define INFOPIPE_PRIVATE_H_
+struct infp_ctx {
+ struct event_context *ev;
+ struct confdb_ctx *cdb;
+ struct service_sbus_ctx *ss_ctx;
+ struct sysbus_ctx *sysbus;
+ char *introspect_xml;
+};
+
enum object_types {
INFP_OBJ_TYPE_INVALID = 0,
INFP_OBJ_TYPE_USER,