public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - rgmanager: Cleanups around main.c
@ 2009-06-22 13:49 Lon Hohberger
0 siblings, 0 replies; only message in thread
From: Lon Hohberger @ 2009-06-22 13:49 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=4c8e23f2d89389591fc3b357113cc253abf81291
Commit: 4c8e23f2d89389591fc3b357113cc253abf81291
Parent: 00b0a7e4088e765f81f234eb4d16be099a5eb839
Author: Lon Hohberger <lhh@redhat.com>
AuthorDate: Tue Jun 16 13:46:19 2009 -0400
Committer: Lon Hohberger <lhh@redhat.com>
CommitterDate: Mon Jun 22 09:32:03 2009 -0400
rgmanager: Cleanups around main.c
* Clean up msg_* internal APIs to make main.c
compile correctly
* Fix up VF internal APIs to make main.c compile
* Move functions from main.c to rg_event.c since
that's where they're needed
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/include/event.h | 7 ++
rgmanager/include/message.h | 8 +-
rgmanager/include/vf.h | 9 ++-
rgmanager/src/clulib/message.c | 2 +-
rgmanager/src/clulib/msg_cluster.c | 2 +-
rgmanager/src/clulib/msg_socket.c | 2 +-
rgmanager/src/clulib/vft.c | 47 +++++-------
rgmanager/src/daemons/main.c | 139 +++++++-----------------------------
rgmanager/src/daemons/rg_event.c | 19 +++++-
9 files changed, 84 insertions(+), 151 deletions(-)
diff --git a/rgmanager/include/event.h b/rgmanager/include/event.h
index bf89247..7c91a8f 100644
--- a/rgmanager/include/event.h
+++ b/rgmanager/include/event.h
@@ -125,4 +125,11 @@ int service_op_start(char *svcName, int *target_list, int target_list_len,
int service_op_stop(char *svcName, int do_disable, int event_type);
+/* Non-central event processing */
+void node_event(int local, int nodeID, int nodeStatus, int clean);
+
+int32_t master_event_callback(char *key, uint64_t viewno, void *data,
+ uint32_t datalen);
+
+
#endif
diff --git a/rgmanager/include/message.h b/rgmanager/include/message.h
index 3cfed22..fb3ec9a 100644
--- a/rgmanager/include/message.h
+++ b/rgmanager/include/message.h
@@ -99,7 +99,7 @@ typedef struct ALIGNED _msgctx {
typedef int (*msg_open_t)(int type, int nodeid, int port, msgctx_t *ctx,
int timeout);
typedef int (*msg_close_t)(msgctx_t *);
-typedef int (*msg_listen_t)(int me, void *, msgctx_t **);
+typedef int (*msg_listen_t)(int me, const void *, msgctx_t **);
typedef int (*msg_accept_t)(msgctx_t *, msgctx_t *);
typedef int (*msg_shutdown_t)(void);
typedef int (*msg_send_t)(msgctx_t *, void *, size_t);
@@ -140,7 +140,7 @@ typedef struct _msg_ops {
/* Call once for MSG_CLUSTER, once for MSG_SOCKET */
/* Private is should be a null-terminated char string for MSG_SOCKET,
and a pointer to int type for MSG_CLUSTER */
-int msg_listen(int type, void *port, int me, msgctx_t **new_ctx);
+int msg_listen(int type, const void *port, int me, msgctx_t **new_ctx);
int msg_open(int type, int nodeid, int port, msgctx_t *ctx, int timeout);
int msg_init(msgctx_t *ctx);
int msg_accept(msgctx_t *listenctx, msgctx_t *acceptctx);
@@ -160,12 +160,12 @@ int msg_shutdown(void);
/* From msg_cluster */
int cluster_msg_init(msgctx_t *ctx);
-int cluster_msg_listen(int me, void *, msgctx_t **ctx);
+int cluster_msg_listen(int me, const void *, msgctx_t **ctx);
int cluster_msg_shutdown(void);
/* From msg_socket */
int sock_msg_init(msgctx_t *ctx);
-int sock_msg_listen(int me, void *, msgctx_t **ctx);
+int sock_msg_listen(int me, const void *, msgctx_t **ctx);
int sock_msg_shutdown(void);
/* Debugging */
diff --git a/rgmanager/include/vf.h b/rgmanager/include/vf.h
index 99239ab..528930c 100644
--- a/rgmanager/include/vf.h
+++ b/rgmanager/include/vf.h
@@ -163,12 +163,13 @@ int vf_shutdown(void);
* the child has exited
*/
int vf_write(cluster_member_list_t *membership, uint32_t flags,
- char *keyid, void *data, uint32_t datalen);
-int vf_read(cluster_member_list_t *membership, char *keyid,
+ const char *keyid, const void *data, uint32_t datalen);
+int vf_read(cluster_member_list_t *membership, const char *keyid,
uint64_t *view, void **data, uint32_t *datalen);
-int vf_read_local(char *keyid, uint64_t *view, void **data, uint32_t *datalen);
+int vf_read_local(const char *keyid, uint64_t *view, void **data,
+ uint32_t *datalen);
-int vf_key_init(char *keyid, int timeout, vf_vote_cb_t vote_cb,
+int vf_key_init(const char *keyid, int timeout, vf_vote_cb_t vote_cb,
vf_commit_cb_t commit_cb);
int getuptime(struct timeval *tv);
int vf_process_msg(msgctx_t *ctx, int nodeid, generic_msg_hdr *msgp, int nbytes);
diff --git a/rgmanager/src/clulib/message.c b/rgmanager/src/clulib/message.c
index 461e080..3eb7b2f 100644
--- a/rgmanager/src/clulib/message.c
+++ b/rgmanager/src/clulib/message.c
@@ -202,7 +202,7 @@ msg_accept(msgctx_t *listenctx, msgctx_t *acceptctx)
/* XXX Special case */
int
-msg_listen(int type, void *port, int me, msgctx_t **ctx)
+msg_listen(int type, const void *port, int me, msgctx_t **ctx)
{
errno = EINVAL;
if (!me)
diff --git a/rgmanager/src/clulib/msg_cluster.c b/rgmanager/src/clulib/msg_cluster.c
index 20d2c7f..136b376 100644
--- a/rgmanager/src/clulib/msg_cluster.c
+++ b/rgmanager/src/clulib/msg_cluster.c
@@ -1055,7 +1055,7 @@ process_cman_event(cman_handle_t handle, void *private, int reason, int arg)
/* */
int
-cluster_msg_listen(int me, void *portp, msgctx_t **cluster_ctx)
+cluster_msg_listen(int me, const void *portp, msgctx_t **cluster_ctx)
{
int e;
pthread_attr_t attrs;
diff --git a/rgmanager/src/clulib/msg_socket.c b/rgmanager/src/clulib/msg_socket.c
index 77de352..130cbd7 100644
--- a/rgmanager/src/clulib/msg_socket.c
+++ b/rgmanager/src/clulib/msg_socket.c
@@ -335,7 +335,7 @@ sock_msg_accept(msgctx_t *listenctx, msgctx_t *acceptctx)
int
-sock_msg_listen(int me, void *portp, msgctx_t **listen_ctx)
+sock_msg_listen(int me, const void *portp, msgctx_t **listen_ctx)
{
int sock;
struct sockaddr_un su;
diff --git a/rgmanager/src/clulib/vft.c b/rgmanager/src/clulib/vft.c
index 1bae2a7..eefba2f 100644
--- a/rgmanager/src/clulib/vft.c
+++ b/rgmanager/src/clulib/vft.c
@@ -52,15 +52,16 @@ static int _send_simple(msgctx_t *ctx, int32_t command, int arg1, int arg2,
int log_errors);
static int vf_send_abort(msgctx_t *ctx, uint32_t trans);
static int vf_send_commit(msgctx_t *ctx, uint32_t trans);
-static key_node_t * kn_find_key(char *keyid);
+static key_node_t * kn_find_key(const char *keyid);
static key_node_t * kn_find_trans(uint32_t trans);
static int vf_handle_join_view_msg(msgctx_t *ctx, int nodeid, vf_msg_t * hdrp);
static int vf_resolve_views(key_node_t *key_node);
static int vf_unanimous(msgctx_t *ctx, int trans, int remain, int timeout);
static view_node_t * vn_new(uint32_t trans, uint32_t nodeid, int viewno,
void *data, uint32_t datalen);
-static int vf_request_current(cluster_member_list_t *membership, char *keyid,
- uint64_t *viewno, void **data, uint32_t *datalen);
+static int vf_request_current(cluster_member_list_t *membership,
+ const char *keyid, uint64_t *viewno,
+ void **data, uint32_t *datalen);
static int _vf_purge(key_node_t *key_node, uint32_t *trans);
/* Join-view buffer list functions */
@@ -85,21 +86,12 @@ static int tv_cmp(struct timeval *left, struct timeval *right);
/* Resolution */
static uint32_t vf_try_commit(key_node_t *key_node);
-int vf_init(int my_node_id, uint16_t my_port,
- vf_vote_cb_t vote_cb, vf_commit_cb_t commit_cb);
-int vf_key_init(char *keyid, int timeout, vf_vote_cb_t vote_cb,
- vf_commit_cb_t commit_cb);
-static int vf_key_init_nt(char *keyid, int timeout, vf_vote_cb_t vote_cb,
- vf_commit_cb_t commit_cb);
-int vf_write(cluster_member_list_t *memberhip, uint32_t flags,
- char *keyid, void *data, uint32_t datalen);
+static int vf_key_init_nt(const char *keyid, int timeout,
+ vf_vote_cb_t vote_cb, vf_commit_cb_t commit_cb);
int vf_process_msg(msgctx_t *ctx, int nodeid, generic_msg_hdr *msgp, int nbytes);
-int vf_end(char *keyid);
-int vf_read(cluster_member_list_t *membership, char *keyid, uint64_t *view,
- void **data, uint32_t *datalen);
/* Reply to request for current data */
-static int vf_send_current(msgctx_t *, char *);
+static int vf_send_current(msgctx_t *, const char *);
struct vf_args {
@@ -147,7 +139,7 @@ vf_send_commit(msgctx_t *ctx, uint32_t trans)
static key_node_t *
-kn_find_key(char *keyid)
+kn_find_key(const char *keyid)
{
key_node_t *cur;
@@ -1004,7 +996,7 @@ vf_shutdown(void)
* @return 0 (always)
*/
static int
-vf_key_init_nt(char *keyid, int timeout, vf_vote_cb_t vote_cb,
+vf_key_init_nt(const char *keyid, int timeout, vf_vote_cb_t vote_cb,
vf_commit_cb_t commit_cb)
{
key_node_t *newnode = NULL;
@@ -1054,7 +1046,7 @@ vf_key_init_nt(char *keyid, int timeout, vf_vote_cb_t vote_cb,
int
-vf_key_init(char *keyid, int timeout, vf_vote_cb_t vote_cb,
+vf_key_init(const char *keyid, int timeout, vf_vote_cb_t vote_cb,
vf_commit_cb_t commit_cb)
{
int rv;
@@ -1068,8 +1060,9 @@ vf_key_init(char *keyid, int timeout, vf_vote_cb_t vote_cb,
static vf_msg_t *
-build_vf_data_message(int cmd, char *keyid, void *data, uint32_t datalen,
- int viewno, int trans, uint32_t *retlen)
+build_vf_data_message(int cmd, const char *keyid, const void *data,
+ uint32_t datalen, int viewno, int trans,
+ uint32_t *retlen)
{
uint32_t totallen;
vf_msg_t *msg;
@@ -1118,8 +1111,8 @@ build_vf_data_message(int cmd, char *keyid, void *data, uint32_t datalen,
* @see vf_end
*/
int
-vf_write(cluster_member_list_t *membership, uint32_t flags, char *keyid,
- void *data, uint32_t datalen)
+vf_write(cluster_member_list_t *membership, uint32_t flags,
+ const char *keyid, const void *data, uint32_t datalen)
{
msgctx_t everyone;
key_node_t *key_node;
@@ -1437,7 +1430,7 @@ vf_process_msg(msgctx_t *ctx, int nodeid, generic_msg_hdr *msgp, int nbytes)
* @return -1 on failure, 0 on success.
*/
int
-vf_read(cluster_member_list_t *membership, char *keyid, uint64_t *view,
+vf_read(cluster_member_list_t *membership, const char *keyid, uint64_t *view,
void **data, uint32_t *datalen)
{
key_node_t *key_node;
@@ -1521,7 +1514,7 @@ vf_read(cluster_member_list_t *membership, char *keyid, uint64_t *view,
int
-vf_read_local(char *keyid, uint64_t *view, void **data, uint32_t *datalen)
+vf_read_local(const char *keyid, uint64_t *view, void **data, uint32_t *datalen)
{
key_node_t *key_node = NULL;
@@ -1562,7 +1555,7 @@ vf_read_local(char *keyid, uint64_t *view, void **data, uint32_t *datalen)
static int
-vf_send_current(msgctx_t *ctx, char *keyid)
+vf_send_current(msgctx_t *ctx, const char *keyid)
{
key_node_t *key_node;
vf_msg_t *msg;
@@ -1605,7 +1598,7 @@ vf_send_current(msgctx_t *ctx, char *keyid)
static int
-vf_set_current(char *keyid, int view, void *data, uint32_t datalen)
+vf_set_current(const char *keyid, int view, void *data, uint32_t datalen)
{
key_node_t *key_node;
void *datatmp;
@@ -1652,7 +1645,7 @@ vf_set_current(char *keyid, int view, void *data, uint32_t datalen)
* @param datalen Size of data returned.
*/
static int
-vf_request_current(cluster_member_list_t *membership, char *keyid,
+vf_request_current(cluster_member_list_t *membership, const char *keyid,
uint64_t *viewno, void **data, uint32_t *datalen)
{
int x, n, rv = VFR_OK, port;
diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index e4800cb..c289565 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -1,4 +1,3 @@
-#include <message.h>
#include <platform.h>
#include <ccs.h>
#include <stdio.h>
@@ -7,18 +6,22 @@
#include <unistd.h>
#include <rg_locks.h>
#include <fcntl.h>
+#include <restart_counter.h>
#include <resgroup.h>
+#include <reslist.h>
#include <logging.h>
#include <members.h>
#include <msgsimple.h>
#include <vf.h>
#include <lock.h>
+#include <message.h>
#include <rg_queue.h>
#include <malloc.h>
#include <cman-private.h>
#include <event.h>
#include <members.h>
#include <daemon_init.h>
+#include <groups.h>
#define L_SHUTDOWN (1<<2)
#define L_SYS (1<<1)
@@ -27,33 +30,26 @@
#ifdef WRAP_THREADS
void dump_thread_states(FILE *);
#endif
-int configure_rgmanager(int ccsfd, int debug);
+static int configure_rgmanager(int ccsfd, int debug);
void set_transition_throttling(int);
-void node_event(int, int, int, int);
-void node_event_q(int, int, int, int);
-void daemon_cleanup(void);
-void kill_resource_groups(void);
-void flag_shutdown(int sig);
-void hard_exit(void);
-int send_rg_states(msgctx_t *, int);
-int svc_exists(char *);
-int watchdog_init(void);
-int32_t master_event_callback(char *key, uint64_t viewno, void *data, uint32_t datalen);
+static void flag_shutdown(int sig);
int node_has_fencing(int nodeid);
int fence_domain_joined(void);
+int watchdog_init(void);
+
int shutdown_pending = 0, running = 1, need_reconfigure = 0;
char debug = 0; /* XXX* */
static int signalled = 0;
static uint8_t ALIGNED port = RG_PORT;
-static char *rgmanager_lsname = "rgmanager"; /* XXX default */
+static char *rgmanager_lsname = (char *)"rgmanager"; /* XXX default */
static int status_poll_interval = DEFAULT_CHECK_INTERVAL;
int next_node_id(cluster_member_list_t *membership, int me);
-void
+static void
segfault(int __attribute__ ((unused)) sig)
{
char ow[64];
@@ -67,7 +63,7 @@ segfault(int __attribute__ ((unused)) sig)
}
-int
+static int
send_exit_msg(msgctx_t *ctx)
{
msg_send_simple(ctx, RG_EXITING, my_id(), 0);
@@ -76,7 +72,7 @@ send_exit_msg(msgctx_t *ctx)
}
-void
+static void
send_node_states(msgctx_t *ctx)
{
int x;
@@ -102,13 +98,6 @@ send_node_states(msgctx_t *ctx)
}
-void
-flag_reconfigure(int __attribute__ ((unused)) sig)
-{
- need_reconfigure++;
-}
-
-
/**
This updates our local membership view and handles whether or not we
should exit, as well as determines node transitions (thus, calling
@@ -117,7 +106,7 @@ flag_reconfigure(int __attribute__ ((unused)) sig)
@see node_event
@return 0
*/
-int
+static int
membership_update(void)
{
cluster_member_list_t *new_ml = NULL, *node_delta = NULL,
@@ -279,7 +268,7 @@ membership_update(void)
}
-int
+static int
lock_commit_cb(char __attribute__ ((unused)) *key,
uint64_t __attribute__ ((unused)) viewno,
void *data, uint32_t datalen)
@@ -314,59 +303,7 @@ lock_commit_cb(char __attribute__ ((unused)) *key,
}
-#if 0
-struct lr_arg {
- msgctx_t *ctx;
- int req;
-};
-
-
-void *
-lockreq_th(void *a)
-{
- int ret;
- char state;
- struct lr_arg *lr_arg = (struct lr_arg *)a;
- cluster_member_list_t *m = member_list();
-
- state = (lr_arg->req==RG_LOCK)?1:0;
- ret = vf_write(m, VFF_IGN_CONN_ERRORS, "rg_lockdown", &state, 1);
- free_member_list(m);
-
- if (ret == 0) {
- msg_send_simple(lr_arg->ctx, RG_SUCCESS, 0, 0);
- } else {
- msg_send_simple(lr_arg->ctx, RG_FAIL, 0, 0);
- }
-
- msg_close(lr_arg->ctx);
- msg_free_ctx(lr_arg->ctx);
- free(lr_arg);
- return NULL;
-}
-
-
-void
-do_lockreq(msgctx_t *ctx, int req)
-{
- pthread_t th;
- struct lr_arg *arg;
-
- arg = malloc(sizeof(*arg));
- if (!arg) {
- msg_send_simple(ctx, RG_FAIL, 0, 0);
- msg_close(ctx);
- msg_free_ctx(ctx);
- return 0;
- }
-
- arg->ctx = ctx;
- arg->req = req;
-
- pthread_create(&th, NULL, lockreq_th, (void *)arg);
-}
-#else
-void
+static void
do_lockreq(msgctx_t *ctx, int req)
{
int ret;
@@ -393,8 +330,6 @@ do_lockreq(msgctx_t *ctx, int req)
msg_send_simple(ctx, RG_FAIL, 0, 0);
}
}
-#endif
-
/**
@@ -406,7 +341,7 @@ do_lockreq(msgctx_t *ctx, int req)
* data received. 0 - handled message successfully.
* @see quorum_msg
*/
-int
+static int
dispatch_msg(msgctx_t *ctx, int nodeid, int need_close)
{
int ret = 0, sz = -1, nid;
@@ -595,7 +530,7 @@ out:
@param fd File descriptor to check
@return Event
*/
-int
+static int
handle_cluster_event(msgctx_t *ctx)
{
int ret;
@@ -676,8 +611,8 @@ void dump_config_version(FILE *fp);
void dump_vf_states(FILE *fp);
void dump_cluster_ctx(FILE *fp);
-void
-dump_internal_state(char *loc)
+static void
+dump_internal_state(const char *loc)
{
FILE *fp;
fp=fopen(loc, "w+");
@@ -691,7 +626,7 @@ dump_internal_state(char *loc)
fclose(fp);
}
-int
+static int
event_loop(msgctx_t *localctx, msgctx_t *clusterctx)
{
int n = 0, max, ret;
@@ -786,24 +721,14 @@ event_loop(msgctx_t *localctx, msgctx_t *clusterctx)
}
-void
+static void
flag_shutdown(int __attribute__ ((unused)) sig)
{
shutdown_pending = 1;
}
-void
-hard_exit(void)
-{
- rg_lockall(L_SYS);
- rg_doall(RG_INIT, 1, "Emergency stop of %s");
- //vf_shutdown();
- exit(1);
-}
-
-
-void
+static void
cleanup(msgctx_t *clusterctx)
{
kill_resource_groups();
@@ -812,7 +737,7 @@ cleanup(msgctx_t *clusterctx)
-void
+static void
statedump(int __attribute__ ((unused)) sig)
{
signalled++;
@@ -822,7 +747,7 @@ statedump(int __attribute__ ((unused)) sig)
/*
* Configure logging based on data in cluster.conf
*/
-int
+static int
configure_rgmanager(int ccsfd, int dbg)
{
char *v;
@@ -888,7 +813,7 @@ configure_rgmanager(int ccsfd, int dbg)
}
-int
+static int
cman_connect(cman_handle_t *ch)
{
if (!ch)
@@ -926,7 +851,7 @@ cman_connect(cman_handle_t *ch)
}
-void
+static void
wait_for_fencing(void)
{
if (node_has_fencing(my_id()) && !fence_domain_joined()) {
@@ -943,17 +868,7 @@ wait_for_fencing(void)
}
-void
-set_nonblock(int fd)
-{
- int flags;
-
- flags = fcntl(fd, F_GETFL, 0);
- fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-}
-
-
-void *
+static void *
shutdown_thread(void __attribute__ ((unused)) *arg)
{
rg_lockall(L_SYS|L_SHUTDOWN);
diff --git a/rgmanager/src/daemons/rg_event.c b/rgmanager/src/daemons/rg_event.c
index 08404c6..061749d 100644
--- a/rgmanager/src/daemons/rg_event.c
+++ b/rgmanager/src/daemons/rg_event.c
@@ -31,12 +31,12 @@ static int central_events = 0;
extern int running;
extern int shutdown_pending;
+extern int need_reconfigure;
static int _master = 0;
static struct dlm_lksb _master_lock;
static int _xid = 0;
static event_master_t *mi = NULL;
-void hard_exit(void);
void flag_shutdown(int sig);
void flag_reconfigure(int sig);
@@ -66,6 +66,23 @@ central_events_enabled(void)
}
+static void
+hard_exit(void)
+{
+ rg_lockall(L_SYS);
+ rg_doall(RG_INIT, 1, "Emergency stop of %s");
+ //vf_shutdown();
+ exit(1);
+}
+
+
+void
+flag_reconfigure(int __attribute__ ((unused)) sig)
+{
+ need_reconfigure++;
+}
+
+
/**
Called to handle the transition of a cluster member from up->down or
down->up. This handles initializing services (in the local node-up case),
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-22 13:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-22 13:49 cluster: STABLE3 - rgmanager: Cleanups around main.c Lon Hohberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).