| 264 | } |
| 265 | |
| 266 | int32_t |
| 267 | cib_common_callback(qb_ipcs_connection_t *c, void *data, size_t size, gboolean privileged) |
| 268 | { |
| 269 | uint32_t id = 0; |
| 270 | uint32_t flags = 0; |
| 271 | int call_options = 0; |
| 272 | xmlNode *op_request = crm_ipcs_recv(c, data, size, &id, &flags); |
| 273 | cib_client_t *cib_client = qb_ipcs_context_get(c); |
| 274 | |
| 275 | if(op_request) { |
| 276 | crm_element_value_int(op_request, F_CIB_CALLOPTS, &call_options); |
| 277 | } |
| 278 | |
| 279 | crm_trace("Inbound: %.200s", data); |
| 280 | if (op_request == NULL || cib_client == NULL) { |
| 281 | crm_ipcs_send_ack(c, id, "nack", __FUNCTION__, __LINE__); |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | if(is_set(call_options, cib_sync_call)) { |
| 286 | CRM_ASSERT(flags & crm_ipc_client_response); |
| 287 | } |
| 288 | |
| 289 | if(flags & crm_ipc_client_response) { |
| 290 | CRM_LOG_ASSERT(cib_client->request_id == 0); /* This means the client has two synchronous events in-flight */ |
| 291 | cib_client->request_id = id; /* Reply only to the last one */ |
| 292 | } |
| 293 | |
| 294 | |
| 295 | if (cib_client->name == NULL) { |
| 296 | const char *value = crm_element_value(op_request, F_CIB_CLIENTNAME); |
| 297 | if (value == NULL) { |
| 298 | cib_client->name = crm_itoa(crm_ipcs_client_pid(c)); |
| 299 | } else { |
| 300 | cib_client->name = strdup(value); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | if (cib_client->callback_id == NULL) { |
| 305 | const char *value = crm_element_value(op_request, F_CIB_CALLBACK_TOKEN); |
| 306 | if (value != NULL) { |
| 307 | cib_client->callback_id = strdup(value); |
| 308 | |
| 309 | } else { |
| 310 | cib_client->callback_id = strdup(cib_client->id); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | crm_xml_add(op_request, F_CIB_CLIENTID, cib_client->id); |
| 315 | crm_xml_add(op_request, F_CIB_CLIENTNAME, cib_client->name); |
| 316 | |
| 317 | #if ENABLE_ACL |
| 318 | determine_request_user(cib_client->user, op_request, F_CIB_USER); |
| 319 | #endif |
| 320 | |
| 321 | crm_log_xml_trace(op_request, "Client[inbound]"); |
| 322 | |
| 323 | cib_common_callback_worker(id, flags, op_request, cib_client, privileged); |
no test coverage detected