Send Linux-ha-cvs mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."
Today's Topics:
1. Linux-HA CVS: mgmt by zhenh from
([email protected])
2. Linux-HA CVS: mgmt by zhenh from
([email protected])
3. Linux-HA CVS: mgmt by zhenh from
([email protected])
4. Linux-HA CVS: mgmt by zhenh from
([email protected])
5. Linux-HA CVS: mgmt by zhenh from
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Tue, 6 Dec 2005 08:56:32 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : mgmt
Dir : linux-ha/mgmt/daemon
Removed Files:
mgmtd_gen.c
Log Message:
removed after restruct
------------------------------
Message: 2
Date: Tue, 6 Dec 2005 09:03:45 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : mgmt
Dir : linux-ha/mgmt/daemon
Removed Files:
mgmtd_lrm.c mgmtd_hb.c
Log Message:
renameing
------------------------------
Message: 3
Date: Tue, 6 Dec 2005 09:06:14 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : mgmt
Dir : linux-ha/mgmt/daemon
Added Files:
mgmt_internal.h
Log Message:
the internal head file of management library
------------------------------
Message: 4
Date: Tue, 6 Dec 2005 09:07:10 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : mgmt
Dir : linux-ha/mgmt/daemon
Added Files:
mgmt_lib.c
Log Message:
the management library
------------------------------
Message: 5
Date: Tue, 6 Dec 2005 09:09:39 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : mgmt
Dir : linux-ha/mgmt/daemon
Modified Files:
mgmtd.c
Log Message:
split the managemnt functions to mgmt_lib.c
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/mgmt/daemon/mgmtd.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- mgmtd.c 14 Oct 2005 19:34:29 -0000 1.5
+++ mgmtd.c 6 Dec 2005 16:09:39 -0000 1.6
@@ -1,6 +1,5 @@
-
/*
- * Linux HA Management Daemon
+ * Linux HA management daemon
*
* Author: Huang Zhen <[EMAIL PROTECTED]>
* Copyright (c) 2005 International Business Machines
@@ -20,6 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <portability.h>
+
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
@@ -27,6 +28,7 @@
#include <security/pam_appl.h>
#include <glib.h>
+
#include <heartbeat.h>
#include <clplumbing/GSource.h>
#include <clplumbing/cl_log.h>
@@ -36,9 +38,10 @@
#include <clplumbing/coredumps.h>
#include <clplumbing/cl_pidfile.h>
-#include <mgmt/tls.h>
#include <mgmt/mgmt.h>
-#include "mgmtd.h"
+#include <mgmt/mgmt_tls.h>
+#include <mgmt/mgmt_client.h>
+#include "mgmt_internal.h"
/* common daemon and debug functions */
@@ -48,16 +51,8 @@
static int init_start(void);
static int init_stop(const char *pid_file);
static int init_status(const char *pid_file, const char *client_name);
-
-/* the initial func for modules */
-extern int init_general(void);
-extern void final_general(void);
-extern int init_crm(void);
-extern void final_crm(void);
-extern int init_heartbeat(void);
-extern void final_heartbeat(void);
-extern int init_lrm(void);
-extern void final_lrm(void);
+static void shutdown_mgmtd(void);
+static int on_event(const char* event);
/* management daemon internal data structure */
typedef struct
@@ -92,7 +87,6 @@
static GMainLoop* mainloop = NULL;
extern int debug_level;
static GHashTable* clients = NULL;
-static GHashTable* msg_map = NULL;
static GHashTable* evt_map = NULL;
int
@@ -324,17 +318,14 @@
/* create the internal data structures */
clients = g_hash_table_new(g_int_hash, g_int_equal);
- msg_map = g_hash_table_new_full(g_str_hash, g_str_equal, cl_free, NULL);
evt_map = g_hash_table_new_full(g_str_hash, g_str_equal, cl_free, NULL);
/* create the mainloop */
mainloop = g_main_new(FALSE);
- /* init modules */
- init_general();
- init_heartbeat();
- init_lrm();
- init_crm();
+ /* init library */
+ init_mgmtd_lib();
+
/* init ham & gnutls lib */
tls_init_server();
mgmt_set_mem_funcs(cl_malloc, cl_realloc, cl_free);
@@ -372,10 +363,7 @@
g_main_run(mainloop);
/* exit, clean the pid file */
- final_crm();
- final_lrm();
- final_heartbeat();
- final_general();
+ final_mgmtd_lib();
if (cl_unlock_pidfile(PID_FILE) == 0) {
mgmtd_log(LOG_DEBUG, "[%s] stopped", mgmtd_name);
}
@@ -493,9 +481,6 @@
lookup_client(int id)
{
client_t* client = (client_t*)g_hash_table_lookup(clients, &id);
- if (client == NULL) {
- mgmtd_log(LOG_ERR, "no client id: %d", id);
- }
return client;
}
int
@@ -570,17 +555,7 @@
return PAM_SUCCESS;
}
int
-reg_msg(const char* type, msg_handler fun)
-{
- if (g_hash_table_lookup(msg_map, type) != NULL) {
- return -1;
- }
- g_hash_table_insert(msg_map, cl_strdup(type),(gpointer)fun);
- return 0;
-}
-
-int
-fire_evt(const char* event)
+on_event(const char* event)
{
GList* id_list;
GList* node;
@@ -600,6 +575,7 @@
client_t* client;
int id = (int)node->data;
+
client = lookup_client(id);
if (client == NULL) {
/* remove the client id */
@@ -621,34 +597,29 @@
mgmt_del_args(args);
return 0;
}
-
+
char*
dispatch_msg(const char* msg, int client_id)
{
- msg_handler handler;
char* ret;
int num;
char** args = mgmt_msg_args(msg, &num);
if (args == NULL) {
return NULL;
}
- handler = (msg_handler)g_hash_table_lookup(msg_map, args[0]);
- if ( handler == NULL) {
- mgmt_del_args(args);
- return NULL;
+ if (strncmp(args[0], MSG_REGEVT, strlen(MSG_REGEVT)) == 0) {
+ GList* id_list = g_hash_table_lookup(evt_map, args[1]);
+ id_list = g_list_append(id_list, (gpointer)client_id);
+ g_hash_table_replace(evt_map, cl_strdup(args[1]),
(gpointer)id_list);
+ reg_event(args[1], on_event);
+ ret = cl_strdup(MSG_OK);
+ }
+ else {
+ ret = process_msg(msg);
}
- ret = (*handler)(args, num, client_id);
mgmt_del_args(args);
return ret;
}
-int
-reg_evt(const char* type, int client_id)
-{
- GList* id_list = g_hash_table_lookup(evt_map, type);
- id_list = g_list_append(id_list, (gpointer)client_id);
- g_hash_table_replace(evt_map, cl_strdup(type), (gpointer)id_list);
- return 0;
-}
void
shutdown_mgmtd(void)
{
------------------------------
_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
End of Linux-ha-cvs Digest, Vol 25, Issue 10
********************************************