File revision-1496.patch of Package openais (Revision d18554efb4e49d53b81eaf2da636b014)
Currently displaying revision d18554efb4e49d53b81eaf2da636b014, show latest
x
1
Index: exec/totempg.c
2
===================================================================
3
--- exec/totempg.c (revision 1493)
4
+++ exec/totempg.c (revision 1496)
5
6
#include <assert.h>
7
#include <pthread.h>
8
#include <errno.h>
9
-#include <unistd.h>
10
11
#include "../include/hdb.h"
12
#include "../include/list.h"
13
14
list_add (&assembly->list, &assembly_list_free);
15
}
16
17
-static void app_confchg_fn (
18
+static inline void app_confchg_fn (
19
enum totem_configuration_type configuration_type,
20
unsigned int *member_list, int member_list_entries,
21
unsigned int *left_list, int left_list_entries,
22
23
}
24
}
25
26
-static void group_endian_convert (
27
+static inline void group_endian_convert (
28
struct iovec *iovec)
29
{
30
unsigned short *group_len;
31
32
for (i = 1; i < group_len[0] + 1; i++) {
33
group_len[i] = swab16(group_len[i]);
34
}
35
+
36
}
37
38
-static int group_matches (
39
+static inline int group_matches (
40
struct iovec *iovec,
41
unsigned int iov_len,
42
struct totempg_group *groups_b,
43
44
*/
45
if ((size_t)iovec->iov_base % 4 != 0) {
46
iovec_aligned.iov_base = alloca(iovec->iov_len);
47
- memcpy(iovec_aligned.iov_base, iovec->iov_base, iovec->iov_len);
48
- iovec_aligned.iov_len = iovec->iov_len;
49
+ memcpy(iovec_aligned.iov_base, iovec->iov_base, iovec->iov_len); iovec_aligned.iov_len = iovec->iov_len;
50
iovec = &iovec_aligned;
51
}
52
53
54
}
55
56
57
-static void app_deliver_fn (
58
+static inline void app_deliver_fn (
59
unsigned int nodeid,
60
struct iovec *iovec,
61
unsigned int iov_len,
62
63
unsigned int res;
64
struct iovec aligned_iovec = { NULL, 0 };
65
66
+ if (endian_conversion_required) {
67
+ group_endian_convert (iovec);
68
+ }
69
+
70
/*
71
* Align data structure for sparc and ia64
72
*/
73
aligned_iovec.iov_base = alloca(iovec->iov_len);
74
aligned_iovec.iov_len = iovec->iov_len;
75
- assert (aligned_iovec.iov_base != NULL);
76
memcpy(aligned_iovec.iov_base, iovec->iov_base, iovec->iov_len);
77
iovec = &aligned_iovec;
78
- if (endian_conversion_required) {
79
- group_endian_convert (&aligned_iovec);
80
- }
81
82
for (i = 0; i <= totempg_max_handle; i++) {
83
res = hdb_handle_get (&totempg_groups_instance_database,
84
85
86
if (res == 0) {
87
assert (iov_len == 1);
88
- if (group_matches (&aligned_iovec, iov_len, instance->groups, instance->groups_cnt, &adjust_iovec)) {
89
- stripped_iovec.iov_len = aligned_iovec.iov_len - adjust_iovec;
90
-// stripped_iovec.iov_base = (char *)aligned_iovec.iov_base + adjust_iovec;
91
+ if (group_matches (iovec, iov_len, instance->groups, instance->groups_cnt, &adjust_iovec)) {
92
+ stripped_iovec.iov_len = iovec->iov_len - adjust_iovec;
93
+// stripped_iovec.iov_base = (char *)iovec->iov_base + adjust_iovec;
94
95
/*
96
* Align data structure for sparc and ia64
97
98
int endian_conversion_required)
99
{
100
struct totempg_mcast *mcast;
101
- unsigned short *msg_lens_from_msg;
102
- unsigned short msg_lens[1500];
103
- unsigned short mcast_msg_count;
104
+ unsigned short *msg_lens;
105
int i;
106
struct assembly *assembly;
107
+ char header[FRAME_SIZE_MAX];
108
+ int h_index;
109
int a_i = 0;
110
int msg_count;
111
int continuation;
112
113
assembly = assembly_ref (nodeid);
114
assert (assembly);
115
116
- mcast = (struct totempg_mcast *)iovec[0].iov_base;
117
- if (endian_conversion_required) {
118
- mcast_msg_count = swab16 (mcast->msg_count);
119
- } else {
120
- mcast_msg_count = mcast->msg_count;
121
- }
122
- msg_count = mcast_msg_count;
123
-
124
/*
125
+ * Assemble the header into one block of data and
126
* assemble the packet contents into one block of data to simplify delivery
127
*/
128
if (iov_len == 1) {
129
130
char *data;
131
int datasize;
132
133
- msg_lens_from_msg = (unsigned short *) (iovec[0].iov_base +
134
- sizeof (struct totempg_mcast));
135
- for (i = 0; i < mcast_msg_count; i++) {
136
- msg_lens[i] = swab16 (msg_lens_from_msg[i]);
137
+ mcast = (struct totempg_mcast *)iovec[0].iov_base;
138
+ if (endian_conversion_required) {
139
+ mcast->msg_count = swab16 (mcast->msg_count);
140
}
141
142
+ msg_count = mcast->msg_count;
143
datasize = sizeof (struct totempg_mcast) +
144
- mcast_msg_count * sizeof (unsigned short);
145
+ msg_count * sizeof (unsigned short);
146
147
+ memcpy (header, iovec[0].iov_base, datasize);
148
assert(iovec);
149
data = iovec[0].iov_base;
150
151
- memcpy (&assembly->data[assembly->index], &data[datasize],
152
- iovec[0].iov_len - datasize);
153
- } else {
154
- msg_lens_from_msg = (unsigned short *)iovec[1].iov_base;
155
+ msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
156
if (endian_conversion_required) {
157
- for (i = 0; i < mcast_msg_count; i++) {
158
- msg_lens[i] = swab16 (msg_lens_from_msg[i]);
159
+ for (i = 0; i < mcast->msg_count; i++) {
160
+ msg_lens[i] = swab16 (msg_lens[i]);
161
}
162
- } else {
163
- for (i = 0; i < mcast_msg_count; i++) {
164
- msg_lens[i] = msg_lens_from_msg[i];
165
- }
166
}
167
168
+ memcpy (&assembly->data[assembly->index], &data[datasize],
169
+ iovec[0].iov_len - datasize);
170
+ } else {
171
/*
172
* The message originated from local processor
173
- * because there is greater than one iovec for the full msg.
174
+ * becasue there is greater than one iovec for then full msg.
175
*/
176
+ h_index = 0;
177
+ for (i = 0; i < 2; i++) {
178
+ memcpy (&header[h_index], iovec[i].iov_base, iovec[i].iov_len);
179
+ h_index += iovec[i].iov_len;
180
+ }
181
+
182
+ mcast = (struct totempg_mcast *)header;
183
+// TODO make sure we are using a copy of mcast not the actual data itself
184
+
185
+ msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
186
+
187
for (i = 2; i < iov_len; i++) {
188
a_i = assembly->index;
189
assert (iovec[i].iov_len + a_i <= MESSAGE_SIZE_MAX);
190
191
* then adjust the assembly buffer so we can add the rest of the
192
* fragment when it arrives.
193
*/
194
- msg_count = mcast->fragmented ? mcast_msg_count - 1 : mcast_msg_count;
195
+ msg_count = mcast->fragmented ? mcast->msg_count - 1 : mcast->msg_count;
196
continuation = mcast->continuation;
197
iov_delv.iov_base = &assembly->data[0];
198
iov_delv.iov_len = assembly->index + msg_lens[0];
199
200
}
201
202
if ((assembly->index == 0) ||
203
- (!continuation && assembly->index)) {
204
-
205
+ (!continuation && assembly->index)) {
206
log_printf (totempg_log_level_error,
207
"Throwing away broken message: continuation %u, index %u\n",
208
continuation, assembly->index);
209
210
* Message is fragmented, keep around assembly list
211
*/
212
assembly->last_frag_num = mcast->fragmented;
213
- if (mcast_msg_count > 1) {
214
+ if (mcast->msg_count > 1) {
215
memmove (&assembly->data[0],
216
&assembly->data[assembly->index],
217
msg_lens[msg_count]);
218