Skip to content

Commit

Permalink
Refactor: libcrmcommon: add pcmk__server_ipc_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
kgaillot committed Jul 17, 2024
1 parent fb8dc30 commit db60945
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions include/crm/common/servers_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern "C" {
#endif

const char *pcmk__server_log_name(enum pcmk_ipc_server server);
const char *pcmk__server_ipc_name(enum pcmk_ipc_server server);

#ifdef __cplusplus
}
Expand Down
21 changes: 3 additions & 18 deletions lib/common/ipc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,29 +255,14 @@ pcmk_ipc_name(const pcmk_ipc_api_t *api, bool for_log)
return pcmk__s(name, "Pacemaker");
}
switch (api->server) {
case pcmk_ipc_attrd:
return PCMK__VALUE_ATTRD;

// These servers do not have pcmk_ipc_api_t implementations yet
case pcmk_ipc_based:
return NULL /* PCMK__SERVER_BASED_RW */;

case pcmk_ipc_controld:
return CRM_SYSTEM_CRMD;

case pcmk_ipc_execd:
return NULL /* CRM_SYSTEM_LRMD */;

case pcmk_ipc_fenced:
return NULL /* "stonith-ng" */;

case pcmk_ipc_pacemakerd:
return CRM_SYSTEM_MCP;

case pcmk_ipc_schedulerd:
return CRM_SYSTEM_PENGINE;
return NULL;

default:
return NULL;
return pcmk__server_ipc_name(api->server);
}
}

Expand Down
16 changes: 16 additions & 0 deletions lib/common/servers.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,19 @@ pcmk__server_log_name(enum pcmk_ipc_server server)
return NULL);
return server_info[server].log_name;
}

/*!
* \internal
* \brief Return the (primary) IPC endpoint name for a server
*
* \param[in] server Server to get IPC endpoint for
*
* \return IPC endpoint for server (or NULL if invalid)
*/
const char *
pcmk__server_ipc_name(enum pcmk_ipc_server server)
{
CRM_CHECK((server > 0) && (server < PCMK__NELEM(server_info)),
return NULL);
return server_info[server].ipc_names[0];
}

0 comments on commit db60945

Please sign in to comment.