talloc_reparent(state, l, c);
tevent_req_defer_callback(req, state->ev);
- tevent_req_done(req);
+ tevent_req_notify_callback(req);
return;
}
}
if (tevent_req_is_nterror(req, &status)) {
+ DEBUG(0,("%s:%s: here...[%s]\n", __location__, __func__, nt_errstr(status)));
tevent_req_received(req);
-DEBUG(0,("%s:%s: here...\n", __location__, __func__));
return status;
}
/*
* We don't call tevent_req_received()
- * because the caller can lease this alive
+ * because the caller can leave this alive
* in order to consume more connections
*/
if (l->ready == NULL) {
DLIST_REMOVE(l->ready, c);
c->l = NULL;
+ if (l->ready != NULL) {
+ tevent_req_defer_callback(req, state->ev);
+ tevent_req_notify_callback(req);
+ }
+
*fd = c->sock.tmp_fd;
c->sock.tmp_fd = -1;
if (laddr != NULL) {
#include "lib/util/samba_util.h"
#include "lib/util/blocking.h"
#include "lib/util/util_net.h"
+#include "lib/util/msghdr.h"
#ifdef SMB_TRANSPORT_ENABLE_RDMA
#include <rdma/rdma_cma_abi.h>
return NT_STATUS_OK;
}
+static NTSTATUS smbd_direct_daemon_send_fd(
+ struct smb_direct_daemon_state *daemon_state, int fd);
+
static void smbd_direct_daemon_listen_accept_done(struct tevent_req *subreq)
{
struct smb_direct_daemon_conn *conn = tevent_req_callback_data(subreq,
fd, print_sockaddr(laddr_buf, sizeof(laddr_buf), &laddr),
print_sockaddr(raddr_buf, sizeof(raddr_buf), &raddr));
- TALLOC_FREE(c);
+ status = smbd_direct_daemon_send_fd(daemon_state, fd);
close(fd);
}
+static NTSTATUS smbd_direct_daemon_send_fd(
+ struct smb_direct_daemon_state *daemon_state, int fd)
+{
+ struct msghdr msg;
+ struct iovec iov;
+ ssize_t fdlen;
+ int ret;
+ char iobuf[1];
+
+ iov = (struct iovec) {
+ .iov_base = &iobuf[0],
+ .iov_len = 1
+ };
+
+ msg = (struct msghdr) {
+ .msg_iov = &iov,
+ .msg_iovlen = 1
+ };
+
+ fdlen = msghdr_prep_fds(&msg, NULL, 0, &fd, 1);
+ if (fdlen == -1) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ {
+ uint8_t buf[fdlen];
+ msghdr_prep_fds(&msg, buf, fdlen, &fd, 1);
+
+ ret = sendmsg(daemon_state->listening_conn->conn_fd, &msg, 0);
+ if (ret == -1) {
+ DBG_ERR("BUGBUGBUG: this should be an async func\n");
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
static NTSTATUS smbd_direct_daemon_dispatch(struct smb_direct_daemon_conn *conn,
DATA_BLOB in_data,
DATA_BLOB *out_data)