2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2015-2017
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/network.h"
27 #include "protocol_private.h"
28 #include "protocol_api.h"
30 size_t ctdb_tdb_data_len(TDB_DATA
*in
)
32 return in
->dsize
> UINT32_MAX
? UINT32_MAX
: in
->dsize
;
35 void ctdb_tdb_data_push(TDB_DATA
*in
, uint8_t *buf
, size_t *npush
)
37 size_t len
= ctdb_tdb_data_len(in
);
40 memcpy(buf
, in
->dptr
, len
);
46 int ctdb_tdb_data_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
47 TDB_DATA
*out
, size_t *npull
)
51 if (buflen
> UINT32_MAX
) {
57 val
.dptr
= talloc_memdup(mem_ctx
, buf
, buflen
);
58 if (val
.dptr
== NULL
) {
70 size_t ctdb_tdb_datan_len(TDB_DATA
*in
)
72 uint32_t u32
= ctdb_tdb_data_len(in
);
74 return ctdb_uint32_len(&u32
) + u32
;
77 void ctdb_tdb_datan_push(TDB_DATA
*in
, uint8_t *buf
, size_t *npush
)
79 size_t offset
= 0, np
;
80 uint32_t u32
= ctdb_tdb_data_len(in
);
82 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
85 ctdb_tdb_data_push(in
, buf
+offset
, &np
);
91 int ctdb_tdb_datan_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
92 TDB_DATA
*out
, size_t *npull
)
94 size_t offset
= 0, np
;
98 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
104 if (buflen
-offset
< u32
) {
108 ret
= ctdb_tdb_data_pull(buf
+offset
, u32
, mem_ctx
, out
, &np
);
118 size_t ctdb_latency_counter_len(struct ctdb_latency_counter
*in
)
120 return ctdb_int32_len(&in
->num
) +
121 ctdb_padding_len(4) +
122 ctdb_double_len(&in
->min
) +
123 ctdb_double_len(&in
->max
) +
124 ctdb_double_len(&in
->total
);
127 void ctdb_latency_counter_push(struct ctdb_latency_counter
*in
, uint8_t *buf
,
130 size_t offset
= 0, np
;
132 ctdb_int32_push(&in
->num
, buf
+offset
, &np
);
135 ctdb_padding_push(4, buf
+offset
, &np
);
138 ctdb_double_push(&in
->min
, buf
+offset
, &np
);
141 ctdb_double_push(&in
->max
, buf
+offset
, &np
);
144 ctdb_double_push(&in
->total
, buf
+offset
, &np
);
150 int ctdb_latency_counter_pull(uint8_t *buf
, size_t buflen
,
151 struct ctdb_latency_counter
*out
, size_t *npull
)
153 size_t offset
= 0, np
;
156 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &out
->num
, &np
);
162 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
168 ret
= ctdb_double_pull(buf
+offset
, buflen
-offset
, &out
->min
, &np
);
174 ret
= ctdb_double_pull(buf
+offset
, buflen
-offset
, &out
->max
, &np
);
180 ret
= ctdb_double_pull(buf
+offset
, buflen
-offset
, &out
->total
, &np
);
190 size_t ctdb_statistics_len(struct ctdb_statistics
*in
)
192 return ctdb_uint32_len(&in
->num_clients
) +
193 ctdb_uint32_len(&in
->frozen
) +
194 ctdb_uint32_len(&in
->recovering
) +
195 ctdb_uint32_len(&in
->client_packets_sent
) +
196 ctdb_uint32_len(&in
->client_packets_recv
) +
197 ctdb_uint32_len(&in
->node_packets_sent
) +
198 ctdb_uint32_len(&in
->node_packets_recv
) +
199 ctdb_uint32_len(&in
->keepalive_packets_sent
) +
200 ctdb_uint32_len(&in
->keepalive_packets_recv
) +
201 ctdb_uint32_len(&in
->node
.req_call
) +
202 ctdb_uint32_len(&in
->node
.reply_call
) +
203 ctdb_uint32_len(&in
->node
.req_dmaster
) +
204 ctdb_uint32_len(&in
->node
.reply_dmaster
) +
205 ctdb_uint32_len(&in
->node
.reply_error
) +
206 ctdb_uint32_len(&in
->node
.req_message
) +
207 ctdb_uint32_len(&in
->node
.req_control
) +
208 ctdb_uint32_len(&in
->node
.reply_control
) +
209 ctdb_uint32_len(&in
->node
.req_tunnel
) +
210 ctdb_uint32_len(&in
->client
.req_call
) +
211 ctdb_uint32_len(&in
->client
.req_message
) +
212 ctdb_uint32_len(&in
->client
.req_control
) +
213 ctdb_uint32_len(&in
->client
.req_tunnel
) +
214 ctdb_uint32_len(&in
->timeouts
.call
) +
215 ctdb_uint32_len(&in
->timeouts
.control
) +
216 ctdb_uint32_len(&in
->timeouts
.traverse
) +
217 ctdb_padding_len(4) +
218 ctdb_latency_counter_len(&in
->reclock
.ctdbd
) +
219 ctdb_latency_counter_len(&in
->reclock
.recd
) +
220 ctdb_uint32_len(&in
->locks
.num_calls
) +
221 ctdb_uint32_len(&in
->locks
.num_current
) +
222 ctdb_uint32_len(&in
->locks
.num_pending
) +
223 ctdb_uint32_len(&in
->locks
.num_failed
) +
224 ctdb_latency_counter_len(&in
->locks
.latency
) +
225 MAX_COUNT_BUCKETS
* ctdb_uint32_len(&in
->locks
.buckets
[0]) +
226 ctdb_uint32_len(&in
->total_calls
) +
227 ctdb_uint32_len(&in
->pending_calls
) +
228 ctdb_uint32_len(&in
->childwrite_calls
) +
229 ctdb_uint32_len(&in
->pending_childwrite_calls
) +
230 ctdb_uint32_len(&in
->memory_used
) +
231 ctdb_uint32_len(&in
->__last_counter
) +
232 ctdb_uint32_len(&in
->max_hop_count
) +
234 ctdb_uint32_len(&in
->hop_count_bucket
[0]) +
235 ctdb_padding_len(4) +
236 ctdb_latency_counter_len(&in
->call_latency
) +
237 ctdb_latency_counter_len(&in
->childwrite_latency
) +
238 ctdb_uint32_len(&in
->num_recoveries
) +
239 ctdb_padding_len(4) +
240 ctdb_timeval_len(&in
->statistics_start_time
) +
241 ctdb_timeval_len(&in
->statistics_current_time
) +
242 ctdb_uint32_len(&in
->total_ro_delegations
) +
243 ctdb_uint32_len(&in
->total_ro_revokes
);
246 void ctdb_statistics_push(struct ctdb_statistics
*in
, uint8_t *buf
,
249 size_t offset
= 0, np
;
252 ctdb_uint32_push(&in
->num_clients
, buf
+offset
, &np
);
255 ctdb_uint32_push(&in
->frozen
, buf
+offset
, &np
);
258 ctdb_uint32_push(&in
->recovering
, buf
+offset
, &np
);
261 ctdb_uint32_push(&in
->client_packets_sent
, buf
+offset
, &np
);
264 ctdb_uint32_push(&in
->client_packets_recv
, buf
+offset
, &np
);
267 ctdb_uint32_push(&in
->node_packets_sent
, buf
+offset
, &np
);
270 ctdb_uint32_push(&in
->node_packets_recv
, buf
+offset
, &np
);
273 ctdb_uint32_push(&in
->keepalive_packets_sent
, buf
+offset
, &np
);
276 ctdb_uint32_push(&in
->keepalive_packets_recv
, buf
+offset
, &np
);
279 ctdb_uint32_push(&in
->node
.req_call
, buf
+offset
, &np
);
282 ctdb_uint32_push(&in
->node
.reply_call
, buf
+offset
, &np
);
285 ctdb_uint32_push(&in
->node
.req_dmaster
, buf
+offset
, &np
);
288 ctdb_uint32_push(&in
->node
.reply_dmaster
, buf
+offset
, &np
);
291 ctdb_uint32_push(&in
->node
.reply_error
, buf
+offset
, &np
);
294 ctdb_uint32_push(&in
->node
.req_message
, buf
+offset
, &np
);
297 ctdb_uint32_push(&in
->node
.req_control
, buf
+offset
, &np
);
300 ctdb_uint32_push(&in
->node
.reply_control
, buf
+offset
, &np
);
303 ctdb_uint32_push(&in
->node
.req_tunnel
, buf
+offset
, &np
);
306 ctdb_uint32_push(&in
->client
.req_call
, buf
+offset
, &np
);
309 ctdb_uint32_push(&in
->client
.req_message
, buf
+offset
, &np
);
312 ctdb_uint32_push(&in
->client
.req_control
, buf
+offset
, &np
);
315 ctdb_uint32_push(&in
->client
.req_tunnel
, buf
+offset
, &np
);
318 ctdb_uint32_push(&in
->timeouts
.call
, buf
+offset
, &np
);
321 ctdb_uint32_push(&in
->timeouts
.control
, buf
+offset
, &np
);
324 ctdb_uint32_push(&in
->timeouts
.traverse
, buf
+offset
, &np
);
327 ctdb_padding_push(4, buf
+offset
, &np
);
330 ctdb_latency_counter_push(&in
->reclock
.ctdbd
, buf
+offset
, &np
);
333 ctdb_latency_counter_push(&in
->reclock
.recd
, buf
+offset
, &np
);
336 ctdb_uint32_push(&in
->locks
.num_calls
, buf
+offset
, &np
);
339 ctdb_uint32_push(&in
->locks
.num_current
, buf
+offset
, &np
);
342 ctdb_uint32_push(&in
->locks
.num_pending
, buf
+offset
, &np
);
345 ctdb_uint32_push(&in
->locks
.num_failed
, buf
+offset
, &np
);
348 ctdb_latency_counter_push(&in
->locks
.latency
, buf
+offset
, &np
);
351 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
352 ctdb_uint32_push(&in
->locks
.buckets
[i
], buf
+offset
, &np
);
356 ctdb_uint32_push(&in
->total_calls
, buf
+offset
, &np
);
359 ctdb_uint32_push(&in
->pending_calls
, buf
+offset
, &np
);
362 ctdb_uint32_push(&in
->childwrite_calls
, buf
+offset
, &np
);
365 ctdb_uint32_push(&in
->pending_childwrite_calls
, buf
+offset
, &np
);
368 ctdb_uint32_push(&in
->memory_used
, buf
+offset
, &np
);
371 ctdb_uint32_push(&in
->__last_counter
, buf
+offset
, &np
);
374 ctdb_uint32_push(&in
->max_hop_count
, buf
+offset
, &np
);
377 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
378 ctdb_uint32_push(&in
->hop_count_bucket
[i
], buf
+offset
, &np
);
382 ctdb_padding_push(4, buf
+offset
, &np
);
385 ctdb_latency_counter_push(&in
->call_latency
, buf
+offset
, &np
);
388 ctdb_latency_counter_push(&in
->childwrite_latency
, buf
+offset
, &np
);
391 ctdb_uint32_push(&in
->num_recoveries
, buf
+offset
, &np
);
394 ctdb_padding_push(4, buf
+offset
, &np
);
397 ctdb_timeval_push(&in
->statistics_start_time
, buf
+offset
, &np
);
400 ctdb_timeval_push(&in
->statistics_current_time
, buf
+offset
, &np
);
403 ctdb_uint32_push(&in
->total_ro_delegations
, buf
+offset
, &np
);
406 ctdb_uint32_push(&in
->total_ro_revokes
, buf
+offset
, &np
);
412 static int ctdb_statistics_pull_elems(uint8_t *buf
, size_t buflen
,
414 struct ctdb_statistics
*out
,
417 size_t offset
= 0, np
;
420 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->num_clients
,
427 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->frozen
, &np
);
433 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->recovering
,
440 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
441 &out
->client_packets_sent
, &np
);
447 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
448 &out
->client_packets_recv
, &np
);
454 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
455 &out
->node_packets_sent
, &np
);
461 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
462 &out
->node_packets_recv
, &np
);
468 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
469 &out
->keepalive_packets_sent
, &np
);
475 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
476 &out
->keepalive_packets_recv
, &np
);
482 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
483 &out
->node
.req_call
, &np
);
489 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
490 &out
->node
.reply_call
, &np
);
496 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
497 &out
->node
.req_dmaster
, &np
);
503 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
504 &out
->node
.reply_dmaster
, &np
);
510 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
511 &out
->node
.reply_error
, &np
);
517 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
518 &out
->node
.req_message
, &np
);
524 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
525 &out
->node
.req_control
, &np
);
531 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
532 &out
->node
.reply_control
, &np
);
538 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
539 &out
->node
.req_tunnel
, &np
);
545 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
546 &out
->client
.req_call
, &np
);
552 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
553 &out
->client
.req_message
, &np
);
559 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
560 &out
->client
.req_control
, &np
);
566 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
567 &out
->client
.req_tunnel
, &np
);
573 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
574 &out
->timeouts
.call
, &np
);
580 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
581 &out
->timeouts
.control
, &np
);
587 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
588 &out
->timeouts
.traverse
, &np
);
594 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
600 ret
= ctdb_latency_counter_pull(buf
+offset
, buflen
-offset
,
601 &out
->reclock
.ctdbd
, &np
);
607 ret
= ctdb_latency_counter_pull(buf
+offset
, buflen
-offset
,
608 &out
->reclock
.recd
, &np
);
614 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
615 &out
->locks
.num_calls
, &np
);
621 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
622 &out
->locks
.num_current
, &np
);
628 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
629 &out
->locks
.num_pending
, &np
);
635 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
636 &out
->locks
.num_failed
, &np
);
642 ret
= ctdb_latency_counter_pull(buf
+offset
, buflen
-offset
,
643 &out
->locks
.latency
, &np
);
649 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
650 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
651 &out
->locks
.buckets
[i
], &np
);
658 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
659 &out
->total_calls
, &np
);
665 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
666 &out
->pending_calls
, &np
);
672 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
673 &out
->childwrite_calls
, &np
);
679 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
680 &out
->pending_childwrite_calls
, &np
);
686 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->memory_used
,
693 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
694 &out
->__last_counter
, &np
);
700 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
701 &out
->max_hop_count
, &np
);
707 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
708 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
709 &out
->hop_count_bucket
[i
], &np
);
716 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
722 ret
= ctdb_latency_counter_pull(buf
+offset
, buflen
-offset
,
723 &out
->call_latency
, &np
);
729 ret
= ctdb_latency_counter_pull(buf
+offset
, buflen
-offset
,
730 &out
->childwrite_latency
, &np
);
736 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
737 &out
->num_recoveries
, &np
);
743 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
749 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
,
750 &out
->statistics_start_time
, &np
);
756 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
,
757 &out
->statistics_current_time
, &np
);
763 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
764 &out
->total_ro_delegations
, &np
);
770 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
771 &out
->total_ro_revokes
, &np
);
781 int ctdb_statistics_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
782 struct ctdb_statistics
**out
, size_t *npull
)
784 struct ctdb_statistics
*val
;
788 val
= talloc(mem_ctx
, struct ctdb_statistics
);
793 ret
= ctdb_statistics_pull_elems(buf
, buflen
, val
, val
, &np
);
804 size_t ctdb_statistics_list_len(struct ctdb_statistics_list
*in
)
808 len
= ctdb_int32_len(&in
->num
) + ctdb_padding_len(4);
810 len
+= in
->num
* ctdb_statistics_len(&in
->stats
[0]);
816 void ctdb_statistics_list_push(struct ctdb_statistics_list
*in
,
817 uint8_t *buf
, size_t *npush
)
819 size_t offset
= 0, np
;
822 ctdb_int32_push(&in
->num
, buf
+offset
, &np
);
825 ctdb_padding_push(4, buf
+offset
, &np
);
828 for (i
=0; i
<in
->num
; i
++) {
829 ctdb_statistics_push(&in
->stats
[i
], buf
+offset
, &np
);
836 int ctdb_statistics_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
837 struct ctdb_statistics_list
**out
,
840 struct ctdb_statistics_list
*val
;
841 size_t offset
= 0, np
;
844 val
= talloc(mem_ctx
, struct ctdb_statistics_list
);
849 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &val
->num
, &np
);
855 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
866 val
->stats
= talloc_array(val
, struct ctdb_statistics
, val
->num
);
867 if (val
->stats
== NULL
) {
872 for (i
=0; i
<val
->num
; i
++) {
873 ret
= ctdb_statistics_pull_elems(buf
+offset
, buflen
-offset
,
874 val
, &val
->stats
[i
], &np
);
891 size_t ctdb_vnn_map_len(struct ctdb_vnn_map
*in
)
895 len
= ctdb_uint32_len(&in
->generation
) + ctdb_uint32_len(&in
->size
);
897 len
+= in
->size
* ctdb_uint32_len(&in
->map
[0]);
903 void ctdb_vnn_map_push(struct ctdb_vnn_map
*in
, uint8_t *buf
, size_t *npush
)
905 size_t offset
= 0, np
;
908 ctdb_uint32_push(&in
->generation
, buf
+offset
, &np
);
911 ctdb_uint32_push(&in
->size
, buf
+offset
, &np
);
914 for (i
=0; i
<in
->size
; i
++) {
915 ctdb_uint32_push(&in
->map
[i
], buf
+offset
, &np
);
922 int ctdb_vnn_map_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
923 struct ctdb_vnn_map
**out
, size_t *npull
)
925 struct ctdb_vnn_map
*val
;
926 size_t offset
= 0, np
;
930 val
= talloc(mem_ctx
, struct ctdb_vnn_map
);
935 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->generation
,
942 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->size
, &np
);
948 if (val
->size
== 0) {
953 val
->map
= talloc_array(val
, uint32_t, val
->size
);
954 if (val
->map
== NULL
) {
959 for (i
=0; i
<val
->size
; i
++) {
960 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
978 size_t ctdb_dbid_len(struct ctdb_dbid
*in
)
980 return ctdb_uint32_len(&in
->db_id
) +
981 ctdb_uint8_len(&in
->flags
) +
985 void ctdb_dbid_push(struct ctdb_dbid
*in
, uint8_t *buf
, size_t *npush
)
987 size_t offset
= 0, np
;
989 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
992 ctdb_uint8_push(&in
->flags
, buf
+offset
, &np
);
995 ctdb_padding_push(3, buf
+offset
, &np
);
1001 static int ctdb_dbid_pull_elems(uint8_t *buf
, size_t buflen
,
1002 TALLOC_CTX
*mem_ctx
, struct ctdb_dbid
*out
,
1005 size_t offset
= 0, np
;
1008 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->db_id
, &np
);
1014 ret
= ctdb_uint8_pull(buf
+offset
, buflen
-offset
, &out
->flags
, &np
);
1020 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 3, &np
);
1030 int ctdb_dbid_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1031 struct ctdb_dbid
**out
, size_t *npull
)
1033 struct ctdb_dbid
*val
;
1037 val
= talloc(mem_ctx
, struct ctdb_dbid
);
1042 ret
= ctdb_dbid_pull_elems(buf
, buflen
, val
, val
, &np
);
1053 size_t ctdb_dbid_map_len(struct ctdb_dbid_map
*in
)
1057 len
= ctdb_uint32_len(&in
->num
);
1059 len
+= in
->num
* ctdb_dbid_len(&in
->dbs
[0]);
1065 void ctdb_dbid_map_push(struct ctdb_dbid_map
*in
, uint8_t *buf
, size_t *npush
)
1067 size_t offset
= 0, np
;
1070 ctdb_uint32_push(&in
->num
, buf
+offset
, &np
);
1073 for (i
=0; i
<in
->num
; i
++) {
1074 ctdb_dbid_push(&in
->dbs
[i
], buf
+offset
, &np
);
1081 int ctdb_dbid_map_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1082 struct ctdb_dbid_map
**out
, size_t *npull
)
1084 struct ctdb_dbid_map
*val
;
1085 size_t offset
= 0, np
;
1089 val
= talloc(mem_ctx
, struct ctdb_dbid_map
);
1094 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num
, &np
);
1100 if (val
->num
== 0) {
1105 val
->dbs
= talloc_array(val
, struct ctdb_dbid
, val
->num
);
1106 if (val
->dbs
== NULL
) {
1111 for (i
=0; i
<val
->num
; i
++) {
1112 ret
= ctdb_dbid_pull_elems(buf
+offset
, buflen
-offset
, val
,
1130 size_t ctdb_pulldb_len(struct ctdb_pulldb
*in
)
1132 return ctdb_uint32_len(&in
->db_id
) +
1133 ctdb_uint32_len(&in
->lmaster
);
1136 void ctdb_pulldb_push(struct ctdb_pulldb
*in
, uint8_t *buf
, size_t *npush
)
1138 size_t offset
= 0, np
;
1140 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
1143 ctdb_uint32_push(&in
->lmaster
, buf
+offset
, &np
);
1149 int ctdb_pulldb_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1150 struct ctdb_pulldb
**out
, size_t *npull
)
1152 struct ctdb_pulldb
*val
;
1153 size_t offset
= 0, np
;
1156 val
= talloc(mem_ctx
, struct ctdb_pulldb
);
1161 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
1168 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->lmaster
, &np
);
1180 size_t ctdb_pulldb_ext_len(struct ctdb_pulldb_ext
*in
)
1182 return ctdb_uint32_len(&in
->db_id
) +
1183 ctdb_uint32_len(&in
->lmaster
) +
1184 ctdb_uint64_len(&in
->srvid
);
1187 void ctdb_pulldb_ext_push(struct ctdb_pulldb_ext
*in
, uint8_t *buf
,
1190 size_t offset
= 0, np
;
1192 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
1195 ctdb_uint32_push(&in
->lmaster
, buf
+offset
, &np
);
1198 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
1204 int ctdb_pulldb_ext_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1205 struct ctdb_pulldb_ext
**out
, size_t *npull
)
1207 struct ctdb_pulldb_ext
*val
;
1208 size_t offset
= 0, np
;
1211 val
= talloc(mem_ctx
, struct ctdb_pulldb_ext
);
1216 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
1222 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->lmaster
, &np
);
1228 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
1243 size_t ctdb_db_vacuum_len(struct ctdb_db_vacuum
*in
)
1245 return ctdb_uint32_len(&in
->db_id
) +
1246 ctdb_bool_len(&in
->full_vacuum_run
);
1249 void ctdb_db_vacuum_push(struct ctdb_db_vacuum
*in
,
1253 size_t offset
= 0, np
;
1255 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
1258 ctdb_bool_push(&in
->full_vacuum_run
, buf
+offset
, &np
);
1264 int ctdb_db_vacuum_pull(uint8_t *buf
,
1266 TALLOC_CTX
*mem_ctx
,
1267 struct ctdb_db_vacuum
**out
,
1270 struct ctdb_db_vacuum
*val
;
1271 size_t offset
= 0, np
;
1274 val
= talloc(mem_ctx
, struct ctdb_db_vacuum
);
1279 ret
= ctdb_uint32_pull(buf
+offset
,
1288 ret
= ctdb_bool_pull(buf
+offset
,
1290 &val
->full_vacuum_run
,
1306 size_t ctdb_echo_data_len(struct ctdb_echo_data
*in
)
1309 * No overflow check, none of the routines in this file do it
1310 * and there's no way to report it anyway.
1312 return ctdb_uint32_len(&in
->timeout
) + ctdb_tdb_datan_len(&in
->buf
);
1315 void ctdb_echo_data_push(struct ctdb_echo_data
*in
,
1319 size_t offset
= 0, np
;
1322 * No overflow check, none of the routines in this file do it
1323 * and there's no way to report it anyway.
1326 ctdb_uint32_push(&in
->timeout
, buf
+offset
, &np
);
1329 ctdb_tdb_datan_push(&in
->buf
, buf
+offset
, &np
);
1335 int ctdb_echo_data_pull(uint8_t *buf
,
1337 TALLOC_CTX
*mem_ctx
,
1338 struct ctdb_echo_data
**out
,
1341 struct ctdb_echo_data
*val
;
1342 size_t offset
= 0, np
;
1345 val
= talloc(mem_ctx
, struct ctdb_echo_data
);
1350 ret
= ctdb_uint32_pull(buf
+offset
,
1359 ret
= ctdb_tdb_datan_pull(buf
+offset
,
1378 size_t ctdb_ltdb_header_len(struct ctdb_ltdb_header
*in
)
1380 return ctdb_uint64_len(&in
->rsn
) +
1381 ctdb_uint32_len(&in
->dmaster
) +
1382 ctdb_uint32_len(&in
->reserved1
) +
1383 ctdb_uint32_len(&in
->flags
) +
1384 ctdb_padding_len(4);
1387 void ctdb_ltdb_header_push(struct ctdb_ltdb_header
*in
, uint8_t *buf
,
1390 size_t offset
= 0, np
;
1392 ctdb_uint64_push(&in
->rsn
, buf
+offset
, &np
);
1395 ctdb_uint32_push(&in
->dmaster
, buf
+offset
, &np
);
1398 ctdb_uint32_push(&in
->reserved1
, buf
+offset
, &np
);
1401 ctdb_uint32_push(&in
->flags
, buf
+offset
, &np
);
1404 ctdb_padding_push(4, buf
+offset
, &np
);
1410 int ctdb_ltdb_header_pull(uint8_t *buf
, size_t buflen
,
1411 struct ctdb_ltdb_header
*out
, size_t *npull
)
1413 size_t offset
= 0, np
;
1416 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &out
->rsn
, &np
);
1422 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->dmaster
, &np
);
1428 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->reserved1
,
1435 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->flags
, &np
);
1441 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
1451 int ctdb_ltdb_header_extract(TDB_DATA
*data
, struct ctdb_ltdb_header
*header
)
1456 ret
= ctdb_ltdb_header_pull(data
->dptr
, data
->dsize
, header
, &np
);
1467 size_t ctdb_rec_data_len(struct ctdb_rec_data
*in
)
1471 u32
= ctdb_uint32_len(&in
->reqid
) +
1472 ctdb_tdb_datan_len(&in
->key
) +
1473 ctdb_tdb_datan_len(&in
->data
);
1475 if (in
->header
!= NULL
) {
1476 u32
+= ctdb_ltdb_header_len(in
->header
);
1479 return ctdb_uint32_len(&u32
) + u32
;
1482 void ctdb_rec_data_push(struct ctdb_rec_data
*in
, uint8_t *buf
, size_t *npush
)
1484 size_t offset
= 0, np
;
1487 u32
= ctdb_rec_data_len(in
);
1488 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1491 ctdb_uint32_push(&in
->reqid
, buf
+offset
, &np
);
1494 u32
= ctdb_tdb_data_len(&in
->key
);
1495 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1498 u32
= ctdb_tdb_data_len(&in
->data
);
1499 if (in
->header
!= NULL
) {
1500 u32
+= ctdb_ltdb_header_len(in
->header
);
1503 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1506 ctdb_tdb_data_push(&in
->key
, buf
+offset
, &np
);
1509 /* If ltdb header is not NULL, then it is pushed as part of the data */
1510 if (in
->header
!= NULL
) {
1511 ctdb_ltdb_header_push(in
->header
, buf
+offset
, &np
);
1514 ctdb_tdb_data_push(&in
->data
, buf
+offset
, &np
);
1520 static int ctdb_rec_data_pull_data(uint8_t *buf
, size_t buflen
,
1522 TDB_DATA
*key
, TDB_DATA
*data
,
1525 size_t offset
= 0, np
;
1530 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
1541 ret
= ctdb_uint32_pull(buf
+offset
, len
-offset
, reqid
, &np
);
1547 ret
= ctdb_uint32_pull(buf
+offset
, len
-offset
, &u32
, &np
);
1554 ret
= ctdb_uint32_pull(buf
+offset
, len
-offset
, &u32
, &np
);
1561 if (len
-offset
< key
->dsize
) {
1565 key
->dptr
= buf
+offset
;
1566 offset
+= key
->dsize
;
1568 if (len
-offset
< data
->dsize
) {
1572 data
->dptr
= buf
+offset
;
1573 offset
+= data
->dsize
;
1579 static int ctdb_rec_data_pull_elems(uint8_t *buf
, size_t buflen
,
1580 TALLOC_CTX
*mem_ctx
,
1581 struct ctdb_rec_data
*out
,
1589 ret
= ctdb_rec_data_pull_data(buf
, buflen
, &reqid
, &key
, &data
, &np
);
1596 /* Always set header to NULL. If it is required, extract it using
1597 * ctdb_rec_data_extract_header()
1601 out
->key
.dsize
= key
.dsize
;
1602 if (key
.dsize
> 0) {
1603 out
->key
.dptr
= talloc_memdup(mem_ctx
, key
.dptr
, key
.dsize
);
1604 if (out
->key
.dptr
== NULL
) {
1609 out
->data
.dsize
= data
.dsize
;
1610 if (data
.dsize
> 0) {
1611 out
->data
.dptr
= talloc_memdup(mem_ctx
, data
.dptr
, data
.dsize
);
1612 if (out
->data
.dptr
== NULL
) {
1621 int ctdb_rec_data_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1622 struct ctdb_rec_data
**out
, size_t *npull
)
1624 struct ctdb_rec_data
*val
;
1628 val
= talloc(mem_ctx
, struct ctdb_rec_data
);
1633 ret
= ctdb_rec_data_pull_elems(buf
, buflen
, val
, val
, &np
);
1644 size_t ctdb_rec_buffer_len(struct ctdb_rec_buffer
*in
)
1646 return ctdb_uint32_len(&in
->db_id
) +
1647 ctdb_uint32_len(&in
->count
) +
1651 void ctdb_rec_buffer_push(struct ctdb_rec_buffer
*in
, uint8_t *buf
,
1654 size_t offset
= 0, np
;
1656 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
1659 ctdb_uint32_push(&in
->count
, buf
+offset
, &np
);
1662 memcpy(buf
+offset
, in
->buf
, in
->buflen
);
1663 offset
+= in
->buflen
;
1668 int ctdb_rec_buffer_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1669 struct ctdb_rec_buffer
**out
, size_t *npull
)
1671 struct ctdb_rec_buffer
*val
;
1672 size_t offset
= 0, np
;
1676 val
= talloc(mem_ctx
, struct ctdb_rec_buffer
);
1681 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
1687 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->count
, &np
);
1693 /* Since there is no buflen provided, walk the records to
1694 * validate the length of the buffer.
1696 val
->buf
= buf
+offset
;
1697 val
->buflen
= buflen
-offset
;
1700 ret
= ctdb_rec_buffer_traverse(val
, NULL
, &length
);
1705 if (length
> buflen
-offset
) {
1710 val
->buf
= talloc_memdup(val
, buf
+offset
, length
);
1711 if (val
->buf
== NULL
) {
1715 val
->buflen
= length
;
1727 struct ctdb_rec_buffer
*ctdb_rec_buffer_init(TALLOC_CTX
*mem_ctx
,
1730 struct ctdb_rec_buffer
*recbuf
;
1732 recbuf
= talloc_zero(mem_ctx
, struct ctdb_rec_buffer
);
1733 if (recbuf
== NULL
) {
1737 recbuf
->db_id
= db_id
;
1742 int ctdb_rec_buffer_add(TALLOC_CTX
*mem_ctx
, struct ctdb_rec_buffer
*recbuf
,
1743 uint32_t reqid
, struct ctdb_ltdb_header
*header
,
1744 TDB_DATA key
, TDB_DATA data
)
1746 struct ctdb_rec_data recdata
;
1750 recdata
.reqid
= reqid
;
1751 recdata
.header
= header
;
1753 recdata
.data
= data
;
1755 len
= ctdb_rec_data_len(&recdata
);
1757 ptr
= talloc_realloc(mem_ctx
, recbuf
->buf
, uint8_t,
1758 recbuf
->buflen
+ len
);
1763 ctdb_rec_data_push(&recdata
, &ptr
[recbuf
->buflen
], &np
);
1767 recbuf
->buflen
+= np
;
1771 int ctdb_rec_buffer_traverse(struct ctdb_rec_buffer
*recbuf
,
1772 ctdb_rec_parser_func_t func
,
1777 size_t offset
, reclen
;
1782 for (i
=0; i
<recbuf
->count
; i
++) {
1783 ret
= ctdb_rec_data_pull_data(&recbuf
->buf
[offset
],
1784 recbuf
->buflen
- offset
,
1785 &reqid
, &key
, &data
, &reclen
);
1791 ret
= func(reqid
, NULL
, key
, data
, private_data
);
1805 size_t *length
= (size_t *)private_data
;
1813 int ctdb_rec_buffer_write(struct ctdb_rec_buffer
*recbuf
, int fd
)
1817 n
= write(fd
, &recbuf
->db_id
, sizeof(uint32_t));
1818 if (n
== -1 || (size_t)n
!= sizeof(uint32_t)) {
1819 return (errno
!= 0 ? errno
: EIO
);
1821 n
= write(fd
, &recbuf
->count
, sizeof(uint32_t));
1822 if (n
== -1 || (size_t)n
!= sizeof(uint32_t)) {
1823 return (errno
!= 0 ? errno
: EIO
);
1825 n
= write(fd
, &recbuf
->buflen
, sizeof(size_t));
1826 if (n
== -1 || (size_t)n
!= sizeof(size_t)) {
1827 return (errno
!= 0 ? errno
: EIO
);
1829 n
= write(fd
, recbuf
->buf
, recbuf
->buflen
);
1830 if (n
== -1 || (size_t)n
!= recbuf
->buflen
) {
1831 return (errno
!= 0 ? errno
: EIO
);
1837 int ctdb_rec_buffer_read(int fd
, TALLOC_CTX
*mem_ctx
,
1838 struct ctdb_rec_buffer
**out
)
1840 struct ctdb_rec_buffer
*recbuf
;
1843 recbuf
= talloc(mem_ctx
, struct ctdb_rec_buffer
);
1844 if (recbuf
== NULL
) {
1848 n
= read(fd
, &recbuf
->db_id
, sizeof(uint32_t));
1849 if (n
== -1 || (size_t)n
!= sizeof(uint32_t)) {
1850 return (errno
!= 0 ? errno
: EIO
);
1852 n
= read(fd
, &recbuf
->count
, sizeof(uint32_t));
1853 if (n
== -1 || (size_t)n
!= sizeof(uint32_t)) {
1854 return (errno
!= 0 ? errno
: EIO
);
1856 n
= read(fd
, &recbuf
->buflen
, sizeof(size_t));
1857 if (n
== -1 || (size_t)n
!= sizeof(size_t)) {
1858 return (errno
!= 0 ? errno
: EIO
);
1861 recbuf
->buf
= talloc_size(recbuf
, recbuf
->buflen
);
1862 if (recbuf
->buf
== NULL
) {
1866 n
= read(fd
, recbuf
->buf
, recbuf
->buflen
);
1867 if (n
== -1 || (size_t)n
!= recbuf
->buflen
) {
1868 return (errno
!= 0 ? errno
: EIO
);
1875 size_t ctdb_traverse_start_len(struct ctdb_traverse_start
*in
)
1877 return ctdb_uint32_len(&in
->db_id
) +
1878 ctdb_uint32_len(&in
->reqid
) +
1879 ctdb_uint64_len(&in
->srvid
);
1882 void ctdb_traverse_start_push(struct ctdb_traverse_start
*in
, uint8_t *buf
,
1885 size_t offset
= 0, np
;
1887 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
1890 ctdb_uint32_push(&in
->reqid
, buf
+offset
, &np
);
1893 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
1899 int ctdb_traverse_start_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1900 struct ctdb_traverse_start
**out
, size_t *npull
)
1902 struct ctdb_traverse_start
*val
;
1903 size_t offset
= 0, np
;
1906 val
= talloc(mem_ctx
, struct ctdb_traverse_start
);
1911 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
1917 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->reqid
, &np
);
1923 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
1938 size_t ctdb_traverse_all_len(struct ctdb_traverse_all
*in
)
1940 return ctdb_uint32_len(&in
->db_id
) +
1941 ctdb_uint32_len(&in
->reqid
) +
1942 ctdb_uint32_len(&in
->pnn
) +
1943 ctdb_uint32_len(&in
->client_reqid
) +
1944 ctdb_uint64_len(&in
->srvid
);
1947 void ctdb_traverse_all_push(struct ctdb_traverse_all
*in
, uint8_t *buf
,
1950 size_t offset
= 0, np
;
1952 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
1955 ctdb_uint32_push(&in
->reqid
, buf
+offset
, &np
);
1958 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
1961 ctdb_uint32_push(&in
->client_reqid
, buf
+offset
, &np
);
1964 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
1970 int ctdb_traverse_all_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
1971 struct ctdb_traverse_all
**out
, size_t *npull
)
1973 struct ctdb_traverse_all
*val
;
1974 size_t offset
= 0, np
;
1977 val
= talloc(mem_ctx
, struct ctdb_traverse_all
);
1982 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
1988 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->reqid
, &np
);
1994 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->pnn
, &np
);
2000 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->client_reqid
,
2007 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
2022 size_t ctdb_traverse_start_ext_len(struct ctdb_traverse_start_ext
*in
)
2024 return ctdb_uint32_len(&in
->db_id
) +
2025 ctdb_uint32_len(&in
->reqid
) +
2026 ctdb_uint64_len(&in
->srvid
) +
2027 ctdb_bool_len(&in
->withemptyrecords
) +
2028 ctdb_padding_len(7);
2031 void ctdb_traverse_start_ext_push(struct ctdb_traverse_start_ext
*in
,
2032 uint8_t *buf
, size_t *npush
)
2034 size_t offset
= 0, np
;
2036 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
2039 ctdb_uint32_push(&in
->reqid
, buf
+offset
, &np
);
2042 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
2045 ctdb_bool_push(&in
->withemptyrecords
, buf
+offset
, &np
);
2048 ctdb_padding_push(7, buf
+offset
, &np
);
2054 int ctdb_traverse_start_ext_pull(uint8_t *buf
, size_t buflen
,
2055 TALLOC_CTX
*mem_ctx
,
2056 struct ctdb_traverse_start_ext
**out
,
2059 struct ctdb_traverse_start_ext
*val
;
2060 size_t offset
= 0, np
;
2063 val
= talloc(mem_ctx
, struct ctdb_traverse_start_ext
);
2068 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
2074 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->reqid
, &np
);
2080 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
2086 ret
= ctdb_bool_pull(buf
+offset
, buflen
-offset
,
2087 &val
->withemptyrecords
, &np
);
2093 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 7, &np
);
2108 size_t ctdb_traverse_all_ext_len(struct ctdb_traverse_all_ext
*in
)
2110 return ctdb_uint32_len(&in
->db_id
) +
2111 ctdb_uint32_len(&in
->reqid
) +
2112 ctdb_uint32_len(&in
->pnn
) +
2113 ctdb_uint32_len(&in
->client_reqid
) +
2114 ctdb_uint64_len(&in
->srvid
) +
2115 ctdb_bool_len(&in
->withemptyrecords
) +
2116 ctdb_padding_len(7);
2119 void ctdb_traverse_all_ext_push(struct ctdb_traverse_all_ext
*in
,
2120 uint8_t *buf
, size_t *npush
)
2122 size_t offset
= 0, np
;
2124 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
2127 ctdb_uint32_push(&in
->reqid
, buf
+offset
, &np
);
2130 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
2133 ctdb_uint32_push(&in
->client_reqid
, buf
+offset
, &np
);
2136 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
2139 ctdb_bool_push(&in
->withemptyrecords
, buf
+offset
, &np
);
2142 ctdb_padding_push(7, buf
+offset
, &np
);
2148 int ctdb_traverse_all_ext_pull(uint8_t *buf
, size_t buflen
,
2149 TALLOC_CTX
*mem_ctx
,
2150 struct ctdb_traverse_all_ext
**out
,
2153 struct ctdb_traverse_all_ext
*val
;
2154 size_t offset
= 0, np
;
2157 val
= talloc(mem_ctx
, struct ctdb_traverse_all_ext
);
2162 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
2168 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->reqid
, &np
);
2174 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->pnn
, &np
);
2180 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->client_reqid
,
2187 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
2193 ret
= ctdb_bool_pull(buf
+offset
, buflen
-offset
,
2194 &val
->withemptyrecords
, &np
);
2200 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 7, &np
);
2215 size_t ctdb_sock_addr_len(ctdb_sock_addr
*in
)
2217 return sizeof(ctdb_sock_addr
);
2220 void ctdb_sock_addr_push(ctdb_sock_addr
*in
, uint8_t *buf
, size_t *npush
)
2222 memcpy(buf
, in
, sizeof(ctdb_sock_addr
));
2223 *npush
= sizeof(ctdb_sock_addr
);
2226 int ctdb_sock_addr_pull_elems(uint8_t *buf
, size_t buflen
,
2227 TALLOC_CTX
*mem_ctx
, ctdb_sock_addr
*out
,
2230 if (buflen
< sizeof(ctdb_sock_addr
)) {
2234 memcpy(out
, buf
, sizeof(ctdb_sock_addr
));
2235 *npull
= sizeof(ctdb_sock_addr
);
2240 int ctdb_sock_addr_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
2241 ctdb_sock_addr
**out
, size_t *npull
)
2243 ctdb_sock_addr
*val
;
2247 val
= talloc(mem_ctx
, ctdb_sock_addr
);
2252 ret
= ctdb_sock_addr_pull_elems(buf
, buflen
, val
, val
, &np
);
2263 size_t ctdb_connection_len(struct ctdb_connection
*in
)
2265 return ctdb_sock_addr_len(&in
->src
) +
2266 ctdb_sock_addr_len(&in
->dst
);
2269 void ctdb_connection_push(struct ctdb_connection
*in
, uint8_t *buf
,
2272 size_t offset
= 0, np
;
2274 ctdb_sock_addr_push(&in
->src
, buf
+offset
, &np
);
2277 ctdb_sock_addr_push(&in
->dst
, buf
+offset
, &np
);
2283 static int ctdb_connection_pull_elems(uint8_t *buf
, size_t buflen
,
2284 TALLOC_CTX
*mem_ctx
,
2285 struct ctdb_connection
*out
,
2288 size_t offset
= 0, np
;
2291 ret
= ctdb_sock_addr_pull_elems(buf
+offset
, buflen
-offset
,
2292 mem_ctx
, &out
->src
, &np
);
2298 ret
= ctdb_sock_addr_pull_elems(buf
+offset
, buflen
-offset
,
2299 mem_ctx
, &out
->dst
, &np
);
2309 int ctdb_connection_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
2310 struct ctdb_connection
**out
, size_t *npull
)
2312 struct ctdb_connection
*val
;
2316 val
= talloc(mem_ctx
, struct ctdb_connection
);
2321 ret
= ctdb_connection_pull_elems(buf
, buflen
, val
, val
, &np
);
2332 size_t ctdb_connection_list_len(struct ctdb_connection_list
*in
)
2336 len
= ctdb_uint32_len(&in
->num
);
2338 len
+= in
->num
* ctdb_connection_len(&in
->conn
[0]);
2344 void ctdb_connection_list_push(struct ctdb_connection_list
*in
, uint8_t *buf
,
2347 size_t offset
= 0, np
;
2350 ctdb_uint32_push(&in
->num
, buf
+offset
, &np
);
2353 for (i
=0; i
<in
->num
; i
++) {
2354 ctdb_connection_push(&in
->conn
[i
], buf
+offset
, &np
);
2361 int ctdb_connection_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
2362 struct ctdb_connection_list
**out
, size_t *npull
)
2364 struct ctdb_connection_list
*val
;
2365 size_t offset
= 0, np
;
2369 val
= talloc(mem_ctx
, struct ctdb_connection_list
);
2374 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num
, &np
);
2380 if (val
->num
== 0) {
2385 val
->conn
= talloc_array(val
, struct ctdb_connection
, val
->num
);
2386 if (val
->conn
== NULL
) {
2391 for (i
=0; i
<val
->num
; i
++) {
2392 ret
= ctdb_connection_pull_elems(buf
+offset
, buflen
-offset
,
2393 val
, &val
->conn
[i
], &np
);
2410 size_t ctdb_tunable_len(struct ctdb_tunable
*in
)
2412 return ctdb_uint32_len(&in
->value
) +
2413 ctdb_stringn_len(&in
->name
);
2416 void ctdb_tunable_push(struct ctdb_tunable
*in
, uint8_t *buf
, size_t *npush
)
2418 size_t offset
= 0, np
;
2420 ctdb_uint32_push(&in
->value
, buf
+offset
, &np
);
2423 ctdb_stringn_push(&in
->name
, buf
+offset
, &np
);
2429 int ctdb_tunable_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
2430 struct ctdb_tunable
**out
, size_t *npull
)
2432 struct ctdb_tunable
*val
;
2433 size_t offset
= 0, np
;
2436 val
= talloc(mem_ctx
, struct ctdb_tunable
);
2441 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->value
, &np
);
2447 ret
= ctdb_stringn_pull(buf
+offset
, buflen
-offset
, mem_ctx
,
2463 size_t ctdb_node_flag_change_len(struct ctdb_node_flag_change
*in
)
2465 return ctdb_uint32_len(&in
->pnn
) +
2466 ctdb_uint32_len(&in
->new_flags
) +
2467 ctdb_uint32_len(&in
->old_flags
);
2470 void ctdb_node_flag_change_push(struct ctdb_node_flag_change
*in
,
2471 uint8_t *buf
, size_t *npush
)
2473 size_t offset
= 0, np
;
2475 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
2478 ctdb_uint32_push(&in
->new_flags
, buf
+offset
, &np
);
2481 ctdb_uint32_push(&in
->old_flags
, buf
+offset
, &np
);
2487 int ctdb_node_flag_change_pull(uint8_t *buf
, size_t buflen
,
2488 TALLOC_CTX
*mem_ctx
,
2489 struct ctdb_node_flag_change
**out
,
2492 struct ctdb_node_flag_change
*val
;
2493 size_t offset
= 0, np
;
2496 val
= talloc(mem_ctx
, struct ctdb_node_flag_change
);
2501 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->pnn
, &np
);
2507 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->new_flags
,
2514 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->old_flags
,
2530 size_t ctdb_var_list_len(struct ctdb_var_list
*in
)
2535 for (i
=0; i
<in
->count
; i
++) {
2536 u32
+= ctdb_string_len(&in
->var
[i
]);
2539 return ctdb_uint32_len(&u32
) + u32
;
2542 void ctdb_var_list_push(struct ctdb_var_list
*in
, uint8_t *buf
, size_t *npush
)
2544 size_t offset
= 0, np
;
2549 /* The length only corresponds to the payload size */
2550 u32
= ctdb_var_list_len(in
);
2551 u32
-= ctdb_uint32_len(&u32
);
2553 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
2556 /* The variables are separated by ':' and the complete string is null
2559 for (i
=0; i
<in
->count
; i
++) {
2560 ctdb_string_push(&in
->var
[i
], buf
+offset
, &np
);
2563 if (i
< in
->count
- 1) {
2564 /* Replace '\0' with ':' */
2565 ctdb_uint8_push(&sep
, buf
+offset
-1, &np
);
2572 int ctdb_var_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
2573 struct ctdb_var_list
**out
, size_t *npull
)
2575 struct ctdb_var_list
*val
;
2576 const char *str
, **list
;
2577 char *s
, *tok
, *ptr
= NULL
;
2578 size_t offset
= 0, np
;
2582 val
= talloc_zero(mem_ctx
, struct ctdb_var_list
);
2587 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
2593 if (buflen
-offset
< u32
) {
2598 ret
= ctdb_string_pull(buf
+offset
, u32
, val
, &str
, &np
);
2604 s
= discard_const(str
);
2605 while ((tok
= strtok_r(s
, ":", &ptr
)) != NULL
) {
2606 list
= talloc_realloc(val
, val
->var
, const char *,
2615 s
= talloc_strdup(val
, tok
);
2621 val
->var
[val
->count
] = s
;
2626 talloc_free(discard_const(str
));
2636 size_t ctdb_tunable_list_len(struct ctdb_tunable_list
*in
)
2638 return ctdb_uint32_len(&in
->max_redirect_count
) +
2639 ctdb_uint32_len(&in
->seqnum_interval
) +
2640 ctdb_uint32_len(&in
->control_timeout
) +
2641 ctdb_uint32_len(&in
->traverse_timeout
) +
2642 ctdb_uint32_len(&in
->keepalive_interval
) +
2643 ctdb_uint32_len(&in
->keepalive_limit
) +
2644 ctdb_uint32_len(&in
->recover_timeout
) +
2645 ctdb_uint32_len(&in
->recover_interval
) +
2646 ctdb_uint32_len(&in
->election_timeout
) +
2647 ctdb_uint32_len(&in
->takeover_timeout
) +
2648 ctdb_uint32_len(&in
->monitor_interval
) +
2649 ctdb_uint32_len(&in
->tickle_update_interval
) +
2650 ctdb_uint32_len(&in
->script_timeout
) +
2651 ctdb_uint32_len(&in
->monitor_timeout_count
) +
2652 ctdb_uint32_len(&in
->script_unhealthy_on_timeout
) +
2653 ctdb_uint32_len(&in
->recovery_grace_period
) +
2654 ctdb_uint32_len(&in
->recovery_ban_period
) +
2655 ctdb_uint32_len(&in
->database_hash_size
) +
2656 ctdb_uint32_len(&in
->database_max_dead
) +
2657 ctdb_uint32_len(&in
->rerecovery_timeout
) +
2658 ctdb_uint32_len(&in
->enable_bans
) +
2659 ctdb_uint32_len(&in
->deterministic_public_ips
) +
2660 ctdb_uint32_len(&in
->reclock_ping_period
) +
2661 ctdb_uint32_len(&in
->no_ip_failback
) +
2662 ctdb_uint32_len(&in
->disable_ip_failover
) +
2663 ctdb_uint32_len(&in
->verbose_memory_names
) +
2664 ctdb_uint32_len(&in
->recd_ping_timeout
) +
2665 ctdb_uint32_len(&in
->recd_ping_failcount
) +
2666 ctdb_uint32_len(&in
->log_latency_ms
) +
2667 ctdb_uint32_len(&in
->reclock_latency_ms
) +
2668 ctdb_uint32_len(&in
->recovery_drop_all_ips
) +
2669 ctdb_uint32_len(&in
->verify_recovery_lock
) +
2670 ctdb_uint32_len(&in
->vacuum_interval
) +
2671 ctdb_uint32_len(&in
->vacuum_max_run_time
) +
2672 ctdb_uint32_len(&in
->repack_limit
) +
2673 ctdb_uint32_len(&in
->vacuum_limit
) +
2674 ctdb_uint32_len(&in
->max_queue_depth_drop_msg
) +
2675 ctdb_uint32_len(&in
->allow_unhealthy_db_read
) +
2676 ctdb_uint32_len(&in
->stat_history_interval
) +
2677 ctdb_uint32_len(&in
->deferred_attach_timeout
) +
2678 ctdb_uint32_len(&in
->vacuum_fast_path_count
) +
2679 ctdb_uint32_len(&in
->lcp2_public_ip_assignment
) +
2680 ctdb_uint32_len(&in
->allow_client_db_attach
) +
2681 ctdb_uint32_len(&in
->recover_pdb_by_seqnum
) +
2682 ctdb_uint32_len(&in
->deferred_rebalance_on_node_add
) +
2683 ctdb_uint32_len(&in
->fetch_collapse
) +
2684 ctdb_uint32_len(&in
->hopcount_make_sticky
) +
2685 ctdb_uint32_len(&in
->sticky_duration
) +
2686 ctdb_uint32_len(&in
->sticky_pindown
) +
2687 ctdb_uint32_len(&in
->no_ip_takeover
) +
2688 ctdb_uint32_len(&in
->db_record_count_warn
) +
2689 ctdb_uint32_len(&in
->db_record_size_warn
) +
2690 ctdb_uint32_len(&in
->db_size_warn
) +
2691 ctdb_uint32_len(&in
->pulldb_preallocation_size
) +
2692 ctdb_uint32_len(&in
->no_ip_host_on_all_disabled
) +
2693 ctdb_uint32_len(&in
->samba3_hack
) +
2694 ctdb_uint32_len(&in
->mutex_enabled
) +
2695 ctdb_uint32_len(&in
->lock_processes_per_db
) +
2696 ctdb_uint32_len(&in
->rec_buffer_size_limit
) +
2697 ctdb_uint32_len(&in
->queue_buffer_size
) +
2698 ctdb_uint32_len(&in
->ip_alloc_algorithm
) +
2699 ctdb_uint32_len(&in
->allow_mixed_versions
);
2702 void ctdb_tunable_list_push(struct ctdb_tunable_list
*in
, uint8_t *buf
,
2705 size_t offset
= 0, np
;
2707 ctdb_uint32_push(&in
->max_redirect_count
, buf
+offset
, &np
);
2710 ctdb_uint32_push(&in
->seqnum_interval
, buf
+offset
, &np
);
2713 ctdb_uint32_push(&in
->control_timeout
, buf
+offset
, &np
);
2716 ctdb_uint32_push(&in
->traverse_timeout
, buf
+offset
, &np
);
2719 ctdb_uint32_push(&in
->keepalive_interval
, buf
+offset
, &np
);
2722 ctdb_uint32_push(&in
->keepalive_limit
, buf
+offset
, &np
);
2725 ctdb_uint32_push(&in
->recover_timeout
, buf
+offset
, &np
);
2728 ctdb_uint32_push(&in
->recover_interval
, buf
+offset
, &np
);
2731 ctdb_uint32_push(&in
->election_timeout
, buf
+offset
, &np
);
2734 ctdb_uint32_push(&in
->takeover_timeout
, buf
+offset
, &np
);
2737 ctdb_uint32_push(&in
->monitor_interval
, buf
+offset
, &np
);
2740 ctdb_uint32_push(&in
->tickle_update_interval
, buf
+offset
, &np
);
2743 ctdb_uint32_push(&in
->script_timeout
, buf
+offset
, &np
);
2746 ctdb_uint32_push(&in
->monitor_timeout_count
, buf
+offset
, &np
);
2749 ctdb_uint32_push(&in
->script_unhealthy_on_timeout
, buf
+offset
, &np
);
2752 ctdb_uint32_push(&in
->recovery_grace_period
, buf
+offset
, &np
);
2755 ctdb_uint32_push(&in
->recovery_ban_period
, buf
+offset
, &np
);
2758 ctdb_uint32_push(&in
->database_hash_size
, buf
+offset
, &np
);
2761 ctdb_uint32_push(&in
->database_max_dead
, buf
+offset
, &np
);
2764 ctdb_uint32_push(&in
->rerecovery_timeout
, buf
+offset
, &np
);
2767 ctdb_uint32_push(&in
->enable_bans
, buf
+offset
, &np
);
2770 ctdb_uint32_push(&in
->deterministic_public_ips
, buf
+offset
, &np
);
2773 ctdb_uint32_push(&in
->reclock_ping_period
, buf
+offset
, &np
);
2776 ctdb_uint32_push(&in
->no_ip_failback
, buf
+offset
, &np
);
2779 ctdb_uint32_push(&in
->disable_ip_failover
, buf
+offset
, &np
);
2782 ctdb_uint32_push(&in
->verbose_memory_names
, buf
+offset
, &np
);
2785 ctdb_uint32_push(&in
->recd_ping_timeout
, buf
+offset
, &np
);
2788 ctdb_uint32_push(&in
->recd_ping_failcount
, buf
+offset
, &np
);
2791 ctdb_uint32_push(&in
->log_latency_ms
, buf
+offset
, &np
);
2794 ctdb_uint32_push(&in
->reclock_latency_ms
, buf
+offset
, &np
);
2797 ctdb_uint32_push(&in
->recovery_drop_all_ips
, buf
+offset
, &np
);
2800 ctdb_uint32_push(&in
->verify_recovery_lock
, buf
+offset
, &np
);
2803 ctdb_uint32_push(&in
->vacuum_interval
, buf
+offset
, &np
);
2806 ctdb_uint32_push(&in
->vacuum_max_run_time
, buf
+offset
, &np
);
2809 ctdb_uint32_push(&in
->repack_limit
, buf
+offset
, &np
);
2812 ctdb_uint32_push(&in
->vacuum_limit
, buf
+offset
, &np
);
2815 ctdb_uint32_push(&in
->max_queue_depth_drop_msg
, buf
+offset
, &np
);
2818 ctdb_uint32_push(&in
->allow_unhealthy_db_read
, buf
+offset
, &np
);
2821 ctdb_uint32_push(&in
->stat_history_interval
, buf
+offset
, &np
);
2824 ctdb_uint32_push(&in
->deferred_attach_timeout
, buf
+offset
, &np
);
2827 ctdb_uint32_push(&in
->vacuum_fast_path_count
, buf
+offset
, &np
);
2830 ctdb_uint32_push(&in
->lcp2_public_ip_assignment
, buf
+offset
, &np
);
2833 ctdb_uint32_push(&in
->allow_client_db_attach
, buf
+offset
, &np
);
2836 ctdb_uint32_push(&in
->recover_pdb_by_seqnum
, buf
+offset
, &np
);
2839 ctdb_uint32_push(&in
->deferred_rebalance_on_node_add
, buf
+offset
, &np
);
2842 ctdb_uint32_push(&in
->fetch_collapse
, buf
+offset
, &np
);
2845 ctdb_uint32_push(&in
->hopcount_make_sticky
, buf
+offset
, &np
);
2848 ctdb_uint32_push(&in
->sticky_duration
, buf
+offset
, &np
);
2851 ctdb_uint32_push(&in
->sticky_pindown
, buf
+offset
, &np
);
2854 ctdb_uint32_push(&in
->no_ip_takeover
, buf
+offset
, &np
);
2857 ctdb_uint32_push(&in
->db_record_count_warn
, buf
+offset
, &np
);
2860 ctdb_uint32_push(&in
->db_record_size_warn
, buf
+offset
, &np
);
2863 ctdb_uint32_push(&in
->db_size_warn
, buf
+offset
, &np
);
2866 ctdb_uint32_push(&in
->pulldb_preallocation_size
, buf
+offset
, &np
);
2869 ctdb_uint32_push(&in
->no_ip_host_on_all_disabled
, buf
+offset
, &np
);
2872 ctdb_uint32_push(&in
->samba3_hack
, buf
+offset
, &np
);
2875 ctdb_uint32_push(&in
->mutex_enabled
, buf
+offset
, &np
);
2878 ctdb_uint32_push(&in
->lock_processes_per_db
, buf
+offset
, &np
);
2881 ctdb_uint32_push(&in
->rec_buffer_size_limit
, buf
+offset
, &np
);
2884 ctdb_uint32_push(&in
->queue_buffer_size
, buf
+offset
, &np
);
2887 ctdb_uint32_push(&in
->ip_alloc_algorithm
, buf
+offset
, &np
);
2890 ctdb_uint32_push(&in
->allow_mixed_versions
, buf
+offset
, &np
);
2896 static int ctdb_tunable_list_pull_elems(uint8_t *buf
, size_t buflen
,
2897 TALLOC_CTX
*mem_ctx
,
2898 struct ctdb_tunable_list
*out
,
2901 size_t offset
= 0, np
;
2904 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2905 &out
->max_redirect_count
, &np
);
2911 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2912 &out
->seqnum_interval
, &np
);
2918 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2919 &out
->control_timeout
, &np
);
2925 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2926 &out
->traverse_timeout
, &np
);
2932 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2933 &out
->keepalive_interval
, &np
);
2939 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2940 &out
->keepalive_limit
, &np
);
2946 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2947 &out
->recover_timeout
, &np
);
2953 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2954 &out
->recover_interval
, &np
);
2960 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2961 &out
->election_timeout
, &np
);
2967 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2968 &out
->takeover_timeout
, &np
);
2974 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2975 &out
->monitor_interval
, &np
);
2981 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2982 &out
->tickle_update_interval
, &np
);
2988 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2989 &out
->script_timeout
, &np
);
2995 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
2996 &out
->monitor_timeout_count
, &np
);
3002 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3003 &out
->script_unhealthy_on_timeout
, &np
);
3009 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3010 &out
->recovery_grace_period
, &np
);
3016 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3017 &out
->recovery_ban_period
, &np
);
3023 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3024 &out
->database_hash_size
, &np
);
3030 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3031 &out
->database_max_dead
, &np
);
3037 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3038 &out
->rerecovery_timeout
, &np
);
3044 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3045 &out
->enable_bans
, &np
);
3051 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3052 &out
->deterministic_public_ips
, &np
);
3058 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3059 &out
->reclock_ping_period
, &np
);
3065 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3066 &out
->no_ip_failback
, &np
);
3072 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3073 &out
->disable_ip_failover
, &np
);
3079 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3080 &out
->verbose_memory_names
, &np
);
3086 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3087 &out
->recd_ping_timeout
, &np
);
3093 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3094 &out
->recd_ping_failcount
, &np
);
3100 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3101 &out
->log_latency_ms
, &np
);
3107 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3108 &out
->reclock_latency_ms
, &np
);
3114 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3115 &out
->recovery_drop_all_ips
, &np
);
3121 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3122 &out
->verify_recovery_lock
, &np
);
3128 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3129 &out
->vacuum_interval
, &np
);
3135 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3136 &out
->vacuum_max_run_time
, &np
);
3142 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3143 &out
->repack_limit
, &np
);
3149 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3150 &out
->vacuum_limit
, &np
);
3156 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3157 &out
->max_queue_depth_drop_msg
, &np
);
3163 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3164 &out
->allow_unhealthy_db_read
, &np
);
3170 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3171 &out
->stat_history_interval
, &np
);
3177 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3178 &out
->deferred_attach_timeout
, &np
);
3184 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3185 &out
->vacuum_fast_path_count
, &np
);
3191 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3192 &out
->lcp2_public_ip_assignment
, &np
);
3198 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3199 &out
->allow_client_db_attach
, &np
);
3205 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3206 &out
->recover_pdb_by_seqnum
, &np
);
3212 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3213 &out
->deferred_rebalance_on_node_add
, &np
);
3219 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3220 &out
->fetch_collapse
, &np
);
3226 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3227 &out
->hopcount_make_sticky
, &np
);
3233 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3234 &out
->sticky_duration
, &np
);
3240 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3241 &out
->sticky_pindown
, &np
);
3247 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3248 &out
->no_ip_takeover
, &np
);
3254 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3255 &out
->db_record_count_warn
, &np
);
3261 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3262 &out
->db_record_size_warn
, &np
);
3268 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3269 &out
->db_size_warn
, &np
);
3275 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3276 &out
->pulldb_preallocation_size
, &np
);
3282 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3283 &out
->no_ip_host_on_all_disabled
, &np
);
3289 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3290 &out
->samba3_hack
, &np
);
3296 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3297 &out
->mutex_enabled
, &np
);
3303 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3304 &out
->lock_processes_per_db
, &np
);
3310 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3311 &out
->rec_buffer_size_limit
, &np
);
3317 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3318 &out
->queue_buffer_size
, &np
);
3324 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3325 &out
->ip_alloc_algorithm
, &np
);
3331 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
3332 &out
->allow_mixed_versions
, &np
);
3342 int ctdb_tunable_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3343 struct ctdb_tunable_list
**out
, size_t *npull
)
3345 struct ctdb_tunable_list
*val
;
3349 val
= talloc(mem_ctx
, struct ctdb_tunable_list
);
3354 ret
= ctdb_tunable_list_pull_elems(buf
, buflen
, val
, val
, &np
);
3365 size_t ctdb_tickle_list_len(struct ctdb_tickle_list
*in
)
3369 len
= ctdb_sock_addr_len(&in
->addr
) +
3370 ctdb_uint32_len(&in
->num
);
3372 len
+= in
->num
* ctdb_connection_len(&in
->conn
[0]);
3378 void ctdb_tickle_list_push(struct ctdb_tickle_list
*in
, uint8_t *buf
,
3381 size_t offset
= 0, np
;
3384 ctdb_sock_addr_push(&in
->addr
, buf
+offset
, &np
);
3387 ctdb_uint32_push(&in
->num
, buf
+offset
, &np
);
3390 for (i
=0; i
<in
->num
; i
++) {
3391 ctdb_connection_push(&in
->conn
[i
], buf
+offset
, &np
);
3398 int ctdb_tickle_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3399 struct ctdb_tickle_list
**out
, size_t *npull
)
3401 struct ctdb_tickle_list
*val
;
3402 size_t offset
= 0, np
;
3406 val
= talloc(mem_ctx
, struct ctdb_tickle_list
);
3411 ret
= ctdb_sock_addr_pull_elems(buf
+offset
, buflen
-offset
, val
,
3418 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num
, &np
);
3424 if (val
->num
== 0) {
3429 val
->conn
= talloc_array(val
, struct ctdb_connection
, val
->num
);
3430 if (val
->conn
== NULL
) {
3435 for (i
=0; i
<val
->num
; i
++) {
3436 ret
= ctdb_connection_pull_elems(buf
+offset
, buflen
-offset
,
3437 val
, &val
->conn
[i
], &np
);
3454 size_t ctdb_addr_info_len(struct ctdb_addr_info
*in
)
3456 return ctdb_sock_addr_len(&in
->addr
) +
3457 ctdb_uint32_len(&in
->mask
) +
3458 ctdb_stringn_len(&in
->iface
);
3461 void ctdb_addr_info_push(struct ctdb_addr_info
*in
, uint8_t *buf
,
3464 size_t offset
= 0, np
;
3466 ctdb_sock_addr_push(&in
->addr
, buf
+offset
, &np
);
3469 ctdb_uint32_push(&in
->mask
, buf
+offset
, &np
);
3472 ctdb_stringn_push(&in
->iface
, buf
+offset
, &np
);
3478 int ctdb_addr_info_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3479 struct ctdb_addr_info
**out
, size_t *npull
)
3481 struct ctdb_addr_info
*val
;
3482 size_t offset
= 0, np
;
3485 val
= talloc(mem_ctx
, struct ctdb_addr_info
);
3490 ret
= ctdb_sock_addr_pull_elems(buf
+offset
, buflen
-offset
, val
,
3497 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->mask
, &np
);
3503 ret
= ctdb_stringn_pull(buf
+offset
, buflen
-offset
, val
, &val
->iface
,
3519 size_t ctdb_transdb_len(struct ctdb_transdb
*in
)
3521 return ctdb_uint32_len(&in
->db_id
) +
3522 ctdb_uint32_len(&in
->tid
);
3525 void ctdb_transdb_push(struct ctdb_transdb
*in
, uint8_t *buf
, size_t *npush
)
3527 size_t offset
= 0, np
;
3529 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
3532 ctdb_uint32_push(&in
->tid
, buf
+offset
, &np
);
3538 int ctdb_transdb_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3539 struct ctdb_transdb
**out
, size_t *npull
)
3541 struct ctdb_transdb
*val
;
3542 size_t offset
= 0, np
;
3545 val
= talloc(mem_ctx
, struct ctdb_transdb
);
3550 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
3556 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->tid
, &np
);
3571 size_t ctdb_uptime_len(struct ctdb_uptime
*in
)
3573 return ctdb_timeval_len(&in
->current_time
) +
3574 ctdb_timeval_len(&in
->ctdbd_start_time
) +
3575 ctdb_timeval_len(&in
->last_recovery_started
) +
3576 ctdb_timeval_len(&in
->last_recovery_finished
);
3579 void ctdb_uptime_push(struct ctdb_uptime
*in
, uint8_t *buf
, size_t *npush
)
3581 size_t offset
= 0, np
;
3583 ctdb_timeval_push(&in
->current_time
, buf
+offset
, &np
);
3586 ctdb_timeval_push(&in
->ctdbd_start_time
, buf
+offset
, &np
);
3589 ctdb_timeval_push(&in
->last_recovery_started
, buf
+offset
, &np
);
3592 ctdb_timeval_push(&in
->last_recovery_finished
, buf
+offset
, &np
);
3598 int ctdb_uptime_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3599 struct ctdb_uptime
**out
, size_t *npull
)
3601 struct ctdb_uptime
*val
;
3602 size_t offset
= 0, np
;
3605 val
= talloc(mem_ctx
, struct ctdb_uptime
);
3610 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
, &val
->current_time
,
3617 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
,
3618 &val
->ctdbd_start_time
, &np
);
3624 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
,
3625 &val
->last_recovery_started
, &np
);
3631 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
,
3632 &val
->last_recovery_finished
, &np
);
3647 size_t ctdb_public_ip_len(struct ctdb_public_ip
*in
)
3649 return ctdb_uint32_len(&in
->pnn
) +
3650 ctdb_sock_addr_len(&in
->addr
);
3653 void ctdb_public_ip_push(struct ctdb_public_ip
*in
, uint8_t *buf
,
3656 size_t offset
= 0, np
;
3658 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
3661 ctdb_sock_addr_push(&in
->addr
, buf
+offset
, &np
);
3667 static int ctdb_public_ip_pull_elems(uint8_t *buf
, size_t buflen
,
3668 TALLOC_CTX
*mem_ctx
,
3669 struct ctdb_public_ip
*out
, size_t *npull
)
3671 size_t offset
= 0, np
;
3674 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->pnn
, &np
);
3680 ret
= ctdb_sock_addr_pull_elems(buf
+offset
, buflen
-offset
, mem_ctx
,
3691 int ctdb_public_ip_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3692 struct ctdb_public_ip
**out
, size_t *npull
)
3694 struct ctdb_public_ip
*val
;
3698 val
= talloc(mem_ctx
, struct ctdb_public_ip
);
3703 ret
= ctdb_public_ip_pull_elems(buf
, buflen
, val
, val
, &np
);
3714 size_t ctdb_public_ip_list_len(struct ctdb_public_ip_list
*in
)
3718 len
= ctdb_uint32_len(&in
->num
);
3720 len
+= in
->num
* ctdb_public_ip_len(&in
->ip
[0]);
3726 void ctdb_public_ip_list_push(struct ctdb_public_ip_list
*in
, uint8_t *buf
,
3729 size_t offset
= 0, np
;
3732 ctdb_uint32_push(&in
->num
, buf
+offset
, &np
);
3735 for (i
=0; i
<in
->num
; i
++) {
3736 ctdb_public_ip_push(&in
->ip
[i
], buf
+offset
, &np
);
3743 int ctdb_public_ip_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3744 struct ctdb_public_ip_list
**out
, size_t *npull
)
3746 struct ctdb_public_ip_list
*val
;
3747 size_t offset
= 0, np
;
3751 val
= talloc(mem_ctx
, struct ctdb_public_ip_list
);
3756 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num
, &np
);
3762 if (val
->num
== 0) {
3767 val
->ip
= talloc_array(val
, struct ctdb_public_ip
, val
->num
);
3768 if (val
->ip
== NULL
) {
3773 for (i
=0; i
<val
->num
; i
++) {
3774 ret
= ctdb_public_ip_pull_elems(buf
+offset
, buflen
-offset
,
3775 val
->ip
, &val
->ip
[i
], &np
);
3792 size_t ctdb_node_and_flags_len(struct ctdb_node_and_flags
*in
)
3794 return ctdb_uint32_len(&in
->pnn
) +
3795 ctdb_uint32_len(&in
->flags
) +
3796 ctdb_sock_addr_len(&in
->addr
);
3799 void ctdb_node_and_flags_push(struct ctdb_node_and_flags
*in
, uint8_t *buf
,
3802 size_t offset
= 0, np
;
3804 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
3807 ctdb_uint32_push(&in
->flags
, buf
+offset
, &np
);
3810 ctdb_sock_addr_push(&in
->addr
, buf
+offset
, &np
);
3816 static int ctdb_node_and_flags_pull_elems(uint8_t *buf
, size_t buflen
,
3817 TALLOC_CTX
*mem_ctx
,
3818 struct ctdb_node_and_flags
*out
,
3821 size_t offset
= 0, np
;
3824 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->pnn
, &np
);
3830 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->flags
, &np
);
3836 ret
= ctdb_sock_addr_pull_elems(buf
+offset
, buflen
-offset
, mem_ctx
,
3847 int ctdb_node_and_flags_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3848 struct ctdb_node_and_flags
**out
, size_t *npull
)
3850 struct ctdb_node_and_flags
*val
;
3854 val
= talloc(mem_ctx
, struct ctdb_node_and_flags
);
3859 ret
= ctdb_node_and_flags_pull_elems(buf
, buflen
, val
, val
, &np
);
3870 size_t ctdb_node_map_len(struct ctdb_node_map
*in
)
3874 len
= ctdb_uint32_len(&in
->num
);
3876 len
+= in
->num
* ctdb_node_and_flags_len(&in
->node
[0]);
3882 void ctdb_node_map_push(struct ctdb_node_map
*in
, uint8_t *buf
, size_t *npush
)
3884 size_t offset
= 0, np
;
3887 ctdb_uint32_push(&in
->num
, buf
+offset
, &np
);
3890 for (i
=0; i
<in
->num
; i
++) {
3891 ctdb_node_and_flags_push(&in
->node
[i
], buf
+offset
, &np
);
3898 int ctdb_node_map_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
3899 struct ctdb_node_map
**out
, size_t *npull
)
3901 struct ctdb_node_map
*val
;
3902 size_t offset
= 0, np
;
3906 val
= talloc(mem_ctx
, struct ctdb_node_map
);
3911 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num
, &np
);
3917 if (val
->num
== 0) {
3922 val
->node
= talloc_array(val
, struct ctdb_node_and_flags
, val
->num
);
3923 if (val
->node
== NULL
) {
3928 for (i
=0; i
<val
->num
; i
++) {
3929 ret
= ctdb_node_and_flags_pull_elems(buf
+offset
,
3931 val
->node
, &val
->node
[i
],
3949 size_t ctdb_script_len(struct ctdb_script
*in
)
3951 return ctdb_chararray_len(in
->name
, MAX_SCRIPT_NAME
+1) +
3952 ctdb_timeval_len(&in
->start
) +
3953 ctdb_timeval_len(&in
->finished
) +
3954 ctdb_int32_len(&in
->status
) +
3955 ctdb_chararray_len(in
->output
, MAX_SCRIPT_OUTPUT
+1) +
3956 ctdb_padding_len(4);
3959 void ctdb_script_push(struct ctdb_script
*in
, uint8_t *buf
, size_t *npush
)
3961 size_t offset
= 0, np
;
3963 ctdb_chararray_push(in
->name
, MAX_SCRIPT_NAME
+1, buf
+offset
, &np
);
3966 ctdb_timeval_push(&in
->start
, buf
+offset
, &np
);
3969 ctdb_timeval_push(&in
->finished
, buf
+offset
, &np
);
3972 ctdb_int32_push(&in
->status
, buf
+offset
, &np
);
3975 ctdb_chararray_push(in
->output
, MAX_SCRIPT_OUTPUT
+1, buf
+offset
, &np
);
3978 ctdb_padding_push(4, buf
+offset
, &np
);
3984 static int ctdb_script_pull_elems(uint8_t *buf
, size_t buflen
,
3985 TALLOC_CTX
*mem_ctx
,
3986 struct ctdb_script
*out
, size_t *npull
)
3988 size_t offset
= 0, np
;
3991 ret
= ctdb_chararray_pull(buf
+offset
, buflen
-offset
,
3992 out
->name
, MAX_SCRIPT_NAME
+1, &np
);
3998 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
, &out
->start
, &np
);
4004 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
, &out
->finished
,
4011 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &out
->status
, &np
);
4017 ret
= ctdb_chararray_pull(buf
+offset
, buflen
-offset
,
4018 out
->output
, MAX_SCRIPT_OUTPUT
+1, &np
);
4024 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
4034 int ctdb_script_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4035 struct ctdb_script
**out
, size_t *npull
)
4037 struct ctdb_script
*val
;
4041 val
= talloc(mem_ctx
, struct ctdb_script
);
4046 ret
= ctdb_script_pull_elems(buf
, buflen
, val
, val
, &np
);
4057 size_t ctdb_script_list_len(struct ctdb_script_list
*in
)
4065 len
= ctdb_uint32_len(&in
->num_scripts
) + ctdb_padding_len(4);
4066 if (in
->num_scripts
> 0) {
4067 len
+= in
->num_scripts
* ctdb_script_len(&in
->script
[0]);
4073 void ctdb_script_list_push(struct ctdb_script_list
*in
, uint8_t *buf
,
4076 size_t offset
= 0, np
;
4084 ctdb_uint32_push(&in
->num_scripts
, buf
+offset
, &np
);
4087 ctdb_padding_push(4, buf
+offset
, &np
);
4090 for (i
=0; i
<in
->num_scripts
; i
++) {
4091 ctdb_script_push(&in
->script
[i
], buf
+offset
, &np
);
4098 int ctdb_script_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4099 struct ctdb_script_list
**out
, size_t *npull
)
4101 struct ctdb_script_list
*val
;
4102 size_t offset
= 0, np
;
4106 /* If event scripts have never been run, the result will be NULL */
4112 val
= talloc(mem_ctx
, struct ctdb_script_list
);
4117 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num_scripts
,
4124 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
4130 if (val
->num_scripts
== 0) {
4135 val
->script
= talloc_array(val
, struct ctdb_script
, val
->num_scripts
);
4136 if (val
->script
== NULL
) {
4141 for (i
=0; i
<val
->num_scripts
; i
++) {
4142 ret
= ctdb_script_pull_elems(buf
+offset
, buflen
-offset
,
4143 val
, &val
->script
[i
], &np
);
4160 size_t ctdb_ban_state_len(struct ctdb_ban_state
*in
)
4162 return ctdb_uint32_len(&in
->pnn
) +
4163 ctdb_uint32_len(&in
->time
);
4166 void ctdb_ban_state_push(struct ctdb_ban_state
*in
, uint8_t *buf
,
4169 size_t offset
= 0, np
;
4171 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
4174 ctdb_uint32_push(&in
->time
, buf
+offset
, &np
);
4180 int ctdb_ban_state_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4181 struct ctdb_ban_state
**out
, size_t *npull
)
4183 struct ctdb_ban_state
*val
;
4184 size_t offset
= 0, np
;
4187 val
= talloc(mem_ctx
, struct ctdb_ban_state
);
4192 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->pnn
, &np
);
4198 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->time
, &np
);
4213 size_t ctdb_notify_data_len(struct ctdb_notify_data
*in
)
4215 return ctdb_uint64_len(&in
->srvid
) +
4216 ctdb_tdb_datan_len(&in
->data
);
4219 void ctdb_notify_data_push(struct ctdb_notify_data
*in
, uint8_t *buf
,
4222 size_t offset
= 0, np
;
4224 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
4227 ctdb_tdb_datan_push(&in
->data
, buf
+offset
, &np
);
4233 int ctdb_notify_data_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4234 struct ctdb_notify_data
**out
, size_t *npull
)
4236 struct ctdb_notify_data
*val
;
4237 size_t offset
= 0, np
;
4240 val
= talloc(mem_ctx
, struct ctdb_notify_data
);
4245 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
4251 ret
= ctdb_tdb_datan_pull(buf
+offset
, buflen
-offset
, val
, &val
->data
,
4267 size_t ctdb_iface_len(struct ctdb_iface
*in
)
4269 return ctdb_chararray_len(in
->name
, CTDB_IFACE_SIZE
+2) +
4270 ctdb_uint16_len(&in
->link_state
) +
4271 ctdb_uint32_len(&in
->references
);
4274 void ctdb_iface_push(struct ctdb_iface
*in
, uint8_t *buf
, size_t *npush
)
4276 size_t offset
= 0, np
;
4278 ctdb_chararray_push(in
->name
, CTDB_IFACE_SIZE
+2, buf
+offset
, &np
);
4281 ctdb_uint16_push(&in
->link_state
, buf
+offset
, &np
);
4284 ctdb_uint32_push(&in
->references
, buf
+offset
, &np
);
4290 static int ctdb_iface_pull_elems(uint8_t *buf
, size_t buflen
,
4291 TALLOC_CTX
*mem_ctx
,
4292 struct ctdb_iface
*out
, size_t *npull
)
4294 size_t offset
= 0, np
;
4297 ret
= ctdb_chararray_pull(buf
+offset
, buflen
-offset
,
4298 out
->name
, CTDB_IFACE_SIZE
+2, &np
);
4304 ret
= ctdb_uint16_pull(buf
+offset
, buflen
-offset
, &out
->link_state
,
4311 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->references
,
4322 int ctdb_iface_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4323 struct ctdb_iface
**out
, size_t *npull
)
4325 struct ctdb_iface
*val
;
4329 val
= talloc(mem_ctx
, struct ctdb_iface
);
4334 ret
= ctdb_iface_pull_elems(buf
, buflen
, val
, val
, &np
);
4345 size_t ctdb_iface_list_len(struct ctdb_iface_list
*in
)
4349 len
= ctdb_uint32_len(&in
->num
);
4351 len
+= in
->num
* ctdb_iface_len(&in
->iface
[0]);
4357 void ctdb_iface_list_push(struct ctdb_iface_list
*in
, uint8_t *buf
,
4360 size_t offset
= 0, np
;
4363 ctdb_uint32_push(&in
->num
, buf
+offset
, &np
);
4366 for (i
=0; i
<in
->num
; i
++) {
4367 ctdb_iface_push(&in
->iface
[i
], buf
+offset
, &np
);
4374 int ctdb_iface_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4375 struct ctdb_iface_list
**out
, size_t *npull
)
4377 struct ctdb_iface_list
*val
;
4378 size_t offset
= 0, np
;
4382 val
= talloc(mem_ctx
, struct ctdb_iface_list
);
4387 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num
, &np
);
4393 if (val
->num
== 0) {
4398 val
->iface
= talloc_array(val
, struct ctdb_iface
, val
->num
);
4399 if (val
->iface
== NULL
) {
4404 for (i
=0; i
<val
->num
; i
++) {
4405 ret
= ctdb_iface_pull_elems(buf
+offset
, buflen
-offset
,
4406 val
, &val
->iface
[i
], &np
);
4423 size_t ctdb_public_ip_info_len(struct ctdb_public_ip_info
*in
)
4425 return ctdb_public_ip_len(&in
->ip
) +
4426 ctdb_uint32_len(&in
->active_idx
) +
4427 ctdb_iface_list_len(in
->ifaces
);
4430 void ctdb_public_ip_info_push(struct ctdb_public_ip_info
*in
, uint8_t *buf
,
4433 size_t offset
= 0, np
;
4435 ctdb_public_ip_push(&in
->ip
, buf
+offset
, &np
);
4438 ctdb_uint32_push(&in
->active_idx
, buf
+offset
, &np
);
4441 ctdb_iface_list_push(in
->ifaces
, buf
+offset
, &np
);
4447 int ctdb_public_ip_info_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4448 struct ctdb_public_ip_info
**out
, size_t *npull
)
4450 struct ctdb_public_ip_info
*val
;
4451 size_t offset
= 0, np
;
4454 val
= talloc(mem_ctx
, struct ctdb_public_ip_info
);
4459 ret
= ctdb_public_ip_pull_elems(buf
+offset
, buflen
-offset
, val
,
4466 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->active_idx
,
4473 ret
= ctdb_iface_list_pull(buf
+offset
, buflen
-offset
, val
,
4489 size_t ctdb_key_data_len(struct ctdb_key_data
*in
)
4491 return ctdb_uint32_len(&in
->db_id
) +
4492 ctdb_padding_len(4) +
4493 ctdb_ltdb_header_len(&in
->header
) +
4494 ctdb_tdb_datan_len(&in
->key
);
4497 void ctdb_key_data_push(struct ctdb_key_data
*in
, uint8_t *buf
, size_t *npush
)
4499 size_t offset
= 0, np
;
4501 ctdb_uint32_push(&in
->db_id
, buf
+offset
, &np
);
4504 ctdb_padding_push(4, buf
+offset
, &np
);
4507 ctdb_ltdb_header_push(&in
->header
, buf
+offset
, &np
);
4510 ctdb_tdb_datan_push(&in
->key
, buf
+offset
, &np
);
4516 int ctdb_key_data_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4517 struct ctdb_key_data
**out
, size_t *npull
)
4519 struct ctdb_key_data
*val
;
4520 size_t offset
= 0, np
;
4523 val
= talloc(mem_ctx
, struct ctdb_key_data
);
4528 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->db_id
, &np
);
4534 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
4540 ret
= ctdb_ltdb_header_pull(buf
+offset
, buflen
-offset
, &val
->header
,
4547 ret
= ctdb_tdb_datan_pull(buf
+offset
, buflen
-offset
, val
, &val
->key
,
4563 /* In the tdb_data structure marshalling, we are only interested in dsize.
4564 * The dptr value is ignored. The actual tdb_data blob is stored separately.
4566 * This is only required for ctdb_db_statistics and will be dropped in future.
4569 static size_t tdb_data_struct_len(TDB_DATA
*data
)
4571 return sizeof(void *) + sizeof(size_t);
4574 static void tdb_data_struct_push(TDB_DATA
*data
, uint8_t *buf
, size_t *npush
)
4578 memcpy(buf
+offset
, &data
->dptr
, sizeof(void *));
4579 offset
+= sizeof(void *);
4581 memcpy(buf
+offset
, &data
->dsize
, sizeof(size_t));
4582 offset
+= sizeof(size_t);
4587 static int tdb_data_struct_pull(uint8_t *buf
, size_t buflen
, TDB_DATA
*data
,
4593 if (buflen
-offset
< sizeof(void *)) {
4597 memcpy(&ptr
, buf
+offset
, sizeof(void *));
4598 offset
+= sizeof(void *);
4601 if (buflen
-offset
< sizeof(size_t)) {
4605 memcpy(&data
->dsize
, buf
+offset
, sizeof(size_t));
4606 offset
+= sizeof(size_t);
4612 size_t ctdb_db_statistics_len(struct ctdb_db_statistics
*in
)
4614 TDB_DATA data
= { 0 };
4619 len
= ctdb_uint32_len(&in
->locks
.num_calls
) +
4620 ctdb_uint32_len(&in
->locks
.num_current
) +
4621 ctdb_uint32_len(&in
->locks
.num_pending
) +
4622 ctdb_uint32_len(&in
->locks
.num_failed
) +
4623 ctdb_latency_counter_len(&in
->locks
.latency
) +
4625 ctdb_uint32_len(&in
->locks
.buckets
[0]) +
4626 ctdb_latency_counter_len(&in
->vacuum
.latency
) +
4627 ctdb_uint32_len(&in
->db_ro_delegations
) +
4628 ctdb_uint32_len(&in
->db_ro_revokes
) +
4630 ctdb_uint32_len(&in
->hop_count_bucket
[0]) +
4631 ctdb_uint32_len(&in
->num_hot_keys
) +
4632 ctdb_padding_len(4) +
4634 (ctdb_uint32_len(&u32
) + ctdb_padding_len(4) +
4635 tdb_data_struct_len(&data
));
4637 for (i
=0; i
<MAX_HOT_KEYS
; i
++) {
4638 len
+= ctdb_tdb_data_len(&in
->hot_keys
[i
].key
);
4644 void ctdb_db_statistics_push(struct ctdb_db_statistics
*in
, uint8_t *buf
,
4647 size_t offset
= 0, np
;
4648 uint32_t num_hot_keys
;
4651 ctdb_uint32_push(&in
->locks
.num_calls
, buf
+offset
, &np
);
4654 ctdb_uint32_push(&in
->locks
.num_current
, buf
+offset
, &np
);
4657 ctdb_uint32_push(&in
->locks
.num_pending
, buf
+offset
, &np
);
4660 ctdb_uint32_push(&in
->locks
.num_failed
, buf
+offset
, &np
);
4663 ctdb_latency_counter_push(&in
->locks
.latency
, buf
+offset
, &np
);
4666 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
4667 ctdb_uint32_push(&in
->locks
.buckets
[i
], buf
+offset
, &np
);
4671 ctdb_latency_counter_push(&in
->vacuum
.latency
, buf
+offset
, &np
);
4674 ctdb_uint32_push(&in
->db_ro_delegations
, buf
+offset
, &np
);
4677 ctdb_uint32_push(&in
->db_ro_revokes
, buf
+offset
, &np
);
4680 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
4681 ctdb_uint32_push(&in
->hop_count_bucket
[i
], buf
+offset
, &np
);
4685 num_hot_keys
= MAX_HOT_KEYS
;
4686 ctdb_uint32_push(&num_hot_keys
, buf
+offset
, &np
);
4689 ctdb_padding_push(4, buf
+offset
, &np
);
4692 for (i
=0; i
<MAX_HOT_KEYS
; i
++) {
4693 ctdb_uint32_push(&in
->hot_keys
[i
].count
, buf
+offset
, &np
);
4696 ctdb_padding_push(4, buf
+offset
, &np
);
4699 tdb_data_struct_push(&in
->hot_keys
[i
].key
, buf
+offset
, &np
);
4703 for (i
=0; i
<MAX_HOT_KEYS
; i
++) {
4704 ctdb_tdb_data_push(&in
->hot_keys
[i
].key
, buf
+offset
, &np
);
4711 static int ctdb_db_statistics_pull_elems(uint8_t *buf
, size_t buflen
,
4712 TALLOC_CTX
*mem_ctx
,
4713 struct ctdb_db_statistics
*out
,
4716 size_t offset
= 0, np
;
4719 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4720 &out
->locks
.num_calls
, &np
);
4726 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4727 &out
->locks
.num_current
, &np
);
4733 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4734 &out
->locks
.num_pending
, &np
);
4740 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4741 &out
->locks
.num_failed
, &np
);
4747 ret
= ctdb_latency_counter_pull(buf
+offset
, buflen
-offset
,
4748 &out
->locks
.latency
, &np
);
4754 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
4755 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4756 &out
->locks
.buckets
[i
], &np
);
4763 ret
= ctdb_latency_counter_pull(buf
+offset
, buflen
-offset
,
4764 &out
->vacuum
.latency
, &np
);
4770 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4771 &out
->db_ro_delegations
, &np
);
4777 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4778 &out
->db_ro_revokes
, &np
);
4784 for (i
=0; i
<MAX_COUNT_BUCKETS
; i
++) {
4785 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4786 &out
->hop_count_bucket
[i
], &np
);
4793 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4794 &out
->num_hot_keys
, &np
);
4800 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
4806 for (i
=0; i
<MAX_HOT_KEYS
; i
++) {
4807 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
,
4808 &out
->hot_keys
[i
].count
, &np
);
4814 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
4820 ret
= tdb_data_struct_pull(buf
+offset
, buflen
-offset
,
4821 &out
->hot_keys
[i
].key
, &np
);
4828 for (i
=0; i
<MAX_HOT_KEYS
; i
++) {
4829 ret
= ctdb_tdb_data_pull(buf
+offset
,
4830 out
->hot_keys
[i
].key
.dsize
,
4831 out
, &out
->hot_keys
[i
].key
, &np
);
4842 int ctdb_db_statistics_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4843 struct ctdb_db_statistics
**out
, size_t *npull
)
4845 struct ctdb_db_statistics
*val
;
4849 val
= talloc(mem_ctx
, struct ctdb_db_statistics
);
4854 ret
= ctdb_db_statistics_pull_elems(buf
, buflen
, val
, val
, &np
);
4865 size_t ctdb_pid_srvid_len(struct ctdb_pid_srvid
*in
)
4867 return ctdb_pid_len(&in
->pid
) +
4868 ctdb_uint64_len(&in
->srvid
);
4871 void ctdb_pid_srvid_push(struct ctdb_pid_srvid
*in
, uint8_t *buf
,
4874 size_t offset
= 0, np
;
4876 ctdb_pid_push(&in
->pid
, buf
+offset
, &np
);
4879 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
4885 int ctdb_pid_srvid_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
4886 struct ctdb_pid_srvid
**out
, size_t *npull
)
4888 struct ctdb_pid_srvid
*val
;
4889 size_t offset
= 0, np
;
4892 val
= talloc(mem_ctx
, struct ctdb_pid_srvid
);
4897 ret
= ctdb_pid_pull(buf
+offset
, buflen
-offset
, &val
->pid
, &np
);
4903 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
4918 size_t ctdb_election_message_len(struct ctdb_election_message
*in
)
4920 return ctdb_uint32_len(&in
->num_connected
) +
4921 ctdb_padding_len(4) +
4922 ctdb_timeval_len(&in
->priority_time
) +
4923 ctdb_uint32_len(&in
->pnn
) +
4924 ctdb_uint32_len(&in
->node_flags
);
4927 void ctdb_election_message_push(struct ctdb_election_message
*in
,
4928 uint8_t *buf
, size_t *npush
)
4930 size_t offset
= 0, np
;
4932 ctdb_uint32_push(&in
->num_connected
, buf
+offset
, &np
);
4935 ctdb_padding_push(4, buf
+offset
, &np
);
4938 ctdb_timeval_push(&in
->priority_time
, buf
+offset
, &np
);
4941 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
4944 ctdb_uint32_push(&in
->node_flags
, buf
+offset
, &np
);
4950 int ctdb_election_message_pull(uint8_t *buf
, size_t buflen
,
4951 TALLOC_CTX
*mem_ctx
,
4952 struct ctdb_election_message
**out
,
4955 struct ctdb_election_message
*val
;
4956 size_t offset
= 0, np
;
4959 val
= talloc(mem_ctx
, struct ctdb_election_message
);
4964 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->num_connected
,
4971 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
4977 ret
= ctdb_timeval_pull(buf
+offset
, buflen
-offset
,
4978 &val
->priority_time
, &np
);
4984 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->pnn
, &np
);
4990 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->node_flags
,
5006 size_t ctdb_srvid_message_len(struct ctdb_srvid_message
*in
)
5008 return ctdb_uint32_len(&in
->pnn
) +
5009 ctdb_padding_len(4) +
5010 ctdb_uint64_len(&in
->srvid
);
5013 void ctdb_srvid_message_push(struct ctdb_srvid_message
*in
, uint8_t *buf
,
5016 size_t offset
= 0, np
;
5018 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
5021 ctdb_padding_push(4, buf
+offset
, &np
);
5024 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
5030 int ctdb_srvid_message_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
5031 struct ctdb_srvid_message
**out
, size_t *npull
)
5033 struct ctdb_srvid_message
*val
;
5034 size_t offset
= 0, np
;
5037 val
= talloc(mem_ctx
, struct ctdb_srvid_message
);
5042 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->pnn
, &np
);
5048 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
5054 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
5069 size_t ctdb_disable_message_len(struct ctdb_disable_message
*in
)
5071 return ctdb_uint32_len(&in
->pnn
) +
5072 ctdb_padding_len(4) +
5073 ctdb_uint64_len(&in
->srvid
) +
5074 ctdb_uint32_len(&in
->timeout
) +
5075 ctdb_padding_len(4);
5078 void ctdb_disable_message_push(struct ctdb_disable_message
*in
, uint8_t *buf
,
5081 size_t offset
= 0, np
;
5083 ctdb_uint32_push(&in
->pnn
, buf
+offset
, &np
);
5086 ctdb_padding_push(4, buf
+offset
, &np
);
5089 ctdb_uint64_push(&in
->srvid
, buf
+offset
, &np
);
5092 ctdb_uint32_push(&in
->timeout
, buf
+offset
, &np
);
5095 ctdb_padding_push(4, buf
+offset
, &np
);
5101 int ctdb_disable_message_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
5102 struct ctdb_disable_message
**out
,
5105 struct ctdb_disable_message
*val
;
5106 size_t offset
= 0, np
;
5109 val
= talloc(mem_ctx
, struct ctdb_disable_message
);
5114 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->pnn
, &np
);
5120 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
5126 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &val
->srvid
, &np
);
5132 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &val
->timeout
, &np
);
5138 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
5153 size_t ctdb_server_id_len(struct ctdb_server_id
*in
)
5155 return ctdb_uint64_len(&in
->pid
) +
5156 ctdb_uint32_len(&in
->task_id
) +
5157 ctdb_uint32_len(&in
->vnn
) +
5158 ctdb_uint64_len(&in
->unique_id
);
5161 void ctdb_server_id_push(struct ctdb_server_id
*in
, uint8_t *buf
,
5164 size_t offset
= 0, np
;
5166 ctdb_uint64_push(&in
->pid
, buf
+offset
, &np
);
5169 ctdb_uint32_push(&in
->task_id
, buf
+offset
, &np
);
5172 ctdb_uint32_push(&in
->vnn
, buf
+offset
, &np
);
5175 ctdb_uint64_push(&in
->unique_id
, buf
+offset
, &np
);
5181 int ctdb_server_id_pull(uint8_t *buf
, size_t buflen
,
5182 struct ctdb_server_id
*out
, size_t *npull
)
5184 size_t offset
= 0, np
;
5187 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &out
->pid
, &np
);
5193 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->task_id
, &np
);
5199 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &out
->vnn
, &np
);
5205 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &out
->unique_id
,
5216 size_t ctdb_g_lock_len(struct ctdb_g_lock
*in
)
5218 return ctdb_uint32_len(&in
->type
) +
5219 ctdb_padding_len(4) +
5220 ctdb_server_id_len(&in
->sid
);
5223 void ctdb_g_lock_push(struct ctdb_g_lock
*in
, uint8_t *buf
, size_t *npush
)
5225 size_t offset
= 0, np
;
5229 ctdb_uint32_push(&type
, buf
+offset
, &np
);
5232 ctdb_padding_push(4, buf
+offset
, &np
);
5235 ctdb_server_id_push(&in
->sid
, buf
+offset
, &np
);
5241 int ctdb_g_lock_pull(uint8_t *buf
, size_t buflen
, struct ctdb_g_lock
*out
,
5244 size_t offset
= 0, np
;
5248 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &type
, &np
);
5255 out
->type
= CTDB_G_LOCK_READ
;
5256 } else if (type
== 1) {
5257 out
->type
= CTDB_G_LOCK_WRITE
;
5262 ret
= ctdb_padding_pull(buf
+offset
, buflen
-offset
, 4, &np
);
5268 ret
= ctdb_server_id_pull(buf
+offset
, buflen
-offset
, &out
->sid
, &np
);
5278 size_t ctdb_g_lock_list_len(struct ctdb_g_lock_list
*in
)
5283 len
+= in
->num
* ctdb_g_lock_len(&in
->lock
[0]);
5289 void ctdb_g_lock_list_push(struct ctdb_g_lock_list
*in
, uint8_t *buf
,
5292 size_t offset
= 0, np
;
5295 for (i
=0; i
<in
->num
; i
++) {
5296 ctdb_g_lock_push(&in
->lock
[i
], buf
+offset
, &np
);
5303 int ctdb_g_lock_list_pull(uint8_t *buf
, size_t buflen
, TALLOC_CTX
*mem_ctx
,
5304 struct ctdb_g_lock_list
**out
, size_t *npull
)
5306 struct ctdb_g_lock_list
*val
;
5307 struct ctdb_g_lock lock
= { 0 };
5308 size_t offset
= 0, np
;
5312 val
= talloc(mem_ctx
, struct ctdb_g_lock_list
);
5323 val
->num
= buflen
/ ctdb_g_lock_len(&lock
);
5325 val
->lock
= talloc_array(val
, struct ctdb_g_lock
, val
->num
);
5326 if (val
->lock
== NULL
) {
5331 for (i
=0; i
<val
->num
; i
++) {
5332 ret
= ctdb_g_lock_pull(buf
+offset
, buflen
-offset
,
5333 &val
->lock
[i
], &np
);