From: "Jeff Hostetler via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Jeff Hostetler <jeffhost@microsoft.com>,
Jeff Hostetler <jeffhost@microsoft.com>
Subject: [PATCH 2/8] unix-socket: simplify initialization of unix_stream_listen_opts
Date: Thu, 04 Mar 2021 20:17:21 +0000 [thread overview]
Message-ID: <6ef867bf37d366071d5f0f101e7430d859f529b5.1614889047.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.893.git.1614889047.gitgitgadget@gmail.com>
From: Jeff Hostetler <jeffhost@microsoft.com>
Change the public initialization of `struct unix_stream_listen_opts`
to be all zeroes. Hide the default values for the timeout and backlog
values inside `unix-socket.c`.
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
unix-socket.c | 11 +++++++++--
unix-socket.h | 7 ++-----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/unix-socket.c b/unix-socket.c
index 647bbde37f97..c9ea1de43bd2 100644
--- a/unix-socket.c
+++ b/unix-socket.c
@@ -2,6 +2,9 @@
#include "lockfile.h"
#include "unix-socket.h"
+#define DEFAULT_UNIX_STREAM_LISTEN_TIMEOUT (100)
+#define DEFAULT_UNIX_STREAM_LISTEN_BACKLOG (5)
+
static int chdir_len(const char *orig, int len)
{
char *path = xmemdupz(orig, len);
@@ -165,14 +168,18 @@ struct unix_stream_server_socket *unix_stream_server__listen_with_lock(
const struct unix_stream_listen_opts *opts)
{
struct lock_file lock = LOCK_INIT;
+ long timeout;
int fd_socket;
struct unix_stream_server_socket *server_socket;
+ timeout = opts->timeout_ms;
+ if (opts->timeout_ms <= 0)
+ timeout = DEFAULT_UNIX_STREAM_LISTEN_TIMEOUT;
+
/*
* Create a lock at "<path>.lock" if we can.
*/
- if (hold_lock_file_for_update_timeout(&lock, path, 0,
- opts->timeout_ms) < 0) {
+ if (hold_lock_file_for_update_timeout(&lock, path, 0, timeout) < 0) {
error_errno(_("could not lock listener socket '%s'"), path);
return NULL;
}
diff --git a/unix-socket.h b/unix-socket.h
index 8faf5b692f90..bec925ee0213 100644
--- a/unix-socket.h
+++ b/unix-socket.h
@@ -7,13 +7,10 @@ struct unix_stream_listen_opts {
unsigned int disallow_chdir:1;
};
-#define DEFAULT_UNIX_STREAM_LISTEN_TIMEOUT (100)
-#define DEFAULT_UNIX_STREAM_LISTEN_BACKLOG (5)
-
#define UNIX_STREAM_LISTEN_OPTS_INIT \
{ \
- .timeout_ms = DEFAULT_UNIX_STREAM_LISTEN_TIMEOUT, \
- .listen_backlog_size = DEFAULT_UNIX_STREAM_LISTEN_BACKLOG, \
+ .timeout_ms = 0, \
+ .listen_backlog_size = 0, \
.disallow_chdir = 0, \
}
--
gitgitgadget
next prev parent reply other threads:[~2021-03-04 20:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 20:17 [PATCH 0/8] Simple IPC Cleanups Jeff Hostetler via GitGitGadget
2021-03-04 20:17 ` [PATCH 1/8] pkt-line: remove buffer arg from write_packetized_from_fd_no_flush() Jeff Hostetler via GitGitGadget
2021-03-04 22:55 ` Junio C Hamano
2021-03-04 20:17 ` Jeff Hostetler via GitGitGadget [this message]
2021-03-04 23:12 ` [PATCH 2/8] unix-socket: simplify initialization of unix_stream_listen_opts Junio C Hamano
2021-03-04 20:17 ` [PATCH 3/8] unix-stream-server: create unix-stream-server.c Jeff Hostetler via GitGitGadget
2021-03-04 20:17 ` [PATCH 4/8] simple-ipc: move error handling up a level Jeff Hostetler via GitGitGadget
2021-03-04 20:17 ` [PATCH 5/8] unix-stream-server: add st_dev and st_mode to socket stolen checks Jeff Hostetler via GitGitGadget
2021-03-06 11:42 ` René Scharfe
2021-03-08 14:14 ` Jeff Hostetler
2021-03-04 20:17 ` [PATCH 6/8] test-simple-ipc: refactor command line option processing in helper Jeff Hostetler via GitGitGadget
2021-03-04 20:17 ` [PATCH 7/8] test-simple-ipc: add --token=<token> string option Jeff Hostetler via GitGitGadget
2021-03-04 20:17 ` [PATCH 8/8] simple-ipc: update design documentation with more details Jeff Hostetler via GitGitGadget
2021-03-05 0:24 ` [PATCH 0/8] Simple IPC Cleanups Junio C Hamano
2021-03-05 21:34 ` Jeff Hostetler
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=6ef867bf37d366071d5f0f101e7430d859f529b5.1614889047.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=jeffhost@microsoft.com \
/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).