Added `_priv_module' pointer (type glibtop_backend_module). Made the
2000-01-12 Martin Baulig <martin@home-of-linux.org> * include/glibtop/backend.h (glibtop_backend): Added `_priv_module' pointer (type glibtop_backend_module). Made the `info' field const since this now points to gmodule loaded memory (glibtop_backend_entry): Made the `info' field const since it points to gmodule loaded memory. * lib/close.c (glibtop_close_r): Close all currently opened backends.
This commit is contained in:
committed by
Martin Baulig
parent
12e32ffc24
commit
31067e703d
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
2000-01-12 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
|
* include/glibtop/backend.h (glibtop_backend): Added `_priv_module'
|
||||||
|
pointer (type glibtop_backend_module). Made the `info' field const
|
||||||
|
since this now points to gmodule loaded memory
|
||||||
|
(glibtop_backend_entry): Made the `info' field const since it points
|
||||||
|
to gmodule loaded memory.
|
||||||
|
|
||||||
|
* lib/close.c (glibtop_close_r): Close all currently opened backends.
|
||||||
|
|
||||||
2000-01-12 Martin Baulig <martin@home-of-linux.org>
|
2000-01-12 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
* include/glibtop/backend.h (glibtop_backend_entry): New type.
|
* include/glibtop/backend.h (glibtop_backend_entry): New type.
|
||||||
|
@@ -73,14 +73,21 @@ struct _glibtop_backend_entry
|
|||||||
char *libtool_name;
|
char *libtool_name;
|
||||||
char *shlib_name;
|
char *shlib_name;
|
||||||
|
|
||||||
glibtop_backend_info *info;
|
/* This is const since you must not attempt to
|
||||||
|
* write into gmodule loaded memory. */
|
||||||
|
const glibtop_backend_info *info;
|
||||||
|
|
||||||
|
/* private pointer */
|
||||||
glibtop_backend_module *_priv;
|
glibtop_backend_module *_priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _glibtop_backend
|
struct _glibtop_backend
|
||||||
{
|
{
|
||||||
glibtop_backend_info *info;
|
const glibtop_backend_info *info;
|
||||||
|
|
||||||
|
/* private pointers */
|
||||||
glibtop_backend_private *_priv;
|
glibtop_backend_private *_priv;
|
||||||
|
glibtop_backend_module *_priv_module;
|
||||||
};
|
};
|
||||||
|
|
||||||
long
|
long
|
||||||
|
28
lib/close.c
28
lib/close.c
@@ -27,9 +27,37 @@
|
|||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
#include <glibtop/close.h>
|
#include <glibtop/close.h>
|
||||||
|
|
||||||
|
#include <glibtop/backend.h>
|
||||||
|
|
||||||
/* Closes server. */
|
/* Closes server. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
close_backend (gpointer value, gpointer user_data)
|
||||||
|
{
|
||||||
|
glibtop_backend *backend = (glibtop_backend *) value;
|
||||||
|
glibtop *server = (glibtop *) user_data;
|
||||||
|
|
||||||
|
/* should not happen ... */
|
||||||
|
if (!backend || !backend->_priv_module)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (backend->info && backend->info->close)
|
||||||
|
backend->info->close (server, backend);
|
||||||
|
|
||||||
|
/* Note that two or more servers may open the same backend. */
|
||||||
|
backend->_priv_module->refcount--;
|
||||||
|
if (!backend->_priv_module->refcount) {
|
||||||
|
g_module_close (backend->_priv_module->module);
|
||||||
|
g_free (backend->_priv_module);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (backend);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_close_r (glibtop *server)
|
glibtop_close_r (glibtop *server)
|
||||||
{
|
{
|
||||||
|
g_slist_foreach (server->_priv->backend_list, close_backend, server);
|
||||||
|
g_slist_free (server->_priv->backend_list);
|
||||||
|
server->_priv->backend_list = NULL;
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,8 @@ int
|
|||||||
glibtop_open_backend_l (glibtop *server, const char *backend_name,
|
glibtop_open_backend_l (glibtop *server, const char *backend_name,
|
||||||
u_int64_t features, const char **backend_args)
|
u_int64_t features, const char **backend_args)
|
||||||
{
|
{
|
||||||
|
const glibtop_backend_info *info;
|
||||||
glibtop_backend_entry *entry;
|
glibtop_backend_entry *entry;
|
||||||
glibtop_backend_info *info;
|
|
||||||
glibtop_backend *backend;
|
glibtop_backend *backend;
|
||||||
|
|
||||||
entry = glibtop_backend_by_name (backend_name);
|
entry = glibtop_backend_by_name (backend_name);
|
||||||
@@ -67,14 +67,15 @@ glibtop_open_backend_l (glibtop *server, const char *backend_name,
|
|||||||
|
|
||||||
return -GLIBTOP_ERROR_NO_SUCH_BACKEND;
|
return -GLIBTOP_ERROR_NO_SUCH_BACKEND;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
entry->_priv->refcount++;
|
entry->_priv->refcount++;
|
||||||
}
|
|
||||||
|
|
||||||
info = entry->info;
|
info = entry->info;
|
||||||
if (!info) return -GLIBTOP_ERROR_NO_SUCH_BACKEND;
|
if (!info) return -GLIBTOP_ERROR_NO_SUCH_BACKEND;
|
||||||
|
|
||||||
backend = glibtop_calloc_r (server, 1, sizeof (glibtop_backend));
|
backend = glibtop_calloc_r (server, 1, sizeof (glibtop_backend));
|
||||||
|
backend->_priv_module = entry->_priv;
|
||||||
backend->info = info;
|
backend->info = info;
|
||||||
|
|
||||||
if (info->open) {
|
if (info->open) {
|
||||||
|
Reference in New Issue
Block a user