MCPcopy Create free account
hub / github.com/corosync/corosync / cmap_set

Function cmap_set

lib/cmap.c:390–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390cs_error_t cmap_set (
391 cmap_handle_t handle,
392 const char *key_name,
393 const void *value,
394 size_t value_len,
395 cmap_value_types_t type)
396{
397 cs_error_t error;
398 struct iovec iov[2];
399 struct cmap_inst *cmap_inst;
400 struct req_lib_cmap_set req_lib_cmap_set;
401 struct res_lib_cmap_set res_lib_cmap_set;
402
403 if (key_name == NULL || value == NULL) {
404 return (CS_ERR_INVALID_PARAM);
405 }
406
407 if (strlen(key_name) >= CS_MAX_NAME_LENGTH) {
408 return (CS_ERR_NAME_TOO_LONG);
409 }
410
411 error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst));
412 if (error != CS_OK) {
413 return (error);
414 }
415
416 memset(&req_lib_cmap_set, 0, sizeof(req_lib_cmap_set));
417 req_lib_cmap_set.header.size = sizeof(req_lib_cmap_set) + value_len;
418 req_lib_cmap_set.header.id = MESSAGE_REQ_CMAP_SET;
419
420 memcpy(req_lib_cmap_set.key_name.value, key_name, strlen(key_name));
421 req_lib_cmap_set.key_name.length = strlen(key_name);
422
423 req_lib_cmap_set.value_len = value_len;
424 req_lib_cmap_set.type = type;
425
426 iov[0].iov_base = (char *)&req_lib_cmap_set;
427 iov[0].iov_len = sizeof(req_lib_cmap_set);
428 iov[1].iov_base = (void *)value;
429 iov[1].iov_len = value_len;
430
431 error = qb_to_cs_error(qb_ipcc_sendv_recv(
432 cmap_inst->c,
433 iov,
434 2,
435 &res_lib_cmap_set,
436 sizeof (struct res_lib_cmap_set), CS_IPC_TIMEOUT_MS));
437
438 if (error == CS_OK) {
439 error = res_lib_cmap_set.header.error;
440 }
441
442 (void)hdb_handle_put (&cmap_handle_t_db, handle);
443
444 return (error);
445}
446
447cs_error_t cmap_set_int8(cmap_handle_t handle, const char *key_name, int8_t value)

Callers 13

set_key_binFunction · 0.85
cmap_set_int8Function · 0.85
cmap_set_uint8Function · 0.85
cmap_set_int16Function · 0.85
cmap_set_uint16Function · 0.85
cmap_set_int32Function · 0.85
cmap_set_uint32Function · 0.85
cmap_set_int64Function · 0.85
cmap_set_uint64Function · 0.85
cmap_set_floatFunction · 0.85
cmap_set_doubleFunction · 0.85
cmap_set_stringFunction · 0.85

Calls 4

hdb_error_to_csFunction · 0.85
hdb_handle_getFunction · 0.85
qb_to_cs_errorFunction · 0.85
hdb_handle_putFunction · 0.85

Tested by

no test coverage detected