[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-test-2690-g030bef7
Volker Lendecke
vl at samba.org
Sat Mar 1 08:34:36 GMT 2008
The branch, v3-2-test has been updated
via 030bef7f22f7a73466204b7860f397dbca9f2ab0 (commit)
via 5f53a62be8a21b8d92ac44b18d202882500356e8 (commit)
via 5ab1cfda500de07ff3c712442ab2fc74eecc8886 (commit)
via ac301fada257e2d3b50148109a3d44fa1421b0b4 (commit)
via 413695e8d0d8232a9c35e693f9a4a8009418ede4 (commit)
from 956bc602062825493e1c357e2388fee1e5514b50 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 030bef7f22f7a73466204b7860f397dbca9f2ab0
Author: Volker Lendecke <vl at samba.org>
Date: Sat Mar 1 09:26:43 2008 +0100
Revert "Add basic infrastructure for general async requests"
This reverts commit ae254cb61f4b9331755848c47ebc34e90dd80390.
commit 5f53a62be8a21b8d92ac44b18d202882500356e8
Author: Volker Lendecke <vl at samba.org>
Date: Sat Mar 1 09:26:27 2008 +0100
Revert "Add infrastructure to support async SMB requests"
This reverts commit f5356825698a02df2d400b51dd95d1f857c83e81.
commit 5ab1cfda500de07ff3c712442ab2fc74eecc8886
Author: Volker Lendecke <vl at samba.org>
Date: Sat Mar 1 09:26:18 2008 +0100
Revert "Add async cli_pull support"
This reverts commit 844a163458c7585e4306a21ffdae5d08e03d6e4d.
commit ac301fada257e2d3b50148109a3d44fa1421b0b4
Author: Volker Lendecke <vl at samba.org>
Date: Sat Mar 1 09:26:06 2008 +0100
Revert "Convert cli_read to use cli_pull"
This reverts commit 719527f55e88f0c5fdceda5c807475aba299c79f.
commit 413695e8d0d8232a9c35e693f9a4a8009418ede4
Author: Volker Lendecke <vl at samba.org>
Date: Sat Mar 1 09:25:52 2008 +0100
Revert "Fix warnings"
This reverts commit 9a966e5593ae4474014aec5d8c68c489ac8ce0c9.
-----------------------------------------------------------------------
Summary of changes:
source/Makefile.in | 4 +-
source/client/client.c | 45 +++--
source/include/async_req.h | 89 -------
source/include/async_smb.h | 62 -----
source/include/client.h | 30 ---
source/include/includes.h | 2 -
source/lib/async_req.c | 68 ------
source/libsmb/async_smb.c | 483 ---------------------------------------
source/libsmb/clireadwrite.c | 519 ++++++++++--------------------------------
9 files changed, 152 insertions(+), 1150 deletions(-)
delete mode 100644 source/include/async_req.h
delete mode 100644 source/include/async_smb.h
delete mode 100644 source/lib/async_req.c
delete mode 100644 source/libsmb/async_smb.c
Changeset truncated at 500 lines:
diff --git a/source/Makefile.in b/source/Makefile.in
index d01abc9..3840498 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -326,7 +326,7 @@ LIB_WITHOUT_PROTO_OBJ = $(LIBSAMBAUTIL_OBJ) \
lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \
lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o lib/talloc_stack.o \
lib/interfaces.o lib/rbtree.o lib/memcache.o \
- lib/util_transfer_file.o lib/async_req.o
+ lib/util_transfer_file.o
LIB_WITH_PROTO_OBJ = $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \
lib/interface.o lib/md4.o \
@@ -415,7 +415,7 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
libsmb/clistr.o libsmb/cliquota.o libsmb/clifsinfo.o libsmb/clidfs.o \
libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \
libsmb/clioplock.o $(ERRORMAP_OBJ) libsmb/clirap2.o \
- libsmb/smb_seal.o $(DOSERR_OBJ) libsmb/async_smb.o \
+ libsmb/smb_seal.o $(DOSERR_OBJ) \
$(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(LIBNMB_OBJ)
RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o rpc_client/cli_srvsvc.o
diff --git a/source/client/client.c b/source/client/client.c
index c97f622..f7ed33a 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -964,30 +964,22 @@ static int cmd_echo(void)
Get a file from rname to lname
****************************************************************************/
-static NTSTATUS writefile_sink(char *buf, size_t n, void *priv)
-{
- int *pfd = (int *)priv;
- if (writefile(*pfd, buf, n) == -1) {
- return map_nt_error_from_unix(errno);
- }
- return NT_STATUS_OK;
-}
-
static int do_get(const char *rname, const char *lname_in, bool reget)
{
TALLOC_CTX *ctx = talloc_tos();
int handle = 0, fnum;
bool newhandle = false;
+ char *data = NULL;
struct timeval tp_start;
+ int read_size = io_bufsize;
uint16 attr;
SMB_OFF_T size;
off_t start = 0;
- ssize_t nread = 0;
+ off_t nread = 0;
int rc = 0;
struct cli_state *targetcli = NULL;
char *targetname = NULL;
char *lname = NULL;
- NTSTATUS status;
lname = talloc_strdup(ctx, lname_in);
if (!lname) {
@@ -1046,15 +1038,36 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
DEBUG(1,("getting file %s of size %.0f as %s ",
rname, (double)size, lname));
- status = cli_pull(targetcli, fnum, start, size, 1024*1024,
- writefile_sink, (void *)&handle, &nread);
- if (!NT_STATUS_IS_OK(status)) {
- d_fprintf(stderr, "parallel_read returned %s\n",
- nt_errstr(status));
+ if(!(data = (char *)SMB_MALLOC(read_size))) {
+ d_printf("malloc fail for size %d\n", read_size);
cli_close(targetcli, fnum);
return 1;
}
+ while (1) {
+ int n = cli_read(targetcli, fnum, data, nread + start, read_size);
+
+ if (n <= 0)
+ break;
+
+ if (writefile(handle,data, n) != n) {
+ d_printf("Error writing local file\n");
+ rc = 1;
+ break;
+ }
+
+ nread += n;
+ }
+
+ if (nread + start < size) {
+ DEBUG (0, ("Short read when getting file %s. Only got %ld bytes.\n",
+ rname, (long)nread));
+
+ rc = 1;
+ }
+
+ SAFE_FREE(data);
+
if (!cli_close(targetcli, fnum)) {
d_printf("Error %s closing remote file\n",cli_errstr(cli));
rc = 1;
diff --git a/source/include/async_req.h b/source/include/async_req.h
deleted file mode 100644
index 6df5360..0000000
--- a/source/include/async_req.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Infrastructure for async requests
- Copyright (C) Volker Lendecke 2008
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __ASYNC_REQ_H__
-#define __ASYNC_REQ_H__
-
-#include "includes.h"
-
-/*
- * An async request moves between the following 4 states.
- */
-enum async_req_state {
- ASYNC_REQ_INIT, /* we are creating the request */
- ASYNC_REQ_IN_PROGRESS, /* we are waiting the request to complete */
- ASYNC_REQ_DONE, /* the request is finished */
- ASYNC_REQ_ERROR }; /* an error has occured */
-
-struct async_req {
- /* the external state - will be queried by the caller */
- enum async_req_state state;
-
- /* a private pointer for use by the async function implementation */
- void *private_data;
-
- /* print yourself, for debugging purposes */
- char *(*print)(TALLOC_CTX *mem_ctx, struct async_req *);
-
- /* status code when finished */
- NTSTATUS status;
-
- /* the event context we are using */
- struct event_context *event_ctx;
-
- /* information on what to do on completion */
- struct {
- void (*fn)(struct async_req *);
- void *priv;
- } async;
-};
-
-/*
- * Print an async_req structure for debugging purposes
- */
-char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req);
-
-/*
- * Create an async request
- */
-struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev);
-
-/*
- * An async request has successfully finished, invoke the callback
- */
-void async_req_done(struct async_req *req);
-
-/*
- * An async request has seen an error, invoke the callback
- */
-void async_req_error(struct async_req *req, NTSTATUS status);
-
-/*
- * Convenience helper to easily check alloc failure within a callback.
- *
- * Call pattern would be
- * p = talloc(mem_ctx, bla);
- * if (async_req_nomem(p, req)) {
- * return;
- * }
- *
- */
-bool async_req_nomem(const void *p, struct async_req *req);
-
-#endif
diff --git a/source/include/async_smb.h b/source/include/async_smb.h
deleted file mode 100644
index 19408be..0000000
--- a/source/include/async_smb.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Infrastructure for async SMB client requests
- Copyright (C) Volker Lendecke 2008
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/*
- * Create a fresh async smb request
- */
-
-struct async_req *cli_request_new(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint8_t num_words, size_t num_bytes,
- struct cli_request **preq);
-
-/*
- * Convenience function to get the SMB part out of an async_req
- */
-
-struct cli_request *cli_request_get(struct async_req *req);
-
-/*
- * Fetch an error out of a NBT packet
- */
-
-NTSTATUS cli_pull_error(char *buf);
-
-/*
- * Compatibility helper for the sync APIs: Fake NTSTATUS in cli->inbuf
- */
-
-void cli_set_error(struct cli_state *cli, NTSTATUS status);
-
-/*
- * Create a temporary event context for use in the sync helper functions
- */
-
-struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx,
- struct cli_state *cli);
-
-/*
- * Attach an event context permanently to a cli_struct
- */
-
-NTSTATUS cli_add_event_ctx(struct cli_state *cli,
- struct event_context *event_ctx);
diff --git a/source/include/client.h b/source/include/client.h
index 52dc513..d29a2e7 100644
--- a/source/include/client.h
+++ b/source/include/client.h
@@ -192,36 +192,6 @@ struct cli_state {
bool force_dos_errors;
bool case_sensitive; /* False by default. */
-
- struct event_context *event_ctx;
- struct fd_event *fd_event;
- char *evt_inbuf;
-
- struct cli_request *outstanding_requests;
-};
-
-struct cli_request {
- struct cli_request *prev, *next;
- struct async_req *async;
-
- struct cli_state *cli;
-
- struct smb_trans_enc_state *enc_state;
-
- uint16_t mid;
-
- char *outbuf;
- size_t sent;
- char *inbuf;
-
- union {
- struct {
- off_t ofs;
- size_t size;
- ssize_t received;
- uint8_t *rcvbuf;
- } read;
- } data;
};
typedef struct file_info {
diff --git a/source/include/includes.h b/source/include/includes.h
index 36c71d7..c54afd8 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -723,8 +723,6 @@ typedef char fstring[FSTRING_LEN];
#include "ctdbd_conn.h"
#include "talloc_stack.h"
#include "memcache.h"
-#include "async_req.h"
-#include "async_smb.h"
/* used in net.c */
struct functable {
diff --git a/source/lib/async_req.c b/source/lib/async_req.c
deleted file mode 100644
index 01154ca..0000000
--- a/source/lib/async_req.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Infrastructure for async requests
- Copyright (C) Volker Lendecke 2008
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req)
-{
- return talloc_asprintf(mem_ctx, "async_req: state=%d, status=%s, "
- "priv=%s", req->state, nt_errstr(req->status),
- talloc_get_name(req->private_data));
-}
-
-struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev)
-{
- struct async_req *result;
-
- result = TALLOC_ZERO_P(mem_ctx, struct async_req);
- if (result == NULL) {
- return NULL;
- }
- result->state = ASYNC_REQ_IN_PROGRESS;
- result->event_ctx = ev;
- result->print = async_req_print;
- return result;
-}
-
-void async_req_done(struct async_req *req)
-{
- req->status = NT_STATUS_OK;
- req->state = ASYNC_REQ_DONE;
- if (req->async.fn != NULL) {
- req->async.fn(req);
- }
-}
-
-void async_req_error(struct async_req *req, NTSTATUS status)
-{
- req->status = status;
- req->state = ASYNC_REQ_ERROR;
- if (req->async.fn != NULL) {
- req->async.fn(req);
- }
-}
-
-bool async_req_nomem(const void *p, struct async_req *req)
-{
- if (p != NULL) {
- return false;
- }
- async_req_error(req, NT_STATUS_NO_MEMORY);
- return true;
-}
diff --git a/source/libsmb/async_smb.c b/source/libsmb/async_smb.c
deleted file mode 100644
index 21bcd5b..0000000
--- a/source/libsmb/async_smb.c
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Infrastructure for async SMB client requests
- Copyright (C) Volker Lendecke 2008
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/*
- * Fetch an error out of a NBT packet
- */
-
-NTSTATUS cli_pull_error(char *buf)
-{
- uint32_t flags2 = SVAL(buf, smb_flg2);
-
- if (flags2 & FLAGS2_32_BIT_ERROR_CODES) {
- return NT_STATUS(IVAL(buf, smb_rcls));
- }
-
- return NT_STATUS_DOS(CVAL(buf, smb_rcls), SVAL(buf,smb_err));
-}
-
-/*
- * Compatibility helper for the sync APIs: Fake NTSTATUS in cli->inbuf
- */
-
-void cli_set_error(struct cli_state *cli, NTSTATUS status)
-{
- uint32_t flags2 = SVAL(cli->inbuf, smb_flg2);
-
- if (NT_STATUS_IS_DOS(status)) {
- SSVAL(cli->inbuf, smb_flg2,
- flags2 & ~FLAGS2_32_BIT_ERROR_CODES);
- SCVAL(cli->inbuf, smb_rcls, NT_STATUS_DOS_CLASS(status));
- SSVAL(cli->inbuf, smb_err, NT_STATUS_DOS_CODE(status));
- return;
- }
-
- SSVAL(cli->inbuf, smb_flg2, flags2 | FLAGS2_32_BIT_ERROR_CODES);
- SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status));
- return;
-}
-
-/*
- * Allocate a new mid
- */
-
-static uint16_t cli_new_mid(struct cli_state *cli)
-{
- uint16_t result;
- struct cli_request *req;
-
- while (true) {
- result = cli->mid++;
- if (result == 0) {
- continue;
- }
-
- for (req = cli->outstanding_requests; req; req = req->next) {
- if (result == req->mid) {
- break;
- }
- }
-
- if (req == NULL) {
- return result;
- }
- }
-}
-
-static char *cli_request_print(TALLOC_CTX *mem_ctx, struct async_req *req)
-{
- char *result = async_req_print(mem_ctx, req);
- struct cli_request *cli_req = cli_request_get(req);
-
- if (result == NULL) {
- return NULL;
- }
-
- return talloc_asprintf_append_buffer(
- result, "mid=%d\n", cli_req->mid);
-}
-
-static int cli_request_destructor(struct cli_request *req)
-{
- if (req->enc_state != NULL) {
- common_free_enc_buffer(req->enc_state, req->outbuf);
--
Samba Shared Repository
More information about the samba-cvs
mailing list