git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] run-command: make async_exit usage consistent

From
RGRose via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 8, 2023, 14:33 UTC
Message-ID
<pull.1423.v2.git.git.1673188382186.gitgitgadget@gmail.com>
In-Reply-To
<pull.1423.git.git.1672768772484.gitgitgadget@gmail.com>
From: Seija Kijin <doremylover123@gmail.com>

Use async_exit instead of pthread_exit, and make async_exit inline.

Functions were reordered so that this would compile.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    run-command: make async_exit usage consistent
    
    Use async_exit instead of pthread_exit, and make async_exit inline.
    
    Finally, make the parameter an unsigned int, because the Win32 API uses
    unsigned int, and for other platforms, we cast to void anyway.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1423%2FAtariDreams%2Fconsistency-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1423/AtariDreams/consistency-v2
Pull-Request: https://github.com/git/git/pull/1423
Range-diff vs v1:
 1:  b5f29059d79 ! 1:  d4cf19107ed run-command: make async_exit usage consistent
     @@ Commit message
          Functions were reordered
          so that this would compile.
      
     -    Luckily, the order remains consistent.
     -
          Signed-off-by: Seija Kijin <doremylover123@gmail.com>
      
       ## run-command.c ##
 run-command.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/run-command.c b/run-command.c
index 756f1839aab..e1eab4cb69b 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1030,6 +1030,18 @@ static void *run_thread(void *data)
 	return (void *)ret;
 }
 
+int in_async(void)
+{
+	if (!main_thread_set)
+		return 0; /* no asyncs started yet */
+	return !pthread_equal(main_thread, pthread_self());
+}
+
+static inline void NORETURN async_exit(int code)
+{
+	pthread_exit((void *)(intptr_t)code);
+}
+
 static NORETURN void die_async(const char *err, va_list params)
 {
 	report_fn die_message_fn = get_die_message_routine();
@@ -1042,7 +1054,7 @@ static NORETURN void die_async(const char *err, va_list params)
 			close(async->proc_in);
 		if (async->proc_out >= 0)
 			close(async->proc_out);
-		pthread_exit((void *)128);
+		async_exit(128);
 	}
 
 	exit(128);
@@ -1055,18 +1067,6 @@ static int async_die_is_recursing(void)
 	return ret != NULL;
 }
 
-int in_async(void)
-{
-	if (!main_thread_set)
-		return 0; /* no asyncs started yet */
-	return !pthread_equal(main_thread, pthread_self());
-}
-
-static void NORETURN async_exit(int code)
-{
-	pthread_exit((void *)(intptr_t)code);
-}
-
 #else
 
 static struct {
@@ -1112,7 +1112,7 @@ int in_async(void)
 	return process_is_async;
 }
 
-static void NORETURN async_exit(int code)
+static inline void NORETURN async_exit(int code)
 {
 	exit(code);
 }

base-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1
-- 
gitgitgadget
Previous: Rose via GitGitGadgetNext: Rose via GitGitGadget
Message 2 of 3 in “run-command: make async_exit usage consistent”
  1. run-command: make async_exit usage consistentRose via GitGitGadget, Jan 3, 2023
  2. run-command: make async_exit usage consistentRose via GitGitGadget, Jan 8, 2023
  3. run-command: remove async_exitRose via GitGitGadget, Jan 8, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.