| 94 | } |
| 95 | |
| 96 | static void do_cache(const char *socket, const char *action, int timeout, |
| 97 | int flags) |
| 98 | { |
| 99 | struct strbuf buf = STRBUF_INIT; |
| 100 | |
| 101 | strbuf_addf(&buf, "action=%s\n", action); |
| 102 | strbuf_addf(&buf, "timeout=%d\n", timeout); |
| 103 | if (flags & FLAG_RELAY) { |
| 104 | if (strbuf_read(&buf, 0, 0) < 0) |
| 105 | die_errno("unable to relay credential"); |
| 106 | } |
| 107 | |
| 108 | if (send_request(socket, &buf) < 0) { |
| 109 | if (connection_fatally_broken(errno)) |
| 110 | die_errno("unable to connect to cache daemon"); |
| 111 | if (flags & FLAG_SPAWN) { |
| 112 | spawn_daemon(socket); |
| 113 | if (send_request(socket, &buf) < 0) |
| 114 | die_errno("unable to connect to cache daemon"); |
| 115 | } |
| 116 | } |
| 117 | strbuf_release(&buf); |
| 118 | } |
| 119 | |
| 120 | static char *get_socket_path(void) |
| 121 | { |
no test coverage detected