• src/xpdev/filewrap.c

    From Deuc¿@VERT to Git commit to main/sbbs/master on Saturday, February 10, 2024 22:28:17
    https://gitlab.synchro.net/main/sbbs/-/commit/1f2f00b04b06f3e9d595bb2f
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Fix misleading comment
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Sunday, November 10, 2024 22:12:10
    https://gitlab.synchro.net/main/sbbs/-/commit/09f98728aecf1e7049d04168
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Get rid of the fcntl() usage in sopen()

    You can't lock a file on a Samba share via both fcntl() and flock() (the interact/collide).

    This code was in a !BSD block which means they guy that wrote/committed
    it wasn't using it either.
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Sunday, November 10, 2024 23:52:50
    https://gitlab.synchro.net/main/sbbs/-/commit/043feff892a3a206ed12e9cf
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Log a build warning if building for Linux without OFD lock support

    OFD locks are needed on Linux for appropriate multi-threaded shared file
    access (using fcntl record locks to prevent corruption), so log a warning if building for Linux without that support.

    lock() now mimics DOS/Windows again: the result lock is an "all access" lock regardless of what mode the file was open in. I'm not sure why this change was made (commit 11b73134563ce26), but I don't think it was necessary or appropriate (though I can't think of any immediate negative effects). At minimum it makes the code a little more understandable and eliminates an
    extra call to fcntl().
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Monday, November 11, 2024 01:13:16
    https://gitlab.synchro.net/main/sbbs/-/commit/d9d86d6a36f9133ed5b08189
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Revert the lock() change in commit 043feff8

    So this change is needed or else fcntl() will fail with errno=BADF if trying
    to write-lock a file that was opened read-only. Oh well. Added a comment explaining the rationale.
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Monday, December 02, 2024 20:29:33
    https://gitlab.synchro.net/main/sbbs/-/commit/77a771095c72121700e96ca2
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Don't use flock() in sopen() since it ends up using non-OFD fcntl() locks

    When OFD locks are available, that's what we should be using.
    Otherwise, we suffer the horrible behavior of POSIX file/region locks and
    a subsequent open/close of the file releases any/all locks on it.

    This is currently in an !BSD block, which appears to include macOS, but
    macOS *does* support OFD locks, so I'll be fixing that here shortly.
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Wednesday, December 04, 2024 18:48:28
    https://gitlab.synchro.net/main/sbbs/-/commit/6000b7606167fe18b73d63a7
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Clean up the OFD check/decision, make use of fcntl() locks easier to opt-in
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Thursday, December 05, 2024 17:10:10
    https://gitlab.synchro.net/main/sbbs/-/commit/c88cfcedf21c1c9dd6bbeb97
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Fix typo in Windows version of xp_lockfile()
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Thursday, December 05, 2024 17:16:34
    https://gitlab.synchro.net/main/sbbs/-/commit/c2f0aded1f86373335282c2a
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Move the xp_lockfile() into a compile block that includes Borland
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on ChromeOS)@VERT to Git commit to main/sbbs/master on Thursday, December 05, 2024 17:32:00
    https://gitlab.synchro.net/main/sbbs/-/commit/f28db0b28d5f5d46c8801526
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Need locking.h here for Borland C++ build
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on ChromeOS)@VERT to Git commit to main/sbbs/master on Thursday, December 05, 2024 17:43:13
    https://gitlab.synchro.net/main/sbbs/-/commit/f421f1bb88f20536b2af3d4c
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    In Boland's io.h, this function is just called locking()
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on ChromeOS)@VERT to Git commit to main/sbbs/master on Thursday, December 05, 2024 17:53:11
    https://gitlab.synchro.net/main/sbbs/-/commit/fc17319e92c4b7af30123d57
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Appears MinGW requires '_locking' Borland requires 'locking' and MSVC does both ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Saturday, August 08, 2026 18:05:04
    https://gitlab.synchro.net/main/sbbs/-/commit/7384ba6569de8ffbf0720f2d
    Modified Files:
    src/xpdev/filewrap.c
    Log Message:
    Close descriptors with closefrom() rather than close_range()

    closefrom() exists on the BSDs, Solaris and glibc 2.34 and later, where close_range() is a Linux syscall this code was reaching for directly. On
    glibc, closefrom() is implemented in terms of close_range() anyway, so
    calling it gets the better mechanism where there is one and a working
    fallback where there isn't, without this file having to know which.

    Keeping one descriptor no longer needs a range API at all: close everything above it in a single call, and walk the few below it. That loop is bounded by the kept descriptor rather than by the process descriptor limit, which can be very large. Platforms with neither call (macOS) still consult sysconf(_SC_OPEN_MAX).

    Also spell the first descriptor to close as STDERR_FILENO + 1 rather than 3.

    Suggested by Deuce.

    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net