summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-03-26 11:32:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:59:18 -0500
commit316269a07523a421755158540d2f4e22fa312866 (patch)
treea0569bf07ccae14b213ab9bd63f8a44240427ffe
parente095d9e32ac4770ce8da5f96f143c46a1f803309 (diff)
downloadsamba-316269a07523a421755158540d2f4e22fa312866.tar.gz
samba-316269a07523a421755158540d2f4e22fa312866.tar.bz2
samba-316269a07523a421755158540d2f4e22fa312866.zip
r14739: keep the last request time for the smbsrv_connection,
smbsrv_session and smbsrv_tcon for management tools metze (This used to be commit 2c87f210e9e68de42dc45ca6532f3f33f4b6ce95)
-rw-r--r--source4/librpc/idl/irpc.idl2
-rw-r--r--source4/smb_server/management.c2
-rw-r--r--source4/smb_server/session.c4
-rw-r--r--source4/smb_server/smb/receive.c11
-rw-r--r--source4/smb_server/smb2/receive.c9
-rw-r--r--source4/smb_server/smb_server.c2
-rw-r--r--source4/smb_server/smb_server.h13
-rw-r--r--source4/smb_server/tcon.c16
8 files changed, 46 insertions, 13 deletions
diff --git a/source4/librpc/idl/irpc.idl b/source4/librpc/idl/irpc.idl
index f83816f2f2..5614608bd7 100644
--- a/source4/librpc/idl/irpc.idl
+++ b/source4/librpc/idl/irpc.idl
@@ -92,6 +92,7 @@
astring client_ip;
NTTIME connect_time;
NTTIME auth_time;
+ NTTIME last_use_time;
} smbsrv_session_info;
typedef struct {
@@ -104,6 +105,7 @@
astring share_name;
astring client_ip;
NTTIME connect_time;
+ NTTIME last_use_time;
} smbsrv_tcon_info;
typedef struct {
diff --git a/source4/smb_server/management.c b/source4/smb_server/management.c
index b55a9f7d57..17258cf6c6 100644
--- a/source4/smb_server/management.c
+++ b/source4/smb_server/management.c
@@ -63,6 +63,7 @@ static NTSTATUS smbsrv_session_information(struct irpc_message *msg,
info->connect_time = timeval_to_nttime(&sess->statistics.connect_time);
info->auth_time = timeval_to_nttime(&sess->statistics.auth_time);
+ info->last_use_time= timeval_to_nttime(&sess->statistics.last_request_time);
i++;
}
@@ -102,6 +103,7 @@ static NTSTATUS smbsrv_tcon_information(struct irpc_message *msg,
info->tid = tcon->tid;
info->share_name = tcon->share_name;
info->connect_time = timeval_to_nttime(&tcon->statistics.connect_time);
+ info->last_use_time= timeval_to_nttime(&tcon->statistics.last_request_time);
i++;
}
diff --git a/source4/smb_server/session.c b/source4/smb_server/session.c
index 967c02bfc9..7274a7a716 100644
--- a/source4/smb_server/session.c
+++ b/source4/smb_server/session.c
@@ -47,7 +47,8 @@ NTSTATUS smbsrv_init_sessions(struct smbsrv_connection *smb_conn, uint64_t limit
* Find the session structure assoicated with a VUID
* (not one from an in-progress session setup)
*/
-struct smbsrv_session *smbsrv_session_find(struct smbsrv_connection *smb_conn, uint64_t vuid)
+struct smbsrv_session *smbsrv_session_find(struct smbsrv_connection *smb_conn,
+ uint64_t vuid, struct timeval request_time)
{
void *p;
struct smbsrv_session *sess;
@@ -62,6 +63,7 @@ struct smbsrv_session *smbsrv_session_find(struct smbsrv_connection *smb_conn, u
/* only return a finished session */
sess = talloc_get_type(p, struct smbsrv_session);
if (sess && sess->session_info) {
+ sess->statistics.last_request_time = request_time;
return sess;
}
diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c
index d049475dd2..aff5e88285 100644
--- a/source4/smb_server/smb/receive.c
+++ b/source4/smb_server/smb/receive.c
@@ -71,8 +71,11 @@ NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
{
struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection);
struct smbsrv_request *req;
+ struct timeval cur_time = timeval_current();
uint8_t command;
+ smb_conn->statistics.last_request_time = cur_time;
+
/* see if its a special NBT packet */
if (CVAL(blob.data, 0) != 0) {
req = smbsrv_init_request(smb_conn);
@@ -82,7 +85,7 @@ NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
req->in.buffer = talloc_steal(req, blob.data);
req->in.size = blob.length;
- req->request_time = timeval_current();
+ req->request_time = cur_time;
smbsrv_reply_special(req);
return NT_STATUS_OK;
@@ -107,7 +110,7 @@ NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
req->in.buffer = talloc_steal(req, blob.data);
req->in.size = blob.length;
- req->request_time = timeval_current();
+ req->request_time = cur_time;
req->chained_fnum = -1;
req->in.allocated = req->in.size;
req->in.hdr = req->in.buffer + NBT_HDR_SIZE;
@@ -471,7 +474,7 @@ static void switch_message(int type, struct smbsrv_request *req)
flags = smb_messages[type].flags;
- req->tcon = smbsrv_smb_tcon_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
+ req->tcon = smbsrv_smb_tcon_find(smb_conn, SVAL(req->in.hdr,HDR_TID), req->request_time);
if (!req->session) {
/* setup the user context for this request if it
@@ -484,7 +487,7 @@ static void switch_message(int type, struct smbsrv_request *req)
req->session = req->tcon->sec_share.session;
}
} else {
- req->session = smbsrv_session_find(req->smb_conn, SVAL(req->in.hdr,HDR_UID));
+ req->session = smbsrv_session_find(req->smb_conn, SVAL(req->in.hdr,HDR_UID), req->request_time);
}
}
diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c
index ef67d29c51..6781b6ce65 100644
--- a/source4/smb_server/smb2/receive.c
+++ b/source4/smb_server/smb2/receive.c
@@ -128,8 +128,8 @@ static NTSTATUS smb2srv_reply(struct smb2srv_request *req)
tid = IVAL(req->in.hdr, SMB2_HDR_TID);
uid = BVAL(req->in.hdr, SMB2_HDR_UID);
- req->session = smbsrv_session_find(req->smb_conn, uid);
- req->tcon = smbsrv_smb2_tcon_find(req->session, tid);
+ req->session = smbsrv_session_find(req->smb_conn, uid, req->request_time);
+ req->tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time);
errno = 0;
@@ -241,10 +241,13 @@ NTSTATUS smbsrv_recv_smb2_request(void *private, DATA_BLOB blob)
{
struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection);
struct smb2srv_request *req;
+ struct timeval cur_time = timeval_current();
uint32_t protocol_version;
uint16_t buffer_code;
uint32_t dynamic_size;
+ smb_conn->statistics.last_request_time = cur_time;
+
/* see if its a special NBT packet */
if (CVAL(blob.data,0) != 0) {
DEBUG(2,("Special NBT packet on SMB2 connection"));
@@ -271,7 +274,7 @@ NTSTATUS smbsrv_recv_smb2_request(void *private, DATA_BLOB blob)
req->in.buffer = talloc_steal(req, blob.data);
req->in.size = blob.length;
- req->request_time = timeval_current();
+ req->request_time = cur_time;
req->in.allocated = req->in.size;
req->in.hdr = req->in.buffer+ NBT_HDR_SIZE;
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index f47063f945..927609226b 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -151,6 +151,8 @@ static void smbsrv_accept(struct stream_connection *conn)
irpc_add_name(conn->msg_ctx, "smb_server");
+ smb_conn->statistics.connect_time = timeval_current();
+
smbsrv_management_init(smb_conn);
}
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 8efe7730df..12b12692f3 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -84,6 +84,8 @@ struct smbsrv_session {
struct timeval connect_time;
/* the time when the session setup was finished */
struct timeval auth_time;
+ /* the time when the last request comes in */
+ struct timeval last_request_time;
} statistics;
};
@@ -124,7 +126,10 @@ struct smbsrv_tcon {
/* some statictics for the management tools */
struct {
+ /* the time when the tree connect started */
struct timeval connect_time;
+ /* the time when the last request comes in */
+ struct timeval last_request_time;
} statistics;
};
@@ -297,6 +302,14 @@ struct smbsrv_connection {
enum security_types security;
BOOL nt_status_support;
} config;
+
+ /* some statictics for the management tools */
+ struct {
+ /* the time when the client connects */
+ struct timeval connect_time;
+ /* the time when the last request comes in */
+ struct timeval last_request_time;
+ } statistics;
};
#include "smb_server/smb_server_proto.h"
diff --git a/source4/smb_server/tcon.c b/source4/smb_server/tcon.c
index 95e42d6537..8b100d11ce 100644
--- a/source4/smb_server/tcon.c
+++ b/source4/smb_server/tcon.c
@@ -58,7 +58,8 @@ NTSTATUS smbsrv_smb2_init_tcons(struct smbsrv_session *smb_sess)
/****************************************************************************
find a tcon given a tid for SMB
****************************************************************************/
-static struct smbsrv_tcon *smbsrv_tcon_find(struct smbsrv_tcons_context *tcons_ctx, uint32_t tid)
+static struct smbsrv_tcon *smbsrv_tcon_find(struct smbsrv_tcons_context *tcons_ctx,
+ uint32_t tid, struct timeval request_time)
{
void *p;
struct smbsrv_tcon *tcon;
@@ -71,19 +72,24 @@ static struct smbsrv_tcon *smbsrv_tcon_find(struct smbsrv_tcons_context *tcons_c
if (!p) return NULL;
tcon = talloc_get_type(p, struct smbsrv_tcon);
+ if (!tcon) return NULL;
+
+ tcon->statistics.last_request_time = request_time;
return tcon;
}
-struct smbsrv_tcon *smbsrv_smb_tcon_find(struct smbsrv_connection *smb_conn, uint32_t tid)
+struct smbsrv_tcon *smbsrv_smb_tcon_find(struct smbsrv_connection *smb_conn,
+ uint32_t tid, struct timeval request_time)
{
- return smbsrv_tcon_find(&smb_conn->smb_tcons, tid);
+ return smbsrv_tcon_find(&smb_conn->smb_tcons, tid, request_time);
}
-struct smbsrv_tcon *smbsrv_smb2_tcon_find(struct smbsrv_session *smb_sess, uint32_t tid)
+struct smbsrv_tcon *smbsrv_smb2_tcon_find(struct smbsrv_session *smb_sess,
+ uint32_t tid, struct timeval request_time)
{
if (!smb_sess) return NULL;
- return smbsrv_tcon_find(&smb_sess->smb2_tcons, tid);
+ return smbsrv_tcon_find(&smb_sess->smb2_tcons, tid, request_time);
}
/*