#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
-static int static_fake_fd = -1;
-static int pipe_fds[2];
-
struct smbXcli_conn;
struct smbXcli_req;
struct smbXcli_session;
};
struct smbXcli_req_state {
- bool do_splice;
struct tevent_context *ev;
struct smbXcli_conn *conn;
struct smbXcli_session *session; /* maybe NULL */
uint64_t encryption_session_id = 0;
uint64_t nonce_high = UINT64_MAX;
uint64_t nonce_low = UINT64_MAX;
- uint16_t opcode;
/*
* 1 for the nbt length, optional TRANSFORM
int hdr_iov;
size_t reqlen;
bool ret;
+ uint16_t opcode;
uint64_t avail;
uint16_t charge;
uint16_t credits;
state->conn->dispatch_incoming = smb2cli_conn_dispatch_incoming;
}
- opcode = SVAL(state->smb2.hdr, SMB2_HDR_OPCODE);
- if (opcode == SMB2_OP_WRITE) {
- num_iov--;
- state->do_splice = true;
- }
-
subreq = writev_send(state, state->ev, state->conn->outgoing,
state->conn->sock_fd, false, iov, num_iov);
if (subreq == NULL) {
struct smbXcli_req_state *state =
tevent_req_data(req,
struct smbXcli_req_state);
- ssize_t nwritten, tosend;
+ ssize_t nwritten;
int err;
state->write_req = NULL;
smbXcli_conn_disconnect(state->conn, status);
return;
}
-
- if (!state->do_splice) {
- return;
- }
-
- set_blocking(state->conn->sock_fd, true);
-
- tosend = state->smb2.dyn_len;
-
- while (tosend > 0) {
- ssize_t nread, towrite;
- off_t off = 0;
-
-// DBG_ERR("tosend [%zd]\n", tosend);
- nread = splice(static_fake_fd,
- &off,
- pipe_fds[1],
- NULL,
- MIN(tosend, 8*1024*1024),
- SPLICE_F_MOVE);
- if (nread == -1) {
- NTSTATUS status = map_nt_error_from_unix_common(err);
- DBG_ERR("splice failed %s\n", nt_errstr(status));
- smbXcli_conn_disconnect(state->conn, status);
- return;
- }
-
- towrite = nread;
- while (towrite > 0) {
-// DBG_ERR("towrite [%zd]\n", towrite);
- nwritten = splice(pipe_fds[0],
- NULL,
- state->conn->sock_fd,
- NULL,
- towrite,
- SPLICE_F_MOVE);
- if (nwritten == -1) {
- NTSTATUS status = map_nt_error_from_unix_common(err);
- DBG_ERR("splice failed %s\n", nt_errstr(status));
- smbXcli_conn_disconnect(state->conn, status);
- return;
- }
- towrite -= nwritten;
- }
- tosend -= nread;
- }
-
-// DBG_ERR("DONE\n");
- set_blocking(state->conn->sock_fd, false);
- state->do_splice = false;
}
static struct smbXcli_session* smbXcli_session_by_uid(struct smbXcli_conn *conn,
NTSTATUS status = NT_STATUS_NO_MEMORY;
bool ok;
- if (static_fake_fd == -1) {
- int ret;
-
-// static_fake_fd = open("/etc/hosts", O_RDONLY);
- static_fake_fd = open("/srv/samba/test/1gfile", O_RDONLY);
- if (static_fake_fd == -1) {
- status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
- goto fail;
- }
- ret = pipe(pipe_fds);
- if (ret != 0) {
- status = map_nt_error_from_unix_common(errno);
- goto fail;
- }
- ret = fcntl(pipe_fds[1], F_SETPIPE_SZ, 8*1024*1024);
- SMB_ASSERT(ret >= 8*1024*1024);
- }
-
if (smbXcli_conn_has_async_calls(conn)) {
/*
* Can't use sync call while an async call is in flight