summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srvsvc
diff options
context:
space:
mode:
authorShekhar Amlekar <samlekar@in.ibm.com>2014-03-25 17:06:18 +0530
committerJeremy Allison <jra@samba.org>2014-04-03 21:19:43 +0200
commitfc4845f481a01e7e12dd9f4de3a8a434234c339c (patch)
tree963df7d054043687343c85857a37d612d95848d5 /source3/rpc_server/srvsvc
parentfe6ec8c111879e4130a6ba4675dccca0ffa2e573 (diff)
downloadsamba-fc4845f481a01e7e12dd9f4de3a8a434234c339c.tar.gz
s3: rpc_server/srvsvc: count open files in NetConnEnum
Signed-off-by: Shekhar Amlekar <samlekar@in.ibm.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 3 21:19:43 CEST 2014 on sn-devel-104
Diffstat (limited to 'source3/rpc_server/srvsvc')
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c58
1 files changed, 47 insertions, 11 deletions
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 8a7fc2f03f5..39d5e05bfec 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -1157,29 +1157,65 @@ static WERROR init_srv_conn_info_1(const char *name,
return WERR_OK;
}
+ /*
+ * We know num_entries must be positive, due to
+ * the check resume_handle >= *total_entries above.
+ */
+
+ num_entries = *total_entries - resume_handle;
ZERO_STRUCTP(ctr1);
- for (; resume_handle < *total_entries; resume_handle++) {
+ ctr1->array = talloc_zero_array(talloc_tos(),
+ struct srvsvc_NetConnInfo1,
+ num_entries);
- ctr1->array = talloc_realloc(talloc_tos(),
- ctr1->array,
- struct srvsvc_NetConnInfo1,
- num_entries+1);
- if (!ctr1->array) {
- return WERR_NOMEM;
- }
+ W_ERROR_HAVE_NO_MEMORY(ctr1->array);
+
+ for (num_entries = 0; resume_handle < *total_entries;
+ num_entries++, resume_handle++) {
ctr1->array[num_entries].conn_id = *total_entries;
ctr1->array[num_entries].conn_type = 0x3;
- ctr1->array[num_entries].num_open = 1;
+
+ /*
+ * if these are connections to a share, we are going to
+ * compute the opens on them later. If it's for the server,
+ * it's unimplemented.
+ */
+
+ if (!share_name) {
+ ctr1->array[num_entries].num_open = 1;
+ }
+
ctr1->array[num_entries].num_users = 1;
ctr1->array[num_entries].conn_time = 3;
ctr1->array[num_entries].user = "dummy_user";
ctr1->array[num_entries].share = "IPC$";
+ }
+
+ /* now compute open files on the share connections */
+
+ if (share_name) {
+
+ /*
+ * the locking tdb, which has the open files information,
+ * does not store share name or share (service) number, but
+ * just the share path. So, we can compute open files only
+ * on the share path. If more than one shares are defined
+ * on a share path, open files on all of them are included
+ * in the count.
+ *
+ * To have the correct behavior in case multiple shares
+ * are defined on the same path, changes to tdb records
+ * would be required. That would be lot more effort, so
+ * this seems a good stopgap fix.
+ */
+
+ count_share_opens(ctr1->array, svrid_arr,
+ lp_path(talloc_tos(), snum),
+ num_entries, *total_entries);
- /* move on to creating next connection */
- num_entries++;
}
ctr1->count = num_entries;