Skip to content

Commit 7ca9c6b

Browse files
committed
Cygwin: flock.cc: rename i_all to __i_all, improve inode_t comments
Accessing i_all should always be performed via the i_all_lf pointer, never directly. Add leading underscores to support this notion. Improve inode_t comments a bit so it's hopefully clearer what all the members are doing. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> (cherry picked from commit 008f8bf)
1 parent 8179425 commit 7ca9c6b

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

winsup/cygwin/flock.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ class lockf_t
279279
void del_lock_obj (HANDLE fhdl, bool signal = false);
280280
};
281281

282-
/* Number of lockf_t structs which fit in the temporary buffer. */
282+
/* Max. number of lockf_t structs in the __i_all buffer so that an inode_t
283+
fits into a 64K cygheap chunk. */
283284
#define MAX_LOCKF_CNT ((intptr_t)((NT_MAX_PATH * sizeof (WCHAR)) \
284285
/ sizeof (lockf_t)) - 1)
285286

@@ -290,19 +291,22 @@ class inode_t
290291

291292
public:
292293
LIST_ENTRY (inode_t) i_next;
293-
lockf_t *i_lockf; /* List of locks of this process. */
294-
/* list of all locks for this file. */
295-
lockf_t *i_all_lf;
294+
lockf_t *i_lockf; /* List of locks held by this process. */
295+
lockf_t *i_all_lf; /* List of all locks on this file. Always
296+
points to __i_all below. The indirection
297+
is required by list handling. */
296298

297299
dev_t i_dev; /* Device ID */
298300
ino_t i_ino; /* inode number */
299301

300302
private:
301-
HANDLE i_dir;
302-
HANDLE i_mtx;
303+
HANDLE i_dir; /* Directory in NT namespace holding symlinks
304+
representing locks on this file. */
305+
HANDLE i_mtx; /* Mutex controlling access to locks on
306+
this file. */
303307
uint32_t i_cnt; /* # of threads referencing this instance. */
304-
uint32_t i_lock_cnt; /* # of locks for this file */
305-
lockf_t i_all[MAX_LOCKF_CNT];
308+
uint32_t i_lock_cnt; /* # of locks on this file */
309+
lockf_t __i_all[MAX_LOCKF_CNT];
306310

307311
public:
308312
inode_t (dev_t dev, ino_t ino);
@@ -511,7 +515,7 @@ inode_t::get (dev_t dev, ino_t ino, bool create_if_missing, bool lock)
511515
}
512516

513517
inode_t::inode_t (dev_t dev, ino_t ino)
514-
: i_lockf (NULL), i_all_lf (i_all), i_dev (dev), i_ino (ino), i_cnt (0L),
518+
: i_lockf (NULL), i_all_lf (__i_all), i_dev (dev), i_ino (ino), i_cnt (0L),
515519
i_lock_cnt (0)
516520
{
517521
HANDLE parent_dir;

0 commit comments

Comments
 (0)