mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-common: Add client pid to connect callback in sock_daemon
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
5586e035f2
commit
f42106fb49
@ -36,6 +36,7 @@
|
||||
#include "common/reqid.h"
|
||||
#include "common/comm.h"
|
||||
#include "common/pidfile.h"
|
||||
#include "common/system.h"
|
||||
#include "common/sock_daemon.h"
|
||||
|
||||
struct sock_socket {
|
||||
@ -114,9 +115,14 @@ static int sock_client_context_init(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
|
||||
if (sock->funcs->connect != NULL) {
|
||||
pid_t pid;
|
||||
bool status;
|
||||
|
||||
status = sock->funcs->connect(client_ctx, sock->private_data);
|
||||
(void) ctdb_get_peer_pid(client_fd, &pid);
|
||||
|
||||
status = sock->funcs->connect(client_ctx,
|
||||
pid,
|
||||
sock->private_data);
|
||||
if (! status) {
|
||||
talloc_free(client_ctx);
|
||||
close(client_fd);
|
||||
|
@ -109,6 +109,7 @@ struct sock_daemon_funcs {
|
||||
* connect() is called when there is a new connection
|
||||
*
|
||||
* @param[in] client The new socket client context
|
||||
* @param[in] pid The pid of the new client process, or -1 if unknown
|
||||
* @param[in] private_data Private data set with the socket
|
||||
* @return true if connection should be accepted, false otherwise
|
||||
*
|
||||
@ -139,6 +140,7 @@ struct sock_daemon_funcs {
|
||||
*/
|
||||
struct sock_socket_funcs {
|
||||
bool (*connect)(struct sock_client_context *client,
|
||||
pid_t pid,
|
||||
void *private_data);
|
||||
void (*disconnect)(struct sock_client_context *client,
|
||||
void *private_data);
|
||||
|
@ -625,6 +625,7 @@ static struct eventd_client *client_find(struct eventd_context *ectx,
|
||||
}
|
||||
|
||||
static bool client_connect(struct sock_client_context *client_ctx,
|
||||
pid_t pid,
|
||||
void *private_data)
|
||||
{
|
||||
struct eventd_context *ectx = talloc_get_type_abort(
|
||||
|
@ -788,6 +788,7 @@ struct test5_server_state {
|
||||
};
|
||||
|
||||
static bool test5_connect(struct sock_client_context *client,
|
||||
pid_t pid,
|
||||
void *private_data)
|
||||
{
|
||||
struct test5_server_state *state =
|
||||
|
@ -450,7 +450,7 @@ def build(bld):
|
||||
bld.SAMBA_SUBSYSTEM('ctdb-server-util',
|
||||
source=bld.SUBDIR('common',
|
||||
'''sock_daemon.c'''),
|
||||
deps='''samba-util ctdb-util tevent-util
|
||||
deps='''samba-util ctdb-util ctdb-system tevent-util
|
||||
LIBASYNC_REQ replace talloc tevent''')
|
||||
|
||||
bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
|
||||
@ -800,7 +800,6 @@ def build(bld):
|
||||
'comm_client_test',
|
||||
'pidfile_test',
|
||||
'run_proc_test',
|
||||
'sock_daemon_test',
|
||||
'sock_io_test',
|
||||
'hash_count_test',
|
||||
'run_event_test',
|
||||
@ -837,6 +836,12 @@ def build(bld):
|
||||
deps='samba-util ctdb-system popt',
|
||||
install_path='${CTDB_TEST_LIBEXECDIR}')
|
||||
|
||||
bld.SAMBA_BINARY('sock_daemon_test',
|
||||
source='tests/src/sock_daemon_test.c',
|
||||
deps='''ctdb-system talloc tevent tevent-util
|
||||
LIBASYNC_REQ samba-util sys_rw''',
|
||||
install_path='${CTDB_TEST_LIBEXECDIR}')
|
||||
|
||||
bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
|
||||
source=bld.SUBDIR('tests/src',
|
||||
'protocol_common_basic.c'),
|
||||
|
Loading…
Reference in New Issue
Block a user