Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#7,301 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
c, git

调研方向

首先复现服务器一秒超时的示例,并跟踪 socket_read 经过 BIO 和 stream 抽象层的过程。当超时得到保留,并且被报告为超时而不是 "Resource temporarily unavailable" 时,工作就完成了。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
C
星标
10.6k
派生
2.7k
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

libgit2/libgit2 的其他 Issue

查看 libgit2/libgit2 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。