ACK Reviewed-By: Christine Caulfield <ccaulfie@xxxxxxxxxx> On 05/03/12 12:14, Fabio M. Di Nitto wrote:
From: "Fabio M. Di Nitto"<fdinitto@xxxxxxxxxx> this should guarantee that votequorum won't fail under high memory pressure. Price is 3500 bytes extra preallocated at startup. Signed-off-by: Fabio M. Di Nitto<fdinitto@xxxxxxxxxx> --- exec/votequorum.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/exec/votequorum.c b/exec/votequorum.c index d34107a..4d1fda8 100644 --- a/exec/votequorum.c +++ b/exec/votequorum.c @@ -1273,7 +1273,7 @@ static int votequorum_exec_send_quorum_notification(void *conn, uint64_t context int cluster_members = 0; int i = 0; int size; - char *buf; + char buf[sizeof(struct res_lib_votequorum_notification) + sizeof(struct votequorum_node) * (PROCESSOR_COUNT_MAX + 2)]; ENTER(); @@ -1286,13 +1286,8 @@ static int votequorum_exec_send_quorum_notification(void *conn, uint64_t context } size = sizeof(struct res_lib_votequorum_notification) + sizeof(struct votequorum_node) * cluster_members; - buf = alloca(size); - if (!buf) { - LEAVE(); - return -1; - } - res_lib_votequorum_notification = (struct res_lib_votequorum_notification *)buf; + res_lib_votequorum_notification = (struct res_lib_votequorum_notification *)&buf; res_lib_votequorum_notification->quorate = cluster_is_quorate; res_lib_votequorum_notification->node_list_entries = cluster_members; res_lib_votequorum_notification->context = context; @@ -1311,7 +1306,7 @@ static int votequorum_exec_send_quorum_notification(void *conn, uint64_t context /* Send it to all interested parties */ if (conn) { - int ret = corosync_api->ipc_dispatch_send(conn, buf, size); + int ret = corosync_api->ipc_dispatch_send(conn,&buf, size); LEAVE(); return ret; } else { @@ -1320,7 +1315,7 @@ static int votequorum_exec_send_quorum_notification(void *conn, uint64_t context list_iterate(tmp,&trackers_list) { qpd = list_entry(tmp, struct quorum_pd, list); res_lib_votequorum_notification->context = qpd->tracking_context; - corosync_api->ipc_dispatch_send(qpd->conn, buf, size); + corosync_api->ipc_dispatch_send(qpd->conn,&buf, size); } }
_______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss