MCPcopy Create free account
hub / github.com/git/git / serve_cache_loop

Function serve_cache_loop

builtin/credential-cache--daemon.c:189–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189static int serve_cache_loop(int fd)
190{
191 struct pollfd pfd;
192 timestamp_t wakeup;
193
194 wakeup = check_expirations();
195 if (!wakeup)
196 return 0;
197
198 pfd.fd = fd;
199 pfd.events = POLLIN;
200 if (poll(&pfd, 1, 1000 * wakeup) < 0) {
201 if (errno != EINTR)
202 die_errno("poll failed");
203 return 1;
204 }
205
206 if (pfd.revents & POLLIN) {
207 int client, client2;
208 FILE *in, *out;
209
210 client = accept(fd, NULL, NULL);
211 if (client < 0) {
212 warning_errno("accept failed");
213 return 1;
214 }
215 client2 = dup(client);
216 if (client2 < 0) {
217 warning_errno("dup failed");
218 close(client);
219 return 1;
220 }
221
222 in = xfdopen(client, "r");
223 out = xfdopen(client2, "w");
224 serve_one_client(in, out);
225 fclose(in);
226 fclose(out);
227 }
228 return 1;
229}
230
231static void serve_cache(const char *socket_path, int debug)
232{

Callers 1

serve_cacheFunction · 0.85

Calls 6

check_expirationsFunction · 0.85
pollFunction · 0.85
die_errnoFunction · 0.85
warning_errnoFunction · 0.85
xfdopenFunction · 0.85
serve_one_clientFunction · 0.85

Tested by

no test coverage detected