| 77 | |
| 78 | static unsigned char buffer[2000000]; |
| 79 | int main (void) |
| 80 | { |
| 81 | cpg_handle_t handle; |
| 82 | cs_error_t result; |
| 83 | unsigned int i = 0; |
| 84 | struct iovec iov; |
| 85 | int res; |
| 86 | unsigned int msg_size; |
| 87 | |
| 88 | result = cpg_initialize (&handle, &callbacks); |
| 89 | if (result != CS_OK) { |
| 90 | printf ("Couldn't initialize CPG service %d\n", result); |
| 91 | exit (0); |
| 92 | } |
| 93 | |
| 94 | res = cpg_join (handle, &group_name); |
| 95 | if (res != CS_OK) { |
| 96 | printf ("cpg_join failed with result %d\n", res); |
| 97 | exit (1); |
| 98 | } |
| 99 | |
| 100 | iov.iov_base = (void *)buffer; |
| 101 | |
| 102 | /* |
| 103 | * Demonstrate cpg_mcast_joined |
| 104 | */ |
| 105 | msg_size = 1025000; |
| 106 | for (i = 0; i < 1000000000; i++) { |
| 107 | iov.iov_len = msg_size; |
| 108 | try_again_one: |
| 109 | result = cpg_mcast_joined (handle, CPG_TYPE_AGREED, |
| 110 | &iov, 1); |
| 111 | if (result == CS_ERR_TRY_AGAIN) { |
| 112 | goto try_again_one; |
| 113 | } |
| 114 | if (result == CS_ERR_INVALID_PARAM) { |
| 115 | printf ("found boundary at %d\n", msg_size); |
| 116 | exit (1); |
| 117 | } |
| 118 | msg_size += 1; |
| 119 | printf ("msg size %d\n", msg_size); |
| 120 | result = cpg_dispatch (handle, CS_DISPATCH_ALL); |
| 121 | if (result != CS_OK && result != CS_ERR_TRY_AGAIN) { |
| 122 | printf ("cpg_dispatch failed with result %d\n", res); |
| 123 | exit (1); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | cpg_finalize (handle); |
| 128 | |
| 129 | return (0); |
| 130 | } |
nothing calls this directly
no test coverage detected