| 41 | #endif |
| 42 | |
| 43 | static int send_request(const char *socket, const struct strbuf *out) |
| 44 | { |
| 45 | int got_data = 0; |
| 46 | int fd = unix_stream_connect(socket, 0); |
| 47 | |
| 48 | if (fd < 0) |
| 49 | return -1; |
| 50 | |
| 51 | if (write_in_full(fd, out->buf, out->len) < 0) |
| 52 | die_errno("unable to write to cache daemon"); |
| 53 | shutdown(fd, SHUT_WR); |
| 54 | |
| 55 | while (1) { |
| 56 | char in[1024]; |
| 57 | int r; |
| 58 | |
| 59 | r = read_in_full(fd, in, sizeof(in)); |
| 60 | if (r == 0 || (r < 0 && connection_closed(errno))) |
| 61 | break; |
| 62 | if (r < 0) |
| 63 | die_errno("read error from cache daemon"); |
| 64 | write_or_die(1, in, r); |
| 65 | got_data = 1; |
| 66 | } |
| 67 | close(fd); |
| 68 | return got_data; |
| 69 | } |
| 70 | |
| 71 | static void spawn_daemon(const char *socket) |
| 72 | { |
no test coverage detected