diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-08-17 03:52:05 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-08-17 03:52:05 +0000 |
commit | 8978aae69699ccab76fdf95037948b1cc7e7c286 (patch) | |
tree | 19d2fdbc1da4d4353d226a81960f500ac06c0359 /source3/smbd/files.c | |
parent | f2d538a105a61ce6d2852700fc328e15ac158827 (diff) | |
download | samba-8978aae69699ccab76fdf95037948b1cc7e7c286.tar.gz samba-8978aae69699ccab76fdf95037948b1cc7e7c286.tar.xz samba-8978aae69699ccab76fdf95037948b1cc7e7c286.zip |
much cleaner chain pointer handling for both files and pipes.
the chain pointer is now stored as a static and is set whenever a
handle is created or extracted. This also makes the code less error
prone.
(This used to be commit 068a862982bea726e8d7b1b4065d510b9840a272)
Diffstat (limited to 'source3/smbd/files.c')
-rw-r--r-- | source3/smbd/files.c | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c index bc3ea880bfa..e66e53e6ed2 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -35,6 +35,10 @@ static struct bitmap *fd_bmap; static files_struct *Files; +/* a fsp to use when chaining */ +static files_struct *chain_fsp = NULL; + + /* * Indirection for file fd's. Needed as POSIX locking * is based on file/process, not fd/process. @@ -106,6 +110,8 @@ files_struct *file_new(void ) DEBUG(5,("allocated file structure %d (%d used)\n", i, files_used)); + + chain_fsp = fsp; return fsp; } @@ -238,21 +244,6 @@ void file_init(void) /**************************************************************************** -find a fsp given a fnum -****************************************************************************/ -files_struct *file_fsp(int fnum) -{ - files_struct *fsp; - - for (fsp=Files;fsp;fsp=fsp->next) { - if (fsp->fnum == fnum) return fsp; - } - - return NULL; -} - - -/**************************************************************************** close files open by a specified vuid ****************************************************************************/ void file_close_user(int vuid) @@ -375,5 +366,39 @@ void file_free(files_struct *fsp) information */ memset(fsp, 0, sizeof(*fsp)); + if (fsp == chain_fsp) chain_fsp = NULL; + free(fsp); } + + +/**************************************************************************** +get a fsp from a packet given the offset of a 16 bit fnum +****************************************************************************/ +files_struct *file_fsp(char *buf, int where) +{ + int fnum; + files_struct *fsp; + + if (chain_fsp) return chain_fsp; + + fnum = SVAL(buf, where); + + for (fsp=Files;fsp;fsp=fsp->next) { + if (fsp->fnum == fnum) { + chain_fsp = fsp; + return fsp; + } + } + + return NULL; +} + + +/**************************************************************************** +reset the chained fsp - done at the start of a packet reply +****************************************************************************/ +void file_chain_reset(void) +{ + chain_fsp = NULL; +} |