Patch: Elm ME+ 2.5 PLalpha54 -> Elm ME+ 2.5 PLalpha60 [4/13] (4/5)
From
Kari Hurtta@21:1/5 to
All on Thu Nov 24 20:25:47 2022
[continued from previous message]
- "Grab_the_file: fcntl: %s (errno %d)\n",
- strerror(err),err));
- return ((err == EACCES) || (err == EAGAIN))
- ? FLOCKING_RETRY
- : FLOCKING_FAIL ;
- }
- }
- #endif
-
- #ifdef COMPILE_FLOCK_LOCKING
- if (dt_flag_is_set(flags,lock_flock_flag)) {
- DPRINT(Debug,12,(&Debug,
- "Grab_the_file: Use flock locking\n"));
-
- if (flock (flock_fd, LOCK_NB | LOCK_EX)) {
- int err = errno;
- int retcode;
- DPRINT(Debug,12,(&Debug,
- "Grab_the_file: flock: %s (errno %d)\n",
- strerror(err),err));
- retcode = ((err == EWOULDBLOCK) || (err == EAGAIN))
- ? FLOCKING_RETRY
- : FLOCKING_FAIL ;
-
- #ifdef COMPILE_FCNTL_LOCKING
- if (dt_flag_is_set(flags,lock_fcntl_flag)) {
- lock_info.l_type = F_UNLCK;
- lock_info.l_whence = 0;
- lock_info.l_start = 0;
- lock_info.l_len = 0;
-
- /*
- * Just unlock it because we did not succeed with the
- * flock()-style locking. Never mind the return value.
- * It was our own lock anyway if we ever got this far.
- */
- fcntl (flock_fd, F_SETLK, &lock_info);
- }
- #endif
- return retcode;
- }
- }
- #endif
DPRINT(Debug,12,(&Debug,
! "Grab_the_file=FLOCKING_OK\n"));
! return FLOCKING_OK;
}
! int Release_the_file(flock_fd,flags)
int flock_fd;
struct dt_flags_info *flags;
{
! #ifdef COMPILE_FCNTL_LOCKING
! struct flock lock_info;
! #endif
!
! int fcntlret = 0,
! flockret = 0,
! fcntlerr = 0,
! flockerr = 0;
!
if (&folder_locking == flags) {
DPRINT(Debug,13,(&Debug, "Release_the_file: using folder-locking\n"));
}
--- 117,152 ----
DPRINT(Debug,13,(&Debug, "Grab_the_file: using mailhome-locking\n"));
}
! ret = filelock_fd(flock_fd,FLOCKING_exclusive,
! flags,NULL /* no filename */,FLOCKING_non_block,
! &err);
DPRINT(Debug,12,(&Debug,
! "Grab_the_file=%d",ret));
! switch (ret) {
! case FLOCKING_FAIL: DPRINT(Debug,12,(&Debug," FLOCKING_FAIL")); break; ! case FLOCKING_OK: DPRINT(Debug,12,(&Debug," FLOCKING_OK")); break; ! case FLOCKING_RETRY: DPRINT(Debug,12,(&Debug," FLOCKING_RETRY")); break; ! case FLOCKING_UNSUPPORTED: DPRINT(Debug,12,(&Debug," FLOCKING_UNSUPPORTED")); break;
! }
! if (err) {
! DPRINT(Debug,12,(&Debug,", error %s (errno %d)",
! strerror(err),err));
! errno = err;
! }
! DPRINT(Debug,12,(&Debug,"\n"));
!
! return ret;
}
! enum FLOCKING_status Release_the_file(flock_fd,flags)
int flock_fd;
struct dt_flags_info *flags;
{
! int err = 0;
! enum FLOCKING_s