Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
credential-cache--daemon: use tempfile module
author
Michael Haggerty
<mhagger@alum.mit.edu>
Mon, 10 Aug 2015 09:47:51 +0000
(11:47 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 12 Aug 2015 21:50:11 +0000
(14:50 -0700)
Use the tempfile module to ensure that the socket file gets deleted on
program exit.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
credential-cache--daemon.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
18a3de4
)
diff --git
a/credential-cache--daemon.c
b/credential-cache--daemon.c
index a671b2b53cbc343174802ba5145cc7310555706d..eef6fce4c72ab37d75a0f75129666009a6a1ee54 100644
(file)
--- a/
credential-cache--daemon.c
+++ b/
credential-cache--daemon.c
@@
-1,23
+1,11
@@
#include "cache.h"
#include "cache.h"
+#include "tempfile.h"
#include "credential.h"
#include "unix-socket.h"
#include "sigchain.h"
#include "parse-options.h"
#include "credential.h"
#include "unix-socket.h"
#include "sigchain.h"
#include "parse-options.h"
-static const char *socket_path;
-
-static void cleanup_socket(void)
-{
- if (socket_path)
- unlink(socket_path);
-}
-
-static void cleanup_socket_on_signal(int sig)
-{
- cleanup_socket();
- sigchain_pop(sig);
- raise(sig);
-}
+static struct tempfile socket_file;
struct credential_cache_entry {
struct credential item;
struct credential_cache_entry {
struct credential item;
@@
-256,6
+244,7
@@
static void check_socket_directory(const char *path)
int main(int argc, const char **argv)
{
int main(int argc, const char **argv)
{
+ const char *socket_path;
static const char *usage[] = {
"git-credential-cache--daemon [opts] <socket_path>",
NULL
static const char *usage[] = {
"git-credential-cache--daemon [opts] <socket_path>",
NULL
@@
-272,14
+261,11
@@
int main(int argc, const char **argv)
if (!socket_path)
usage_with_options(usage, options);
if (!socket_path)
usage_with_options(usage, options);
- check_socket_directory(socket_path);
-
- atexit(cleanup_socket);
- sigchain_push_common(cleanup_socket_on_signal);
+ check_socket_directory(socket_path);
+ register_tempfile(&socket_file, socket_path);
serve_cache(socket_path, debug);
serve_cache(socket_path, debug);
-
- unlink(socket_path);
+ delete_tempfile(&socket_file);
return 0;
}
return 0;
}