#include "libcli/security/security.h"
#include "util_tdb.h"
#include <ccan/hash/hash.h>
+#include "lib/util/bitmap.h"
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < real_max_open_files))
increases the chance that the errant client will get an error rather
than causing corruption */
if (sconn->first_file == 0) {
- sconn->first_file = (sys_getpid() ^ (int)time(NULL));
+ sconn->first_file = (getpid() ^ (int)time(NULL));
sconn->first_file %= sconn->real_max_open_files;
}
sconn->first_file = (i+1) % (sconn->real_max_open_files);
bitmap_set(sconn->file_bmap, i);
- sconn->files_used += 1;
fsp->fnum = i + FILE_HANDLE_OFFSET;
SMB_ASSERT(fsp->fnum < 65536);
}
DLIST_ADD(sconn->files, fsp);
+ sconn->num_files += 1;
- DEBUG(5,("allocated file structure %d, fnum = %d (%d used)\n",
- i, fsp->fnum, sconn->files_used));
+ DEBUG(5,("allocated file structure %d, fnum = %d (%u used)\n",
+ i, fsp->fnum, (unsigned int)sconn->num_files));
if (req != NULL) {
req->chain_fsp = fsp;
struct smbd_server_connection *sconn = fsp->conn->sconn;
DLIST_REMOVE(sconn->files, fsp);
+ SMB_ASSERT(sconn->num_files > 0);
+ sconn->num_files--;
TALLOC_FREE(fsp->fake_file_handle);
}
if (fsp->notify) {
+ struct notify_context *notify_ctx =
+ fsp->conn->sconn->notify_ctx;
if (fsp->is_directory) {
- notify_remove_onelevel(fsp->conn->notify_ctx,
+ notify_remove_onelevel(notify_ctx,
&fsp->file_id, fsp);
}
- notify_remove(fsp->conn->notify_ctx, fsp);
+ notify_remove(notify_ctx, fsp);
TALLOC_FREE(fsp->notify);
}
TALLOC_FREE(fsp->update_write_time_event);
bitmap_clear(sconn->file_bmap, fsp->fnum - FILE_HANDLE_OFFSET);
- sconn->files_used--;
-
- DEBUG(5,("freed files structure %d (%d used)\n",
- fsp->fnum, sconn->files_used));
+ DEBUG(5,("freed files structure %d (%u used)\n",
+ fsp->fnum, (unsigned int)sconn->num_files));
fsp->conn->num_files_open--;
to->file_id = from->file_id;
to->initial_allocation_size = from->initial_allocation_size;
- to->mode = from->mode;
to->file_pid = from->file_pid;
to->vuid = from->vuid;
to->open_time = from->open_time;