mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
messaging3: Make messaging_dgm_cleanup return 0/errno
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
e6b33ce611
commit
2f3435085e
@ -76,7 +76,7 @@ struct messaging_backend {
|
||||
NTSTATUS messaging_dgm_init(struct messaging_context *msg_ctx,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct messaging_backend **presult);
|
||||
NTSTATUS messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid);
|
||||
int messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid);
|
||||
NTSTATUS messaging_dgm_wipe(struct messaging_context *msg_ctx);
|
||||
void *messaging_dgm_register_tevent_context(TALLOC_CTX *mem_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
|
@ -368,7 +368,7 @@ static void messaging_dgm_recv(struct unix_msg_ctx *ctx,
|
||||
messaging_dispatch_rec(dgm_ctx->msg_ctx, &rec);
|
||||
}
|
||||
|
||||
NTSTATUS messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid)
|
||||
int messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid)
|
||||
{
|
||||
struct messaging_backend *be = messaging_local_backend(msg_ctx);
|
||||
struct messaging_dgm_context *ctx = talloc_get_type_abort(
|
||||
@ -376,26 +376,25 @@ NTSTATUS messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid)
|
||||
char *lockfile_name, *socket_name;
|
||||
int fd, ret;
|
||||
struct flock lck = {};
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
|
||||
lockfile_name = talloc_asprintf(talloc_tos(), "%s/lck/%u",
|
||||
ctx->cache_dir, (unsigned)pid);
|
||||
if (lockfile_name == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
return ENOMEM;
|
||||
}
|
||||
socket_name = talloc_asprintf(lockfile_name, "%s/msg/%u",
|
||||
ctx->cache_dir, (unsigned)pid);
|
||||
if (socket_name == NULL) {
|
||||
TALLOC_FREE(lockfile_name);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
fd = open(lockfile_name, O_NONBLOCK|O_WRONLY, 0);
|
||||
if (fd == -1) {
|
||||
status = map_nt_error_from_unix(errno);
|
||||
ret = errno;
|
||||
DEBUG(10, ("%s: open(%s) failed: %s\n", __func__,
|
||||
lockfile_name, strerror(errno)));
|
||||
return status;
|
||||
lockfile_name, strerror(ret)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
lck.l_type = F_WRLCK;
|
||||
@ -405,12 +404,12 @@ NTSTATUS messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid)
|
||||
|
||||
ret = fcntl(fd, F_SETLK, &lck);
|
||||
if (ret != 0) {
|
||||
status = map_nt_error_from_unix(errno);
|
||||
ret = errno;
|
||||
DEBUG(10, ("%s: Could not get lock: %s\n", __func__,
|
||||
strerror(errno)));
|
||||
strerror(ret)));
|
||||
TALLOC_FREE(lockfile_name);
|
||||
close(fd);
|
||||
return status;
|
||||
return ret;
|
||||
}
|
||||
|
||||
(void)unlink(socket_name);
|
||||
@ -418,7 +417,7 @@ NTSTATUS messaging_dgm_cleanup(struct messaging_context *msg_ctx, pid_t pid)
|
||||
(void)close(fd);
|
||||
|
||||
TALLOC_FREE(lockfile_name);
|
||||
return NT_STATUS_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
NTSTATUS messaging_dgm_wipe(struct messaging_context *msg_ctx)
|
||||
@ -449,7 +448,6 @@ NTSTATUS messaging_dgm_wipe(struct messaging_context *msg_ctx)
|
||||
}
|
||||
|
||||
while ((dp = readdir(msgdir)) != NULL) {
|
||||
NTSTATUS status;
|
||||
unsigned long pid;
|
||||
|
||||
pid = strtoul(dp->d_name, NULL, 10);
|
||||
@ -467,9 +465,9 @@ NTSTATUS messaging_dgm_wipe(struct messaging_context *msg_ctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
status = messaging_dgm_cleanup(msg_ctx, pid);
|
||||
ret = messaging_dgm_cleanup(msg_ctx, pid);
|
||||
DEBUG(10, ("messaging_dgm_cleanup(%lu) returned %s\n",
|
||||
pid, nt_errstr(status)));
|
||||
pid, ret ? strerror(ret) : "ok"));
|
||||
}
|
||||
closedir(msgdir);
|
||||
|
||||
|
@ -445,13 +445,13 @@ static void remove_child_pid(struct smbd_parent_context *parent,
|
||||
{
|
||||
struct smbd_child_pid *child;
|
||||
struct server_id child_id;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
|
||||
child_id = pid_to_procid(pid);
|
||||
|
||||
status = messaging_dgm_cleanup(parent->msg_ctx, pid);
|
||||
ret = messaging_dgm_cleanup(parent->msg_ctx, pid);
|
||||
DEBUG(10, ("%s: messaging_dgm_cleanup returned %s\n",
|
||||
__func__, nt_errstr(status)));
|
||||
__func__, ret ? strerror(ret) : "ok"));
|
||||
|
||||
for (child = parent->children; child != NULL; child = child->next) {
|
||||
if (child->pid == pid) {
|
||||
|
@ -973,10 +973,14 @@ static bool do_dgm_cleanup(struct tevent_context *ev_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
NTSTATUS status;
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
|
||||
if (pid.pid != 0) {
|
||||
status = messaging_dgm_cleanup(msg_ctx, pid.pid);
|
||||
int ret;
|
||||
ret = messaging_dgm_cleanup(msg_ctx, pid.pid);
|
||||
if (ret != 0) {
|
||||
status = map_nt_error_from_unix(ret);
|
||||
}
|
||||
} else {
|
||||
status = messaging_dgm_wipe(msg_ctx);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user