-int pd_uuid_make_v1(struct pd_uuid_state *s, pd_uuid_t *uuid) {
- struct pd_uuid_state ls;
- uint64_t now;
- uint64_t node;
- int err;
-
- if (!s) {
- s = &ls;
- pd_uuid_init_state(s);
- }
-
- if (s->get_lock) {
- if ((err = s->get_lock(s->lock_data)) != 0) {
- /* TODO set uuid to nil ? */
- /* be cute and have an "error" uuid? */
- return 0;
- }
- }
-
- if (s->read_state) {
- if ((err = s->read_state(s)) != 0) {
- return 0;
- }
- }
-
- now = current_time();
- node = current_node(s);
-
- if (!s->available || s->node != node) {
- s->clock_sequence = random_clock_sequence(s);
- }
-
- s->node = node;