Skip to content

Commit

Permalink
fix lock temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigzagAK authored Jul 29, 2021
1 parent 3b37383 commit a4e6d89
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ngx_zookeeper_upstream_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,8 @@ ngx_zookeeper_ctx_deref(ngx_zookeeper_path_ctx_t *ctx)
}

rc = zoo_acreate(zoo.handle, (const char *) ctx->zscf->lock.data,
"", 0, &ZOO_OPEN_ACL_UNSAFE, 0, ngx_zookeeper_sync_lock, ctx->zscf);
"", 0, &ZOO_OPEN_ACL_UNSAFE, ctx->zscf->lock_ephemeral == 1 ? ZOO_EPHEMERAL : 0,
ngx_zookeeper_sync_lock, ctx->zscf);
if (rc != ZOK)
ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0,
"Zookeeper upstream: [%V] failed to "
Expand Down Expand Up @@ -1510,7 +1511,7 @@ ensure_zpath_ready(int rc, const char *dummy, const void *ctx)


static void
ensure_zpath(const ngx_str_t *path, ngx_flag_t ephemeral)
ensure_zpath(const ngx_str_t *path)
{
u_char *s2;
ngx_str_t *sub;
Expand All @@ -1524,15 +1525,14 @@ ensure_zpath(const ngx_str_t *path, ngx_flag_t ephemeral)
sub = ngx_calloc(sizeof(ngx_str_t), ngx_cycle->log);
if (sub == NULL)
goto nomem;

sub->data = ngx_calloc(s2 - path->data + 1, ngx_cycle->log);
if (sub->data == NULL)
goto nomem;
sub->len = s2 - path->data;
ngx_memcpy(sub->data, path->data, sub->len);

zoo_acreate(zoo.handle, (const char *) sub->data, "", 0,
&ZOO_OPEN_ACL_UNSAFE, ephemeral == 1 && *s2 == 0 ? ZOO_EPHEMERAL : 0, ensure_zpath_ready, sub);
&ZOO_OPEN_ACL_UNSAFE, 0, ensure_zpath_ready, sub);
}
}

Expand All @@ -1559,7 +1559,7 @@ ensure_lock_path_ready(int rc, const struct Stat *dummy,
if (rc == ZNONODE) {

zscf->busy = 0;
return ensure_zpath(&zscf->lock_path, zscf->lock_ephemeral);
return ensure_zpath(&zscf->lock_path);
}

ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0,
Expand Down

0 comments on commit a4e6d89

Please sign in to comment.