summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-09-24 20:46:15 +0200
committerJeremy Allison <jra@samba.org>2014-10-31 03:47:40 +0100
commit9010bbeb00264f4476c3be7d2e8c8420c695cfbb (patch)
treec03448a0c323c99a1d5f55106a7bd5372929ea57
parent48926b761975a7d9cb6daf30d64d6a4f0a34f38a (diff)
downloadsamba-9010bbeb00264f4476c3be7d2e8c8420c695cfbb.tar.gz
samba-9010bbeb00264f4476c3be7d2e8c8420c695cfbb.tar.xz
samba-9010bbeb00264f4476c3be7d2e8c8420c695cfbb.zip
s3:locking: allow early return for share_entry_forall()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source3/locking/proto.h4
-rw-r--r--source3/locking/share_mode_lock.c23
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c46
-rw-r--r--source3/utils/status.c12
4 files changed, 49 insertions, 36 deletions
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index a5c46c8140..44f3ba13e0 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -194,8 +194,8 @@ int share_mode_forall(int (*fn)(struct file_id fid,
const struct share_mode_data *data,
void *private_data),
void *private_data);
-int share_entry_forall(void (*fn)(const struct share_mode_entry *, const char *,
- const char *, void *),
+int share_entry_forall(int (*fn)(const struct share_mode_entry *, const char *,
+ const char *, void *),
void *private_data);
bool share_mode_cleanup_disconnected(struct file_id id,
uint64_t open_persistent_id);
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index c2f34022ae..da16d1acf0 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -522,9 +522,9 @@ int share_mode_forall(int (*fn)(struct file_id fid,
}
struct share_entry_forall_state {
- void (*fn)(const struct share_mode_entry *e,
- const char *service_path, const char *base_name,
- void *private_data);
+ int (*fn)(const struct share_mode_entry *e,
+ const char *service_path, const char *base_name,
+ void *private_data);
void *private_data;
};
@@ -536,9 +536,14 @@ static int share_entry_traverse_fn(struct file_id fid,
uint32_t i;
for (i=0; i<data->num_share_modes; i++) {
- state->fn(&data->share_modes[i],
- data->servicepath, data->base_name,
- state->private_data);
+ int ret;
+
+ ret = state->fn(&data->share_modes[i],
+ data->servicepath, data->base_name,
+ state->private_data);
+ if (ret != 0) {
+ return ret;
+ }
}
return 0;
@@ -549,9 +554,9 @@ static int share_entry_traverse_fn(struct file_id fid,
share mode system.
********************************************************************/
-int share_entry_forall(void (*fn)(const struct share_mode_entry *,
- const char *, const char *, void *),
- void *private_data)
+int share_entry_forall(int (*fn)(const struct share_mode_entry *,
+ const char *, const char *, void *),
+ void *private_data)
{
struct share_entry_forall_state state = {
.fn = fn, .private_data = private_data };
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index d2f05f30cc..eaa70e784d 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -79,9 +79,9 @@ struct share_conn_stat {
/*******************************************************************
********************************************************************/
-static void enum_file_fn( const struct share_mode_entry *e,
- const char *sharepath, const char *fname,
- void *private_data )
+static int enum_file_fn(const struct share_mode_entry *e,
+ const char *sharepath, const char *fname,
+ void *private_data)
{
struct file_enum_count *fenum =
(struct file_enum_count *)private_data;
@@ -98,21 +98,21 @@ static void enum_file_fn( const struct share_mode_entry *e,
/* If the pid was not found delete the entry from connections.tdb */
if ( !process_exists(e->pid) ) {
- return;
+ return 0;
}
username = uidtoname(e->uid);
if ((fenum->username != NULL)
&& !strequal(username, fenum->username)) {
- return;
+ return 0;
}
f = talloc_realloc(fenum->ctx, fenum->ctr3->array,
struct srvsvc_NetFileInfo3, i+1);
if ( !f ) {
DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
- return;
+ return 0;
}
fenum->ctr3->array = f;
@@ -133,7 +133,7 @@ static void enum_file_fn( const struct share_mode_entry *e,
sharepath, fname );
}
if (!fullpath) {
- return;
+ return 0;
}
string_replace( fullpath, '/', '\\' );
@@ -150,6 +150,8 @@ static void enum_file_fn( const struct share_mode_entry *e,
fenum->ctr3->array[i].user = username;
fenum->ctr3->count++;
+
+ return 0;
}
/*******************************************************************
@@ -826,9 +828,9 @@ static WERROR init_srv_sess_info_0(struct pipes_struct *p,
* find out the session on which this file is open and bump up its count
**********************************************************************/
-static void count_sess_files_fn(const struct share_mode_entry *e,
- const char *sharepath, const char *fname,
- void *data)
+static int count_sess_files_fn(const struct share_mode_entry *e,
+ const char *sharepath, const char *fname,
+ void *data)
{
struct sess_file_info *info = data;
uint32_t rh = info->resume_handle;
@@ -846,9 +848,10 @@ static void count_sess_files_fn(const struct share_mode_entry *e,
serverid_equal(&e->pid, &sess->pid)) {
info->ctr->array[i].num_open++;
- return;
+ return 0;
}
}
+ return 0;
}
/*******************************************************************
@@ -950,9 +953,9 @@ static WERROR init_srv_sess_info_1(struct pipes_struct *p,
find the share connection on which this open exists.
********************************************************************/
-static void share_file_fn(const struct share_mode_entry *e,
- const char *sharepath, const char *fname,
- void *data)
+static int share_file_fn(const struct share_mode_entry *e,
+ const char *sharepath, const char *fname,
+ void *data)
{
struct share_file_stat *sfs = data;
uint32_t i;
@@ -962,10 +965,11 @@ static void share_file_fn(const struct share_mode_entry *e,
for (i=0; i < sfs->resp_entries; i++) {
if (serverid_equal(&e->pid, &sfs->svrid_arr[offset + i])) {
sfs->netconn_arr[i].num_open ++;
- return;
+ return 0;
}
}
}
+ return 0;
}
/*******************************************************************
@@ -2690,9 +2694,9 @@ struct enum_file_close_state {
struct messaging_context *msg_ctx;
};
-static void enum_file_close_fn( const struct share_mode_entry *e,
- const char *sharepath, const char *fname,
- void *private_data )
+static int enum_file_close_fn(const struct share_mode_entry *e,
+ const char *sharepath, const char *fname,
+ void *private_data)
{
char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
struct enum_file_close_state *state =
@@ -2700,11 +2704,11 @@ static void enum_file_close_fn( const struct share_mode_entry *e,
uint32_t fid = (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id);
if (fid != state->r->in.fid) {
- return; /* Not this file. */
+ return 0; /* Not this file. */
}
if (!process_exists(e->pid) ) {
- return;
+ return 0;
}
/* Ok - send the close message. */
@@ -2718,6 +2722,8 @@ static void enum_file_close_fn( const struct share_mode_entry *e,
messaging_send_buf(state->msg_ctx,
e->pid, MSG_SMB_CLOSE_FILE,
(uint8 *)msg, sizeof(msg)));
+
+ return 0;
}
/********************************************************************
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 2c850bb591..b58981329b 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -115,10 +115,10 @@ static bool Ucrit_addPid( struct server_id pid )
return True;
}
-static void print_share_mode(const struct share_mode_entry *e,
- const char *sharepath,
- const char *fname,
- void *dummy)
+static int print_share_mode(const struct share_mode_entry *e,
+ const char *sharepath,
+ const char *fname,
+ void *dummy)
{
static int count;
@@ -135,7 +135,7 @@ static void print_share_mode(const struct share_mode_entry *e,
if (do_checks && !serverid_exists(&e->pid)) {
/* the process for this entry does not exist any more */
- return;
+ return 0;
}
if (Ucrit_checkPid(e->pid)) {
@@ -183,6 +183,8 @@ static void print_share_mode(const struct share_mode_entry *e,
d_printf(" %s %s %s",sharepath, fname, time_to_asc((time_t)e->time.tv_sec));
}
+
+ return 0;
}
static void print_brl(struct file_id id,