Confusing "Resource temporarily unavailable" error on timeout with OpenSSL backend
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 10.6k
- Fork
- 2.7k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Consider this example:
#include <git2.h>
#include <assert.h>
#include <stdio.h>
int
main ()
{
int err;
err = git_libgit2_init ();
assert (err == 1);
git_clone_options opts;
err = git_clone_init_options (&opts, GIT_CLONE_OPTIONS_VERSION);
assert (err == 0);
err = git_libgit2_opts (GIT_OPT_SET_SERVER_TIMEOUT, 1);
assert (err == 0);
git_repository *repo;
err = git_clone (&repo, "https://git.guix.gnu.org/guix.git", "/tmp/example",
&opts);
assert (err != 0);
const git_error *gerr;
gerr = giterr_last ();
fprintf (stderr, "last error: %s\n", gerr->message);
return 0;
}
When running it (using libgit2 1.9.2 on Linux, with the OpenSSL backend), I get:
last error: SSL error: syscall failure: Resource temporarily unavailable
... which is somewhat confusing.
Here's what we see from strace:
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("46.224.9.33")}, 16) = 0
fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
...
sendto(3, "\26\3\1\6\4\1\0\6\0\3\3m\205\362N]I5|\3452\341b\v\316`9'*/\225?"..., 1545, 0, NULL, 0) = 1545
recvfrom(3, 0x19d1853, 5, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}], 1, 1) = 0 (Timeout)
close(3) = 0
This corresponds to socket_read, calling recv then poll.
The issue here is that the error reported ("Resource temporarily available") is the wrong one; it should say "Timeout" (or similar). socket_read does try to convey that error but it gets lost in the abstraction layers (BIO, streams, etc.).
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l'esempio con il timeout del server di un secondo e tracciando socket_read attraverso i livelli di astrazione BIO e stream. Il lavoro è completato quando il timeout viene preservato e segnalato come timeout anziché come "Resource temporarily unavailable".
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, git
- Ambito
- backend, networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100