odissey: reuse client id as a forge backend key

This commit is contained in:
Dmitry Simonenko 2017-11-24 15:19:14 +03:00
parent b63748813e
commit 023b931ee1
4 changed files with 10 additions and 9 deletions

View File

@ -244,8 +244,8 @@ od_frontend_key(od_client_t *client)
* possibility of cancelling requests by a previous
* server owners.
*/
client->key.key_pid = *(int32_t*)client->id.id;
client->key.key = 1 + rand();
client->key.key_pid = client->id.id_a;
client->key.key = client->id.id_b;
}
static inline int

View File

@ -71,6 +71,9 @@ void od_idmgr_generate(od_idmgr_t *mgr, od_id_t *id, char *prefix)
memcpy(seed + 4, &b, 2);
id->id_prefix = prefix;
id->id_a = a;
id->id_b = b;
static const char *hex = "0123456789abcdef";
int q, w;
for (q = 0, w = 0; q < OD_ID_SEEDMAX; q++) {

View File

@ -14,8 +14,10 @@ typedef struct od_idmgr od_idmgr_t;
struct od_id
{
char *id_prefix;
char id[OD_ID_SEEDMAX * 2];
char *id_prefix;
char id[OD_ID_SEEDMAX * 2];
uint64_t id_a;
uint64_t id_b;
};
struct od_idmgr

View File

@ -175,11 +175,7 @@ int od_instance_main(od_instance_t *instance, int argc, char **argv)
od_pid_create(&instance->pid, instance->scheme.pid_file);
/* seed id manager */
rc = od_idmgr_seed(&instance->id_mgr);
if (rc == -1) {
od_error(&instance->logger, "init", NULL, NULL,
"failed to open random source device");
}
od_idmgr_seed(&instance->id_mgr);
/* run system services */
od_router_t router;