summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2012-08-27 15:12:36 +0200
committerMichael Adam <obnox@samba.org>2012-10-19 12:14:59 +0200
commit77906e7cdf4c40ab860af8bb42e2c5f3b5501e7d (patch)
treed6ccbe9f9fb897a3d4eaef08613d798468c041d8 /source3/smbd
parentb237bbc0d1afdfea3b6b6335854f92d6fe80a151 (diff)
downloadsamba-77906e7cdf4c40ab860af8bb42e2c5f3b5501e7d.tar.gz
samba-77906e7cdf4c40ab860af8bb42e2c5f3b5501e7d.tar.bz2
samba-77906e7cdf4c40ab860af8bb42e2c5f3b5501e7d.zip
s3:count_current_connections: do not clear orphaned entries from connections.tdb
This removes one of the last callers of connetions_forall. Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/connection.c28
-rw-r--r--source3/smbd/proto.h2
2 files changed, 9 insertions, 21 deletions
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index d334e8bdc1..ac2ab955d2 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -57,15 +57,14 @@ bool yield_connection(connection_struct *conn, const char *name)
struct count_stat {
int curr_connections;
const char *name;
- bool Clear;
+ bool verify;
};
/****************************************************************************
Count the entries belonging to a service in the connection db.
****************************************************************************/
-static int count_fn(struct db_record *rec,
- const struct connections_key *ckey,
+static int count_fn(const struct connections_key *ckey,
const struct connections_data *crec,
void *udp)
{
@@ -75,24 +74,13 @@ static int count_fn(struct db_record *rec,
return 0;
}
- /* If the pid was not found delete the entry from connections.tdb */
-
- if (cs->Clear && !process_exists(crec->pid) && (errno == ESRCH)) {
- NTSTATUS status;
- DEBUG(2,("pid %s doesn't exist - deleting connections %d [%s]\n",
- procid_str_static(&crec->pid), crec->cnum,
- crec->servicename));
-
- status = dbwrap_record_delete(rec);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("count_fn: tdb_delete failed with error %s\n",
- nt_errstr(status)));
- }
+ if (cs->verify && !process_exists(crec->pid)) {
return 0;
}
- if (strequal(crec->servicename, cs->name))
+ if (strequal(crec->servicename, cs->name)) {
cs->curr_connections++;
+ }
return 0;
}
@@ -101,14 +89,14 @@ static int count_fn(struct db_record *rec,
Claim an entry in the connections database.
****************************************************************************/
-int count_current_connections( const char *sharename, bool clear )
+int count_current_connections(const char *sharename, bool verify)
{
struct count_stat cs;
int ret;
cs.curr_connections = 0;
cs.name = sharename;
- cs.Clear = clear;
+ cs.verify = verify;
/*
* This has a race condition, but locking the chain before hand is worse
@@ -120,7 +108,7 @@ int count_current_connections( const char *sharename, bool clear )
* via ctdb, which is not possible without root.
*/
become_root();
- ret = connections_forall(count_fn, &cs);
+ ret = connections_forall_read(count_fn, &cs);
unbecome_root();
if (ret < 0) {
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index f1b359f917..a71547678f 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -161,7 +161,7 @@ void msg_force_tdis(struct messaging_context *msg,
/* The following definitions come from smbd/connection.c */
bool yield_connection(connection_struct *conn, const char *name);
-int count_current_connections( const char *sharename, bool clear );
+int count_current_connections(const char *sharename, bool verify);
bool connections_snum_used(struct smbd_server_connection *unused, int snum);
bool claim_connection(connection_struct *conn, const char *name);