Commit Graph

36 Commits

Author SHA1 Message Date
v9v
3917404668 Fix race condition in saving lock
Two consecutive calls to "date +%s" can return different values. Call "date" only once and reuse the result.
2019-07-09 10:46:56 +02:00
v9v
800488ca6f Replace flock with mkdir
flock is not supported on MacOS.

`mkdir` locks have a drawback: they are not cleaned up automatically. If the lock owner crashed before cleaning up the lock, the directory will stay in the filesystem and the lock will be never acquired by someone else. To avoid that, we create temporary locks (the lockdir name changes every 100 seconds). We grab two lock (N and N+1) to avoid the case where process A grabs lock N and process B grabs lock N+1 and both enter the critical section.
2019-07-08 15:58:42 +02:00
v9v
10e612d72c Handle missing flock
If flock is not installed, fall back to the thread-unsafe version.
2019-07-05 19:33:12 +02:00
v9v
721890d22f Fix race condition in autosave
Fixes the case where multiple tmux sessions call auto-save at the same time, which occasionally results in multiple instances of save_all() running in parallel and causing issues like #3 and tmux-plugins/tmux-resurrect#294.

The sequence in main() is:
1. Check enough_time_since_last_run_passed
2. Save
3. Update last_save_timestamp.

The race here is:
* process A finishes step 1 and is busy with step 2. The timestamp is not updated yet.
* process B comes to step 1, sees the old timestamp and proceeds to step 2, too.
2019-07-04 20:21:02 +02:00
6ed3078f47 Make user systemd dir if it doesn't exist 2017-10-14 11:25:00 -04:00
438e50d54f replaced hardcoded home directory in Systemd ExecStop with HOME variable 2016-01-23 09:39:06 -06:00
3ed7db77f2 Re-named tmux variable to maintain consistency. 2016-01-09 16:28:48 +01:00
328d070787 Removing debug opts. 2016-01-09 16:28:47 +01:00
53853713eb Swiched default command to new-session -d
- need the -d to start the server correctly as it does not have an emulator to
  attach the session to.
2016-01-09 16:28:45 +01:00
fb52a173b8 Switched to forking to better represent server nature of tmux.
- Also added RestartSec option to fix minor issues with restarts trying to
  start the server before it had fully shutdown.
2016-01-09 16:28:44 +01:00
b495ea2912 set default tmux start command to new-session 2016-01-09 16:28:44 +01:00
65d627af30 Removed automatic restore as screwed pane organisation.
- this caused issues with the restore missing some processes and putting
  others in the wrong place.

- I think this may need some work with the tmux-resurrect plugin to fix if auto
  restore is to be used.
2016-01-09 16:28:41 +01:00
a9cbf68546 Added defaults for tmux start command variable. 2016-01-09 16:28:40 +01:00
05a4a827e5 initial stab at systemd support for tmux-continuum 2016-01-09 16:28:39 +01:00
d0cebe0804 Continuum status 2015-11-29 18:36:13 +01:00
186c2b9e9b Move all docs to 'docs/' dir 2015-10-08 18:44:32 +02:00
d6ac017d1d Bugfix: do not count tmux source-file as tmux process
Do not count `tmux source-file .tmux.conf` as a tmux process when checking if
other tmux server is running.

Previously, this caused interpolation command not to be inserted into
`status-right` because `tmux source-file` was falsely detected as another tmux
server.
2015-03-14 15:55:00 +01:00
bdc47273d3 Properly quote scripts 2015-02-20 15:48:36 +01:00
20a83738c0 Rename the plugin to 'tmux-continuum' 2015-02-20 13:38:09 +01:00
e384ce1040 Document tmux multi-server behavior in the readme 2015-02-20 02:59:15 +01:00
fb641881c2 Don't start auto-saving if another tmux server is running 2015-02-20 02:05:58 +01:00
ab3e951cfa Do not auto-restore tmux env if there's another tmux server already running 2015-02-20 00:34:01 +01:00
4939459f33 Improve 'tmux auto start' readme 2015-02-19 22:58:10 +01:00
1acd25cff2 Change restore script function name 2015-02-19 13:53:23 +01:00
061f024c0a Bugfixes for Terminal.app and iTerm tmux start scripts 2015-02-19 13:43:41 +01:00
57226cfb97 Docs for tmux auto start feature 2015-02-18 16:52:14 +01:00
b82aa1d343 Bugfixes for launchd plist on OS X 2015-02-18 16:24:01 +01:00
dd82e770bd Enable customizing 'tmux auto start' for OS X 2015-02-18 15:14:11 +01:00
61ff39584a Enable easy 'tmux auto start' configuration 2015-02-17 17:13:48 +01:00
99658eda98 Enable auto load 2015-02-15 14:43:09 +01:00
1588471ed0 More bugfixing 2015-02-12 15:52:10 +01:00
aa01161701 Disable autosave when interval is set to 0 2015-02-12 15:42:18 +01:00
099cc256f3 Initializer script checks tmux version 2015-02-12 03:37:34 +01:00
2e40ecf4d0 Don't start continuous saving right after tmux is started 2015-02-12 01:31:56 +01:00
5ca7656df0 Run the save script in the background 2015-02-11 16:01:20 +01:00
42ca2d4454 First working version 2015-02-11 15:43:37 +01:00