totempg.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. /*
  2. * Copyright (c) 2003-2005 MontaVista Software, Inc.
  3. * Copyright (c) 2005 OSDL.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@mvista.com)
  8. * Mark Haverkamp (markh@osdl.org)
  9. *
  10. * This software licensed under BSD license, the text of which follows:
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * - Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  21. * contributors may be used to endorse or promote products derived from this
  22. * software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  34. * THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. /*
  37. * FRAGMENTATION AND PACKING ALGORITHM:
  38. *
  39. * Assemble the entire message into one buffer
  40. * if full fragment
  41. * store fragment into lengths list
  42. * for each full fragment
  43. * multicast fragment
  44. * set length and fragment fields of pg mesage
  45. * store remaining multicast into head of fragmentation data and set lens field
  46. *
  47. * If a message exceeds the maximum packet size allowed by the totem
  48. * single ring protocol, the protocol could lose forward progress.
  49. * Statically calculating the allowed data amount doesn't work because
  50. * the amount of data allowed depends on the number of fragments in
  51. * each message. In this implementation, the maximum fragment size
  52. * is dynamically calculated for each fragment added to the message.
  53. * It is possible for a message to be two bytes short of the maximum
  54. * packet size. This occurs when a message or collection of
  55. * messages + the mcast header + the lens are two bytes short of the
  56. * end of the packet. Since another len field consumes two bytes, the
  57. * len field would consume the rest of the packet without room for data.
  58. *
  59. * One optimization would be to forgo the final len field and determine
  60. * it from the size of the udp datagram. Then this condition would no
  61. * longer occur.
  62. */
  63. /*
  64. * ASSEMBLY AND UNPACKING ALGORITHM:
  65. *
  66. * copy incoming packet into assembly data buffer indexed by current
  67. * location of end of fragment
  68. *
  69. * if not fragmented
  70. * deliver all messages in assembly data buffer
  71. * else
  72. * if msg_count > 1 and fragmented
  73. * deliver all messages except last message in assembly data buffer
  74. * copy last fragmented section to start of assembly data buffer
  75. * else
  76. * if msg_count = 1 and fragmented
  77. * do nothing
  78. *
  79. */
  80. #include <netinet/in.h>
  81. #include "totempg.h"
  82. #include "totemsrp.h"
  83. #include "totemmrp.h"
  84. #include <sys/uio.h>
  85. #include <stdio.h>
  86. #include <stdlib.h>
  87. #include <string.h>
  88. #include <assert.h>
  89. #include "swab.h"
  90. #define min(a,b) ((a) < (b)) ? a : b
  91. struct totempg_mcast_header {
  92. short version;
  93. short type;
  94. };
  95. /*
  96. * totempg_mcast structure
  97. *
  98. * header: Identify the mcast.
  99. * fragmented: Set if this message continues into next message
  100. * continuation: Set if this message is a continuation from last message
  101. * msg_count Indicates how many packed messages are contained
  102. * in the mcast.
  103. * Also, the size of each packed message and the messages themselves are
  104. * appended to the end of this structure when sent.
  105. */
  106. struct totempg_mcast {
  107. struct totempg_mcast_header header;
  108. unsigned char fragmented;
  109. unsigned char continuation;
  110. unsigned short msg_count;
  111. /*
  112. * short msg_len[msg_count];
  113. */
  114. /*
  115. * data for messages
  116. */
  117. };
  118. /*
  119. * Maximum packet size for totem pg messages
  120. */
  121. #define TOTEMPG_PACKET_SIZE (totempg_totem_config->net_mtu - \
  122. sizeof (struct totempg_mcast))
  123. /*
  124. * Local variables used for packing small messages
  125. */
  126. static unsigned short mcast_packed_msg_lens[FRAME_SIZE_MAX];
  127. static int mcast_packed_msg_count = 0;
  128. struct totem_config *totempg_totem_config;
  129. static void (*app_deliver_fn) (
  130. struct totem_ip_address *source_addr,
  131. struct iovec *iovec,
  132. int iov_len,
  133. int endian_conversion_required) = 0;
  134. static void (*app_confchg_fn) (
  135. enum totem_configuration_type configuration_type,
  136. struct totem_ip_address *member_list, int member_list_entries,
  137. struct totem_ip_address *left_list, int left_list_entries,
  138. struct totem_ip_address *joined_list, int joined_list_entries,
  139. struct memb_ring_id *ring_id) = 0;
  140. struct assembly {
  141. struct totem_ip_address addr;
  142. unsigned char data[MESSAGE_SIZE_MAX];
  143. int index;
  144. unsigned char last_frag_num;
  145. };
  146. struct assembly *assembly_list[PROCESSOR_COUNT_MAX];
  147. int assembly_list_entries = 0;
  148. /*
  149. * Staging buffer for packed messages. Messages are staged in this buffer
  150. * before sending. Multiple messages may fit which cuts down on the
  151. * number of mcasts sent. If a message doesn't completely fit, then
  152. * the mcast header has a fragment bit set that says that there are more
  153. * data to follow. fragment_size is an index into the buffer. It indicates
  154. * the size of message data and where to place new message data.
  155. * fragment_contuation indicates whether the first packed message in
  156. * the buffer is a continuation of a previously packed fragment.
  157. */
  158. static unsigned char *fragmentation_data;
  159. int fragment_size = 0;
  160. int fragment_continuation = 0;
  161. static struct iovec iov_delv;
  162. static struct assembly *find_assembly (struct totem_ip_address *addr)
  163. {
  164. int i;
  165. for (i = 0; i < assembly_list_entries; i++) {
  166. if (totemip_equal(addr, &assembly_list[i]->addr)) {
  167. return (assembly_list[i]);
  168. }
  169. }
  170. return (0);
  171. }
  172. static void totempg_confchg_fn (
  173. enum totem_configuration_type configuration_type,
  174. struct totem_ip_address *member_list, int member_list_entries,
  175. struct totem_ip_address *left_list, int left_list_entries,
  176. struct totem_ip_address *joined_list, int joined_list_entries,
  177. struct memb_ring_id *ring_id)
  178. {
  179. int i;
  180. int j;
  181. int found;
  182. /*
  183. * Clean out the assembly area for nodes that have left the
  184. * membership. If they return, we don't want any stale message
  185. * data that may be there.
  186. */
  187. for (i = 0; i < left_list_entries; i++) {
  188. for (j = 0; j < assembly_list_entries; j++) {
  189. if (totemip_equal(&left_list[i], &assembly_list[j]->addr)) {
  190. assembly_list[j]->index = 0;
  191. }
  192. }
  193. }
  194. /*
  195. * Create a message assembly area for any new members.
  196. */
  197. for (i = 0; i < member_list_entries; i++) {
  198. found = 0;
  199. for (j = 0; j < assembly_list_entries; j++) {
  200. if (totemip_equal(&member_list[i], &assembly_list[j]->addr)) {
  201. found = 1;
  202. break;
  203. }
  204. }
  205. if (found == 0) {
  206. assembly_list[assembly_list_entries] =
  207. malloc (sizeof (struct assembly));
  208. assert (assembly_list[assembly_list_entries]); // TODO
  209. totemip_copy(&assembly_list[assembly_list_entries]->addr,
  210. &member_list[i]);
  211. assembly_list[assembly_list_entries]->index = 0;
  212. assembly_list_entries += 1;
  213. }
  214. }
  215. app_confchg_fn (configuration_type,
  216. member_list, member_list_entries,
  217. left_list, left_list_entries,
  218. joined_list, joined_list_entries,
  219. ring_id);
  220. }
  221. static void totempg_deliver_fn (
  222. struct totem_ip_address *source_addr,
  223. struct iovec *iovec,
  224. int iov_len,
  225. int endian_conversion_required)
  226. {
  227. struct totempg_mcast *mcast;
  228. unsigned short *msg_lens;
  229. int i;
  230. struct assembly *assembly;
  231. char header[FRAME_SIZE_MAX];
  232. int h_index;
  233. int a_i = 0;
  234. int msg_count;
  235. int continuation;
  236. int start;
  237. assembly = find_assembly (source_addr);
  238. assert (assembly);
  239. /*
  240. * Assemble the header into one block of data and
  241. * assemble the packet contents into one block of data to simplify delivery
  242. */
  243. if (iov_len == 1) {
  244. /*
  245. * This message originated from external processor
  246. * because there is only one iovec for the full msg.
  247. */
  248. char *data;
  249. int datasize;
  250. mcast = (struct totempg_mcast *)iovec[0].iov_base;
  251. msg_count = mcast->msg_count;
  252. if (endian_conversion_required) {
  253. msg_count = swab16 (mcast->msg_count);
  254. }
  255. datasize = sizeof (struct totempg_mcast) +
  256. msg_count * sizeof (unsigned short);
  257. memcpy (header, iovec[0].iov_base, datasize);
  258. assert(iovec);
  259. data = iovec[0].iov_base;
  260. msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
  261. memcpy (&assembly->data[assembly->index], &data[datasize],
  262. iovec[0].iov_len - datasize);
  263. } else {
  264. /*
  265. * The message originated from local processor
  266. * becasue there is greater than one iovec for then full msg.
  267. */
  268. h_index = 0;
  269. for (i = 0; i < 2; i++) {
  270. memcpy (&header[h_index], iovec[i].iov_base, iovec[i].iov_len);
  271. h_index += iovec[i].iov_len;
  272. }
  273. mcast = (struct totempg_mcast *)header;
  274. // TODO make sure we are using a copy of mcast not the actual data itself
  275. msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
  276. for (i = 2; i < iov_len; i++) {
  277. a_i = assembly->index;
  278. assert (iovec[i].iov_len + a_i <= MESSAGE_SIZE_MAX);
  279. memcpy (&assembly->data[a_i], iovec[i].iov_base, iovec[i].iov_len);
  280. a_i += msg_lens[i - 2];
  281. }
  282. iov_len -= 2;
  283. }
  284. if (endian_conversion_required) {
  285. mcast->msg_count = swab16 (mcast->msg_count);
  286. for (i = 0; i < mcast->msg_count; i++) {
  287. msg_lens[i] = swab16 (msg_lens[i]);
  288. }
  289. }
  290. /*
  291. printf ("Message fragmented %d count %d\n", mcast->fragmented, mcast->msg_count);
  292. for (i = 0; i < mcast->msg_count; i++) {
  293. printf ("len[%d] = %d\n", i, msg_lens[i]);
  294. }
  295. */
  296. /*
  297. * If the last message in the buffer is a fragment, then we
  298. * can't deliver it. We'll first deliver the full messages
  299. * then adjust the assembly buffer so we can add the rest of the
  300. * fragment when it arrives.
  301. */
  302. msg_count = mcast->fragmented ? mcast->msg_count - 1 : mcast->msg_count;
  303. continuation = mcast->continuation;
  304. iov_delv.iov_base = &assembly->data[0];
  305. iov_delv.iov_len = assembly->index + msg_lens[0];
  306. // printf ("%d %d %d\n", msg_count, continuation, assembly->last_frag_num);
  307. /*
  308. * Make sure that if this message is a continuation, that it
  309. * matches the sequence number of the previous fragment.
  310. * Also, if the first packed message is a continuation
  311. * of a previous message, but the assembly buffer
  312. * is empty, then we need to discard it since we can't
  313. * assemble a complete message. Likewise, if this message isn't a
  314. * continuation and the assembly buffer is empty, we have to discard
  315. * the continued message.
  316. */
  317. start = 0;
  318. if (continuation) {
  319. if (continuation != assembly->last_frag_num) {
  320. printf("Message continuation doesn't match previous frag e: %u - a: %u\n",
  321. assembly->last_frag_num, continuation);
  322. continuation = 0;
  323. }
  324. if ((assembly->index == 0) ||
  325. (!continuation && assembly->index)) {
  326. printf("Throwing away broken message: continuation %u, index %u\n",
  327. continuation, assembly->index);
  328. continuation = 0;
  329. }
  330. /*
  331. * we decided to throw away the first continued message
  332. * in this buffer, if continuation was set to zero.
  333. */
  334. if (!continuation) {
  335. assembly->index += msg_lens[0];
  336. iov_delv.iov_base = &assembly->data[assembly->index];
  337. iov_delv.iov_len = msg_lens[1];
  338. start = 1;
  339. }
  340. }
  341. for (i = start; i < msg_count; i++) {
  342. app_deliver_fn(source_addr, &iov_delv, 1,
  343. endian_conversion_required);
  344. assembly->index += msg_lens[i];
  345. iov_delv.iov_base = &assembly->data[assembly->index];
  346. if (i < (msg_count - 1)) {
  347. iov_delv.iov_len = msg_lens[i + 1];
  348. }
  349. }
  350. if (mcast->fragmented) {
  351. assembly->last_frag_num = mcast->fragmented;
  352. if (mcast->msg_count > 1) {
  353. memmove (&assembly->data[0],
  354. &assembly->data[assembly->index],
  355. msg_lens[msg_count]);
  356. assembly->index = 0;
  357. }
  358. assembly->index += msg_lens[msg_count];
  359. } else {
  360. assembly->last_frag_num = 0;
  361. assembly->index = 0;
  362. }
  363. }
  364. /*
  365. * Totem Process Group Abstraction
  366. * depends on poll abstraction, POSIX, IPV4
  367. */
  368. void *callback_token_received_handle;
  369. int callback_token_received_fn (enum totem_callback_token_type type,
  370. void *data)
  371. {
  372. struct totempg_mcast mcast;
  373. struct iovec iovecs[3];
  374. int res;
  375. if (mcast_packed_msg_count == 0) {
  376. return (0);
  377. }
  378. if (totemmrp_avail() == 0) {
  379. return (0);
  380. }
  381. mcast.fragmented = 0;
  382. /*
  383. * Was the first message in this buffer a continuation of a
  384. * fragmented message?
  385. */
  386. mcast.continuation = fragment_continuation;
  387. fragment_continuation = 0;
  388. mcast.msg_count = mcast_packed_msg_count;
  389. iovecs[0].iov_base = &mcast;
  390. iovecs[0].iov_len = sizeof (struct totempg_mcast);
  391. iovecs[1].iov_base = mcast_packed_msg_lens;
  392. iovecs[1].iov_len = mcast_packed_msg_count * sizeof (unsigned short);
  393. iovecs[2].iov_base = &fragmentation_data[0];
  394. iovecs[2].iov_len = fragment_size;
  395. res = totemmrp_mcast (iovecs, 3, 0);
  396. mcast_packed_msg_count = 0;
  397. fragment_size = 0;
  398. return (0);
  399. }
  400. /*
  401. * Initialize the totem process group abstraction
  402. */
  403. int totempg_initialize (
  404. poll_handle poll_handle,
  405. struct totem_config *totem_config,
  406. void (*deliver_fn) (
  407. struct totem_ip_address *source_addr,
  408. struct iovec *iovec,
  409. int iov_len,
  410. int endian_conversion_required),
  411. void (*confchg_fn) (
  412. enum totem_configuration_type configuration_type,
  413. struct totem_ip_address *member_list, int member_list_entries,
  414. struct totem_ip_address *left_list, int left_list_entries,
  415. struct totem_ip_address *joined_list, int joined_list_entries,
  416. struct memb_ring_id *ring_id))
  417. {
  418. int res;
  419. app_deliver_fn = deliver_fn;
  420. app_confchg_fn = confchg_fn;
  421. totempg_totem_config = totem_config;
  422. fragmentation_data = malloc (TOTEMPG_PACKET_SIZE);
  423. if (fragmentation_data == 0) {
  424. return (-1);
  425. }
  426. res = totemmrp_initialize (
  427. poll_handle,
  428. totem_config,
  429. totempg_deliver_fn,
  430. totempg_confchg_fn);
  431. totemmrp_callback_token_create (
  432. &callback_token_received_handle,
  433. TOTEM_CALLBACK_TOKEN_RECEIVED,
  434. 0,
  435. callback_token_received_fn,
  436. 0);
  437. totemsrp_net_mtu_adjust (totem_config);
  438. return (res);
  439. }
  440. void totempg_finalize (void)
  441. {
  442. totemmrp_finalize ();
  443. }
  444. static unsigned char next_fragment = 1;
  445. /*
  446. * Multicast a message
  447. */
  448. int totempg_mcast (
  449. struct iovec *iovec,
  450. int iov_len,
  451. int guarantee)
  452. {
  453. int res = 0;
  454. struct totempg_mcast mcast;
  455. struct iovec iovecs[3];
  456. int i;
  457. int max_packet_size = 0;
  458. int copy_len = 0;
  459. int copy_base = 0;
  460. int total_size = 0;
  461. totemmrp_new_msg_signal ();
  462. max_packet_size = TOTEMPG_PACKET_SIZE -
  463. (sizeof (unsigned short) * (mcast_packed_msg_count + 1));
  464. mcast_packed_msg_lens[mcast_packed_msg_count] = 0;
  465. /*
  466. * Check if we would overwrite new message queue
  467. */
  468. for (i = 0; i < iov_len; i++) {
  469. total_size += iovec[i].iov_len;
  470. }
  471. if( totempg_send_ok (total_size + sizeof(unsigned short) *
  472. (mcast_packed_msg_count+1)) == 0) {
  473. return(-1);
  474. }
  475. for (i = 0; i < iov_len; ) {
  476. mcast.fragmented = 0;
  477. mcast.continuation = fragment_continuation;
  478. copy_len = iovec[i].iov_len - copy_base;
  479. /*
  480. * If it all fits with room left over, copy it in.
  481. * We need to leave at least sizeof(short) + 1 bytes in the
  482. * fragment_buffer on exit so that max_packet_size + fragment_size
  483. * doesn't exceed the size of the fragment_buffer on the next call.
  484. */
  485. if ((copy_len + fragment_size) <
  486. (max_packet_size - sizeof (unsigned short))) {
  487. memcpy (&fragmentation_data[fragment_size],
  488. iovec[i].iov_base + copy_base, copy_len);
  489. fragment_size += copy_len;
  490. mcast_packed_msg_lens[mcast_packed_msg_count] += copy_len;
  491. copy_len = 0;
  492. copy_base = 0;
  493. i++;
  494. continue;
  495. /*
  496. * If it just fits or is too big, then send out what fits.
  497. */
  498. } else {
  499. unsigned char *data_ptr;
  500. copy_len = min(copy_len, max_packet_size - fragment_size);
  501. if( copy_len == max_packet_size )
  502. data_ptr = iovec[i].iov_base + copy_base;
  503. else {
  504. data_ptr = fragmentation_data;
  505. memcpy (&fragmentation_data[fragment_size],
  506. iovec[i].iov_base + copy_base, copy_len);
  507. }
  508. memcpy (&fragmentation_data[fragment_size],
  509. iovec[i].iov_base + copy_base, copy_len);
  510. mcast_packed_msg_lens[mcast_packed_msg_count] += copy_len;
  511. /*
  512. * if we're not on the last iovec or the iovec is too large to
  513. * fit, then indicate a fragment. This also means that the next
  514. * message will have the continuation of this one.
  515. */
  516. if ((i < (iov_len - 1)) ||
  517. ((copy_base + copy_len) < iovec[i].iov_len)) {
  518. if (!next_fragment) {
  519. next_fragment++;
  520. }
  521. fragment_continuation = next_fragment;
  522. mcast.fragmented = next_fragment++;
  523. assert(fragment_continuation != 0);
  524. assert(mcast.fragmented != 0);
  525. } else {
  526. fragment_continuation = 0;
  527. }
  528. /*
  529. * assemble the message and send it
  530. */
  531. mcast.msg_count = ++mcast_packed_msg_count;
  532. iovecs[0].iov_base = &mcast;
  533. iovecs[0].iov_len = sizeof(struct totempg_mcast);
  534. iovecs[1].iov_base = mcast_packed_msg_lens;
  535. iovecs[1].iov_len = mcast_packed_msg_count *
  536. sizeof(unsigned short);
  537. iovecs[2].iov_base = data_ptr;
  538. iovecs[2].iov_len = max_packet_size;
  539. assert (totemmrp_avail() > 0);
  540. res = totemmrp_mcast (iovecs, 3, guarantee);
  541. /*
  542. * Recalculate counts and indexes for the next.
  543. */
  544. mcast_packed_msg_lens[0] = 0;
  545. mcast_packed_msg_count = 0;
  546. fragment_size = 0;
  547. max_packet_size = TOTEMPG_PACKET_SIZE - (sizeof(unsigned short));
  548. /*
  549. * If the iovec all fit, go to the next iovec
  550. */
  551. if ((copy_base + copy_len) == iovec[i].iov_len) {
  552. copy_len = 0;
  553. copy_base = 0;
  554. i++;
  555. /*
  556. * Continue with the rest of the current iovec.
  557. */
  558. } else {
  559. copy_base += copy_len;
  560. }
  561. }
  562. }
  563. /*
  564. * Bump only if we added message data. This may be zero if
  565. * the last buffer just fit into the fragmentation_data buffer
  566. * and we were at the last iovec.
  567. */
  568. if (mcast_packed_msg_lens[mcast_packed_msg_count]) {
  569. mcast_packed_msg_count++;
  570. }
  571. return (res);
  572. }
  573. /*
  574. * Determine if a message of msg_size could be queued
  575. */
  576. int totempg_send_ok (
  577. int msg_size)
  578. {
  579. int avail = 0;
  580. int total;
  581. avail = totemmrp_avail ();
  582. /*
  583. * msg size less then totempg_totem_config->net_mtu - 25 will take up
  584. * a full message, so add +1
  585. * totempg_totem_config->net_mtu - 25 is for the totempg_mcast header
  586. */
  587. total = (msg_size / (totempg_totem_config->net_mtu - 25)) + 1;
  588. return (avail >= total);
  589. }
  590. int totempg_callback_token_create (
  591. void **handle_out,
  592. enum totem_callback_token_type type,
  593. int delete,
  594. int (*callback_fn) (enum totem_callback_token_type type, void *),
  595. void *data)
  596. {
  597. return totemmrp_callback_token_create (handle_out, type, delete, callback_fn, data);
  598. }
  599. void totempg_callback_token_destroy (
  600. void *handle_out)
  601. {
  602. totemmrp_callback_token_destroy (handle_out);
  603. }
  604. /*
  605. * vi: set autoindent tabstop=4 shiftwidth=4 :
  606. */