struct tevent_fd *listen_fde;
struct sdd_listen_params params;
+
+ /*
+ * Pointer to the connection in listening state. There can be
+ * only one and it will receive all new SMB-D connections.
+ */
+ struct smb_direct_daemon_conn *listening_conn;
};
struct smb_direct_daemon_conn {
/*
* A connection in the listening state can only be used with
- * smb_direct_accept() to accept a connection fd.
+ * smb_direct_accept() to accept a connection fd and can't be
+ * used for messaging.
*/
bool listening;
};
struct sdd_packet_listen_request *listen_request,
struct sdd_packet_listen_response *listen_response)
{
+ if (conn->daemon_state->listening_conn != NULL) {
+ /* There can be only one... */
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
conn->daemon_state->params = listen_request->params;
conn->listening = true;
+ conn->daemon_state->listening_conn = conn;
+
+ ok = smb_direct_daemon_rdma_listen(conn->daemon_state);
+ if (!ok) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
listen_response->status = 0;
return NT_STATUS_OK;
static void smbd_direct_daemon_conn_handler(struct tevent_req *read_req);
static void smbd_direct_daemon_conn_handler_next(struct tevent_req *write_req);
+static void smb_direct_daemon_conn_cleanup(struct tevent_req *req,
+ enum tevent_req_state req_state)
+{
+ struct smb_direct_daemon_conn *conn = tevent_req_data(
+ req, struct smb_direct_daemon_conn);
+
+ if (conn->fd != -1) {
+ close(conn->fd);
+ conn->fd = -1;
+ }
+
+ if (conn->daemon_state->conn == conn) {
+ conn->daemon_state->conn = NULL;
+ }
+}
+
/**
* @brief Handle an already accepted connection
*
tevent_req_post(req, ev);
}
tevent_req_set_callback(subreq, smbd_direct_daemon_conn_handler, req);
-
+ tevent_req_set_cleanup_fn(subreq, smb_direct_daemon_conn_cleanup);
return req;
}