#include "common/reqid.h"
#include "common/comm.h"
#include "common/pidfile.h"
+#include "common/system.h"
#include "common/sock_daemon.h"
struct sock_socket {
}
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);
* 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
*
*/
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);
}
static bool client_connect(struct sock_client_context *client_ctx,
+ pid_t pid,
void *private_data)
{
struct eventd_context *ectx = talloc_get_type_abort(
};
static bool test5_connect(struct sock_client_context *client,
+ pid_t pid,
void *private_data)
{
struct test5_server_state *state =
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',
'comm_client_test',
'pidfile_test',
'run_proc_test',
- 'sock_daemon_test',
'sock_io_test',
'hash_count_test',
'run_event_test',
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'),