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

Function cmap_track_add

lib/cmap.c:977–1066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

975}
976
977cs_error_t cmap_track_add(
978 cmap_handle_t handle,
979 const char *key_name,
980 int32_t track_type,
981 cmap_notify_fn_t notify_fn,
982 void *user_data,
983 cmap_track_handle_t *cmap_track_handle)
984{
985 cs_error_t error;
986 struct iovec iov;
987 struct cmap_inst *cmap_inst;
988 struct req_lib_cmap_track_add req_lib_cmap_track_add;
989 struct res_lib_cmap_track_add res_lib_cmap_track_add;
990 struct cmap_track_inst *cmap_track_inst;
991 cmap_track_handle_t cmap_track_inst_handle;
992
993 if (cmap_track_handle == NULL || notify_fn == NULL) {
994 return (CS_ERR_INVALID_PARAM);
995 }
996
997 error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst));
998 if (error != CS_OK) {
999 return (error);
1000 }
1001
1002 error = hdb_error_to_cs(hdb_handle_create(&cmap_track_handle_t_db,
1003 sizeof(*cmap_track_inst), &cmap_track_inst_handle));
1004 if (error != CS_OK) {
1005 goto error_put;
1006 }
1007
1008 error = hdb_error_to_cs(hdb_handle_get(&cmap_track_handle_t_db,
1009 cmap_track_inst_handle, (void *)&cmap_track_inst));
1010 if (error != CS_OK) {
1011 goto error_put_destroy;
1012 }
1013
1014 cmap_track_inst->user_data = user_data;
1015 cmap_track_inst->notify_fn = notify_fn;
1016 cmap_track_inst->c = cmap_inst->c;
1017
1018 memset(&req_lib_cmap_track_add, 0, sizeof(req_lib_cmap_track_add));
1019 req_lib_cmap_track_add.header.size = sizeof(req_lib_cmap_track_add);
1020 req_lib_cmap_track_add.header.id = MESSAGE_REQ_CMAP_TRACK_ADD;
1021
1022 if (key_name) {
1023 if (strlen(key_name) >= CS_MAX_NAME_LENGTH) {
1024 return (CS_ERR_NAME_TOO_LONG);
1025 }
1026 memcpy(req_lib_cmap_track_add.key_name.value, key_name, strlen(key_name));
1027 req_lib_cmap_track_add.key_name.length = strlen(key_name);
1028 }
1029
1030 req_lib_cmap_track_add.track_type = track_type;
1031 req_lib_cmap_track_add.track_inst_handle = cmap_track_inst_handle;
1032
1033 iov.iov_base = (char *)&req_lib_cmap_track_add;
1034 iov.iov_len = sizeof(req_lib_cmap_track_add);

Callers 6

track_link_updown_eventsFunction · 0.85
_cs_cmap_initFunction · 0.85
add_trackFunction · 0.85
track_addFunction · 0.85

Calls 6

hdb_error_to_csFunction · 0.85
hdb_handle_getFunction · 0.85
hdb_handle_createFunction · 0.85
qb_to_cs_errorFunction · 0.85
hdb_handle_putFunction · 0.85
hdb_handle_destroyFunction · 0.85

Tested by

no test coverage detected