Delete a connection record.
****************************************************************************/
-BOOL yield_connection(connection_struct *conn, const char *name)
+bool yield_connection(connection_struct *conn, const char *name)
{
struct db_record *rec;
NTSTATUS status;
pid_t mypid;
int curr_connections;
const char *name;
- BOOL Clear;
+ bool Clear;
};
/****************************************************************************
}
return 0;
}
-
- if (cs->name) {
- /* We are counting all the connections to a given share. */
- if (strequal(crec->servicename, cs->name)) {
- cs->curr_connections++;
- }
- } else {
- /* We are counting all the connections. Static registrations
- * like the lpq backgroud process and the smbd daemon process
- * have a cnum of -1, so won't be counted here.
- */
+
+ if (strequal(crec->servicename, cs->name))
cs->curr_connections++;
- }
return 0;
}
Claim an entry in the connections database.
****************************************************************************/
-int count_current_connections( const char *sharename, BOOL clear )
+int count_current_connections( const char *sharename, bool clear )
{
struct count_stat cs;
if (connections_forall(count_fn, &cs) == -1) {
DEBUG(0,("count_current_connections: traverse of "
"connections.tdb failed\n"));
- DEBUGADD(0, ("count_current_connections: connection count of %d might not be accurate",
- cs.curr_connections));
+ return False;
}
- /* If the traverse failed part-way through, we at least return
- * as many connections as we had already counted. If it failed
- * right at the start, we will return 0, which is about all we
- * can do anywway.
- */
-
return cs.curr_connections;
}
-/****************************************************************************
- Count the number of connections open across all shares.
-****************************************************************************/
-
-int count_all_current_connections(void)
-{
- return count_current_connections(NULL, True /* clear stale entries */);
-}
-
/****************************************************************************
Claim an entry in the connections database.
****************************************************************************/
-BOOL claim_connection(connection_struct *conn, const char *name,
+bool claim_connection(connection_struct *conn, const char *name,
uint32 msg_flags)
{
struct db_record *rec;
struct connections_data crec;
TDB_DATA dbuf;
NTSTATUS status;
+ char addr[INET6_ADDRSTRLEN];
DEBUG(5,("claiming [%s]\n", name));
crec.bcast_msg_flags = msg_flags;
strlcpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine));
- strlcpy(crec.addr,conn?conn->client_address:client_addr(),
+ strlcpy(crec.addr,conn?conn->client_address:
+ client_addr(get_client_fd(),addr,sizeof(addr)),
sizeof(crec.addr));
dbuf.dptr = (uint8 *)&crec;
return True;
}
-BOOL register_message_flags(BOOL doreg, uint32 msg_flags)
+bool register_message_flags(bool doreg, uint32 msg_flags)
{
struct db_record *rec;
struct connections_data *pcrec;
doreg ? "adding" : "removing",
(unsigned int)msg_flags ));
- if (!(rec = connections_fetch_entry(NULL, NULL, NULL))) {
+ if (!(rec = connections_fetch_entry(NULL, NULL, ""))) {
DEBUG(0, ("connections_fetch_entry failed\n"));
return False;
}
status = rec->store(rec, rec->value, TDB_REPLACE);
- TALLOC_FREE(rec);
-
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("register_message_flags: tdb_store failed: %s.\n",
nt_errstr(status)));
+ TALLOC_FREE(rec);
return False;
}
DEBUG(10,("register_message_flags: new flags 0x%x\n",
(unsigned int)pcrec->bcast_msg_flags ));
+ TALLOC_FREE(rec);
+
return True;
}
/*********************************************************************
*********************************************************************/
-BOOL store_pipe_opendb( smb_np_struct *p )
+bool store_pipe_opendb( smb_np_struct *p )
{
struct db_record *dbrec;
struct pipe_open_rec *prec;
TDB_DATA *key;
TDB_DATA data;
- BOOL ret = False;
+ bool ret = False;
if ( (prec = TALLOC_P( NULL, struct pipe_open_rec)) == NULL ) {
DEBUG(0,("store_pipe_opendb: talloc failed!\n"));
/*********************************************************************
*********************************************************************/
-BOOL delete_pipe_opendb( smb_np_struct *p )
+bool delete_pipe_opendb( smb_np_struct *p )
{
struct db_record *dbrec;
struct pipe_open_rec *prec;
TDB_DATA *key;
- BOOL ret = False;
+ bool ret = False;
if ( (prec = TALLOC_P( NULL, struct pipe_open_rec)) == NULL ) {
DEBUG(0,("store_pipe_opendb: talloc failed!\n"));