Artifactspublic-v0

curl

master
ply4 git calls37 ms289 KiB3 cachedprotocol v2
142 lines4.1 KiBRaw

NAME

curl_global_init - global libcurl initialization

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_global_init(long flags);

DESCRIPTION

This function sets up the program environment that libcurl needs. Think of it as an extension of the library loader.

This function must be called at least once within a program (a program is all the code that shares a memory space) before the program calls any other function in libcurl. The environment it sets up is constant for the life of the program and is the same for every program, so multiple calls have the same effect as one call.

The flags option is a bit pattern that tells libcurl exactly what features to init, as described below. Set the desired bits by ORing the values together. In normal operation, you must specify CURL_GLOBAL_ALL. Do not use any other value unless you are familiar with it and mean to control internal operations of libcurl.

This function is thread-safe on most platforms. Then curl_version_info(3) has the threadsafe feature set (added in 7.84.0).

If this is not thread-safe (the bit mentioned above is not set), you must not call this function when any other thread in the program (i.e. a thread sharing the same memory) is running. This does not only mean other threads that use libcurl. Because curl_global_init(3) calls functions of other libraries that are similarly thread-unsafe, it could conflict with any other thread that uses these other libraries.

If you are initializing libcurl from a Windows DLL you should not initialize it from DllMain or a static initializer because Windows holds the loader lock during that time and it could cause a deadlock.

See the description in libcurl(3) of global environment requirements for details of how to use this function.

FLAGS

CURL_GLOBAL_ALL

Initialize everything possible. This sets all known bits except CURL_GLOBAL_ACK_EINTR.

CURL_GLOBAL_SSL

(This flag's presence or absence serves no meaning since 7.57.0. The description below is for older libcurl versions.)

Initialize SSL.

The implication here is that if this bit is not set, the initialization of the SSL layer needs to be done by the application or at least outside of libcurl. The exact procedure how to do SSL initialization depends on the TLS backend libcurl uses.

Doing TLS based transfers without having the TLS layer initialized may lead to unexpected behaviors.

CURL_GLOBAL_WINSOCK

Initialize the Windows sockets library (Winsock).

The implication here is that if this bit is not set, the initialization of Winsock has to be done by the application or you risk getting undefined behaviors. This option exists for when the initialization is handled outside of libcurl so there is no need for libcurl to do it again.

Prior to 8.23.0 this flag was called CURL_GLOBAL_WIN32. The name was changed to eliminate confusion. Most of libcurl's Windows initialization is required and is not controlled by this flag.

CURL_GLOBAL_NOTHING

Initialize nothing extra. This sets no bit.

CURL_GLOBAL_DEFAULT

A sensible default. It initializes both SSL and Winsock. Right now, this equals the functionality of the CURL_GLOBAL_ALL mask.

CURL_GLOBAL_ACK_EINTR

This bit has no point since 7.69.0 but its behavior is instead the default.

Before 7.69.0: when this flag is set, curl acknowledges EINTR condition when connecting or when waiting for data. Otherwise, curl waits until full timeout elapses.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURLcode result;

  result = curl_global_init(CURL_GLOBAL_DEFAULT);

  if(result == CURLE_OK) {

    /* use libcurl, then before exiting... */

    curl_global_cleanup();
  }
}

%AVAILABILITY%

RETURN VALUE

