| 1135 | */ |
| 1136 | |
| 1137 | int totempg_groups_initialize ( |
| 1138 | void **totempg_groups_instance, |
| 1139 | |
| 1140 | void (*deliver_fn) ( |
| 1141 | unsigned int nodeid, |
| 1142 | const void *msg, |
| 1143 | unsigned int msg_len, |
| 1144 | int endian_conversion_required), |
| 1145 | |
| 1146 | void (*confchg_fn) ( |
| 1147 | enum totem_configuration_type configuration_type, |
| 1148 | const unsigned int *member_list, size_t member_list_entries, |
| 1149 | const unsigned int *left_list, size_t left_list_entries, |
| 1150 | const unsigned int *joined_list, size_t joined_list_entries, |
| 1151 | const struct memb_ring_id *ring_id)) |
| 1152 | { |
| 1153 | struct totempg_group_instance *instance; |
| 1154 | |
| 1155 | if (totempg_threaded_mode == 1) { |
| 1156 | pthread_mutex_lock (&totempg_mutex); |
| 1157 | } |
| 1158 | |
| 1159 | instance = malloc (sizeof (struct totempg_group_instance)); |
| 1160 | if (instance == NULL) { |
| 1161 | goto error_exit; |
| 1162 | } |
| 1163 | |
| 1164 | instance->deliver_fn = deliver_fn; |
| 1165 | instance->confchg_fn = confchg_fn; |
| 1166 | instance->groups = 0; |
| 1167 | instance->groups_cnt = 0; |
| 1168 | instance->q_level = QB_LOOP_MED; |
| 1169 | qb_list_init (&instance->list); |
| 1170 | qb_list_add (&instance->list, &totempg_groups_list); |
| 1171 | |
| 1172 | if (totempg_threaded_mode == 1) { |
| 1173 | pthread_mutex_unlock (&totempg_mutex); |
| 1174 | } |
| 1175 | *totempg_groups_instance = instance; |
| 1176 | return (0); |
| 1177 | |
| 1178 | error_exit: |
| 1179 | if (totempg_threaded_mode == 1) { |
| 1180 | pthread_mutex_unlock (&totempg_mutex); |
| 1181 | } |
| 1182 | return (-1); |
| 1183 | } |
| 1184 | |
| 1185 | int totempg_groups_join ( |
| 1186 | void *totempg_groups_instance, |