forked from nodejs/node-v0.x-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_vars.cc
More file actions
48 lines (39 loc) · 902 Bytes
/
Copy pathnode_vars.cc
File metadata and controls
48 lines (39 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <node_vars.h>
#include <node_isolate.h>
#if HAVE_OPENSSL
# include <node_crypto.h>
#endif
#include <string.h>
namespace node {
// For now we just statically initialize the globals structure. Later there
// will be one struct globals for each isolate.
void globals_init(struct globals* g) {
memset(g, 0, sizeof(struct globals));
#ifdef OPENSSL_NPN_NEGOTIATED
g->use_npn = true;
#else
g->use_npn = false;
#endif
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
g->use_sni = true;
#else
g->use_sni = false;
#endif
}
#if HAVE_ISOLATES
struct globals* globals_get() {
node::Isolate* isolate = node::Isolate::GetCurrent();
return isolate->Globals();
}
#else
static struct globals g_struct;
static struct globals* g_ptr;
struct globals* globals_get() {
if (!g_ptr) {
g_ptr = &g_struct;
globals_init(g_ptr);
}
return g_ptr;
}
#endif // HAVE_ISOLATES
} // namespace node