If this function returns non-zero, something went wrong and you cannot use the other curl functions.

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_global_init
5Section: 3
6Source: libcurl
7See-also:
8 - curl_easy_init (3)
9 - curl_global_cleanup (3)
10 - curl_global_init_mem (3)
11 - curl_global_sslset (3)
12 - curl_global_trace (3)
13 - libcurl (3)
14Protocol:
15 - All
16Added-in: 7.8
17---
19# NAME
21curl_global_init - global libcurl initialization
23# SYNOPSIS
25~~~c
26#include <curl/curl.h>
28CURLcode curl_global_init(long flags);
29~~~
31# DESCRIPTION
33This function sets up the program environment that libcurl needs. Think of it
34as an extension of the library loader.
36This function must be called at least once within a program (a program is all
37the code that shares a memory space) before the program calls any other
38function in libcurl. The environment it sets up is constant for the life of
39the program and is the same for every program, so multiple calls have the same
40effect as one call.
42The flags option is a bit pattern that tells libcurl exactly what features to
43init, as described below. Set the desired bits by ORing the values together.
44In normal operation, you must specify CURL_GLOBAL_ALL. Do not use any other
45value unless you are familiar with it and mean to control internal operations
46of libcurl.
48This function is thread-safe on most platforms. Then curl_version_info(3) has
49the `threadsafe` feature set (added in 7.84.0).
51If this is not thread-safe (the bit mentioned above is not set), you must not
52call this function when any other thread in the program (i.e. a thread sharing
53the same memory) is running. This does not only mean other threads that use
54libcurl. Because curl_global_init(3) calls functions of other libraries that
55are similarly thread-unsafe, it could conflict with any other thread that uses
56these other libraries.
58If you are initializing libcurl from a Windows DLL you should not initialize
59it from *DllMain* or a static initializer because Windows holds the loader
60lock during that time and it could cause a deadlock.
62See the description in libcurl(3) of global environment requirements for
63details of how to use this function.
65# FLAGS
67## CURL_GLOBAL_ALL
69Initialize everything possible. This sets all known bits except
70**CURL_GLOBAL_ACK_EINTR**.
72## CURL_GLOBAL_SSL
74(This flag's presence or absence serves no meaning since 7.57.0. The
75description below is for older libcurl versions.)
77Initialize SSL.
79The implication here is that if this bit is not set, the initialization of the
80SSL layer needs to be done by the application or at least outside of
81libcurl. The exact procedure how to do SSL initialization depends on the TLS
82backend libcurl uses.
84Doing TLS based transfers without having the TLS layer initialized may lead to
85unexpected behaviors.
87## CURL_GLOBAL_WINSOCK
89Initialize the Windows sockets library (Winsock).
91The implication here is that if this bit is not set, the initialization of
92Winsock has to be done by the application or you risk getting undefined
93behaviors. This option exists for when the initialization is handled outside
94of libcurl so there is no need for libcurl to do it again.
96Prior to 8.23.0 this flag was called CURL_GLOBAL_WIN32. The name was changed
97to eliminate confusion. Most of libcurl's Windows initialization is required
98and is not controlled by this flag.
100## CURL_GLOBAL_NOTHING
102Initialize nothing extra. This sets no bit.
104## CURL_GLOBAL_DEFAULT
106A sensible default. It initializes both SSL and Winsock. Right now, this equals
107the functionality of the **CURL_GLOBAL_ALL** mask.
109## CURL_GLOBAL_ACK_EINTR
111This bit has no point since 7.69.0 but its behavior is instead the default.
113Before 7.69.0: when this flag is set, curl acknowledges EINTR condition when
114connecting or when waiting for data. Otherwise, curl waits until full timeout
115elapses.
117# %PROTOCOLS%
119# EXAMPLE
121~~~c
122int main(void)
124 CURLcode result;
126 result = curl_global_init(CURL_GLOBAL_DEFAULT);
128 if(result == CURLE_OK) {
130 /* use libcurl, then before exiting... */
132 curl_global_cleanup();
133 }
135~~~
137# %AVAILABILITY%
139# RETURN VALUE
141If this function returns non-zero, something went wrong and you cannot use the
142other curl functions.
Diagnostics4 git calls · 37 ms
CallStatusSizeTime037 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=32
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2002.0 KiB · hit32 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2016
git.response.cache=HIT
git.response.duration_ms=32
git.fetch.wants=9347bbb5aea5f056da86be37a9e50a8221f73b23
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2016
git.pkt.payload.max=1995
git.sideband.band1.bytes=1994
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e3299bd8d14628
Request
c966d419…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format