From: "Martin Ågren" <martin.agren@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH 1/5] sequencer: make lockfiles non-static
Date: Tue, 27 Feb 2018 22:30:09 +0100 [thread overview]
Message-ID: <4572a84cfdcb1897b67c271a9d06ca38802a2352.1519763396.git.martin.agren@gmail.com> (raw)
In-Reply-To: <cover.1519763396.git.martin.agren@gmail.com>
After 076aa2cbd (tempfile: auto-allocate tempfiles on heap, 2017-09-05),
we can have lockfiles on the stack.
One of these functions fails to always roll back the lock. That will be
fixed in the next commit.
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
sequencer.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 4d3f60594c..90807c4559 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -290,7 +290,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)
static int write_message(const void *buf, size_t len, const char *filename,
int append_eol)
{
- static struct lock_file msg_file;
+ struct lock_file msg_file = LOCK_INIT;
int msg_fd = hold_lock_file_for_update(&msg_file, filename, 0);
if (msg_fd < 0)
@@ -436,7 +436,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
struct tree *result, *next_tree, *base_tree, *head_tree;
int clean;
char **xopt;
- static struct lock_file index_lock;
+ struct lock_file index_lock = LOCK_INIT;
if (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR) < 0)
return -1;
@@ -1183,7 +1183,7 @@ static int prepare_revs(struct replay_opts *opts)
static int read_and_refresh_cache(struct replay_opts *opts)
{
- static struct lock_file index_lock;
+ struct lock_file index_lock = LOCK_INIT;
int index_fd = hold_locked_index(&index_lock, 0);
if (read_index_preload(&the_index, NULL) < 0) {
rollback_lock_file(&index_lock);
@@ -1577,7 +1577,7 @@ static int create_seq_dir(void)
static int save_head(const char *head)
{
- static struct lock_file head_lock;
+ struct lock_file head_lock = LOCK_INIT;
struct strbuf buf = STRBUF_INIT;
int fd;
ssize_t written;
@@ -1702,7 +1702,7 @@ int sequencer_rollback(struct replay_opts *opts)
static int save_todo(struct todo_list *todo_list, struct replay_opts *opts)
{
- static struct lock_file todo_lock;
+ struct lock_file todo_lock = LOCK_INIT;
const char *todo_path = get_todo_path(opts);
int next = todo_list->current, offset, fd;
--
2.16.2.246.ga4ee44448f
next prev parent reply other threads:[~2018-02-27 21:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 21:30 [PATCH 0/5] roll back locks in various code paths Martin Ågren
2018-02-27 21:30 ` Martin Ågren [this message]
2018-02-27 21:30 ` [PATCH 2/5] sequencer: always roll back lock in `do_recursive_merge()` Martin Ågren
2018-02-27 21:44 ` Jeff King
2018-02-27 22:08 ` Martin Ågren
2018-02-27 22:15 ` Jeff King
2018-02-27 21:30 ` [PATCH 3/5] merge-recursive: always roll back lock in `merge_recursive_generic()` Martin Ågren
2018-02-28 11:02 ` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 0/5] roll back locks in various code paths Martin Ågren
2018-02-28 19:07 ` [PATCH v2 1/5] sequencer: make lockfiles non-static Martin Ågren
2018-02-28 19:07 ` [PATCH v2 2/5] sequencer: always roll back lock in `do_recursive_merge()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 3/5] merge-recursive: always roll back lock in `merge_recursive_generic()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 4/5] merge: always roll back lock in `checkout_fast_forward()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 5/5] sequencer: do not roll back lockfile unnecessarily Martin Ågren
2018-02-28 19:58 ` [PATCH v2 0/5] roll back locks in various code paths Martin Ågren
2018-02-28 23:20 ` Junio C Hamano
2018-03-01 6:18 ` Martin Ågren
2018-03-01 7:41 ` Jeff King
2018-03-01 19:24 ` Junio C Hamano
2018-03-01 20:40 ` Martin Ågren
2018-03-02 10:49 ` Jeff King
2018-03-01 7:38 ` Jeff King
2018-02-27 21:30 ` [PATCH 4/5] merge: always roll back lock in `checkout_fast_forward()` Martin Ågren
2018-02-27 21:30 ` [PATCH 5/5] sequencer: do not roll back lockfile unnecessarily Martin Ågren
2018-02-27 21:47 ` [PATCH 0/5] roll back locks in various code paths Jeff King
2018-02-27 23:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4572a84cfdcb1897b67c271a9d06ca38802a2352.1519763396.git.martin.agren@gmail.com \
--to=martin.agren@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).