Skip to content

Confusing "Resource temporarily unavailable" error on timeout with OpenSSL backend #7301

Description

@civodul

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.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions