Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
e4751a79
Commit
e4751a79
authored
Sep 16, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace auto_delete* with defer
parent
6fc12caa
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
47 deletions
+25
-47
src/h2load_http2_session.cc
src/h2load_http2_session.cc
+2
-2
src/nghttp.cc
src/nghttp.cc
+1
-2
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+2
-2
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+2
-2
src/shrpx_ssl.cc
src/shrpx_ssl.cc
+4
-5
src/util.h
src/util.h
+14
-34
No files found.
src/h2load_http2_session.cc
View file @
e4751a79
...
@@ -106,8 +106,8 @@ void Http2Session::on_connect()
...
@@ -106,8 +106,8 @@ void Http2Session::on_connect()
nghttp2_session_callbacks_new
(
&
callbacks
);
nghttp2_session_callbacks_new
(
&
callbacks
);
util
::
auto_delete
<
nghttp2_session_callbacks
*>
callbacks_deleter
auto
callbacks_deleter
=
(
callbacks
,
nghttp2_session_callbacks_del
);
util
::
defer
(
callbacks
,
nghttp2_session_callbacks_del
);
nghttp2_session_callbacks_set_on_frame_recv_callback
nghttp2_session_callbacks_set_on_frame_recv_callback
(
callbacks
,
on_frame_recv_callback
);
(
callbacks
,
on_frame_recv_callback
);
...
...
src/nghttp.cc
View file @
e4751a79
...
@@ -1832,8 +1832,7 @@ int run(char **uris, int n)
...
@@ -1832,8 +1832,7 @@ int run(char **uris, int n)
nghttp2_session_callbacks
*
callbacks
;
nghttp2_session_callbacks
*
callbacks
;
nghttp2_session_callbacks_new
(
&
callbacks
);
nghttp2_session_callbacks_new
(
&
callbacks
);
util
::
auto_delete
<
nghttp2_session_callbacks
*>
cbsdel
auto
cbsdel
=
util
::
defer
(
callbacks
,
nghttp2_session_callbacks_del
);
(
callbacks
,
nghttp2_session_callbacks_del
);
nghttp2_session_callbacks_set_on_stream_close_callback
nghttp2_session_callbacks_set_on_stream_close_callback
(
callbacks
,
on_stream_close_callback
);
(
callbacks
,
on_stream_close_callback
);
...
...
src/shrpx_http2_session.cc
View file @
e4751a79
...
@@ -1377,8 +1377,8 @@ int Http2Session::on_connect()
...
@@ -1377,8 +1377,8 @@ int Http2Session::on_connect()
return
-
1
;
return
-
1
;
}
}
util
::
auto_delete
<
nghttp2_session_callbacks
*>
callbacks_deleter
auto
callbacks_deleter
=
(
callbacks
,
nghttp2_session_callbacks_del
);
util
::
defer
(
callbacks
,
nghttp2_session_callbacks_del
);
nghttp2_session_callbacks_set_on_stream_close_callback
nghttp2_session_callbacks_set_on_stream_close_callback
(
callbacks
,
on_stream_close_callback
);
(
callbacks
,
on_stream_close_callback
);
...
...
src/shrpx_http2_upstream.cc
View file @
e4751a79
...
@@ -637,8 +637,8 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
...
@@ -637,8 +637,8 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
assert
(
rv
==
0
);
assert
(
rv
==
0
);
util
::
auto_delete
<
nghttp2_session_callbacks
*>
callbacks_deleter
auto
callbacks_deleter
=
(
callbacks
,
nghttp2_session_callbacks_del
);
util
::
defer
(
callbacks
,
nghttp2_session_callbacks_del
);
nghttp2_session_callbacks_set_on_stream_close_callback
nghttp2_session_callbacks_set_on_stream_close_callback
(
callbacks
,
on_stream_close_callback
);
(
callbacks
,
on_stream_close_callback
);
...
...
src/shrpx_ssl.cc
View file @
e4751a79
...
@@ -602,8 +602,7 @@ void get_altnames(X509 *cert,
...
@@ -602,8 +602,7 @@ void get_altnames(X509 *cert,
static_cast
<
GENERAL_NAMES
*>
static_cast
<
GENERAL_NAMES
*>
(
X509_get_ext_d2i
(
cert
,
NID_subject_alt_name
,
nullptr
,
nullptr
));
(
X509_get_ext_d2i
(
cert
,
NID_subject_alt_name
,
nullptr
,
nullptr
));
if
(
altnames
)
{
if
(
altnames
)
{
util
::
auto_delete
<
GENERAL_NAMES
*>
altnames_deleter
(
altnames
,
auto
altnames_deleter
=
util
::
defer
(
altnames
,
GENERAL_NAMES_free
);
GENERAL_NAMES_free
);
size_t
n
=
sk_GENERAL_NAME_num
(
altnames
);
size_t
n
=
sk_GENERAL_NAME_num
(
altnames
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
const
GENERAL_NAME
*
altname
=
sk_GENERAL_NAME_value
(
altnames
,
i
);
const
GENERAL_NAME
*
altname
=
sk_GENERAL_NAME_value
(
altnames
,
i
);
...
@@ -665,7 +664,7 @@ int check_cert(SSL *ssl)
...
@@ -665,7 +664,7 @@ int check_cert(SSL *ssl)
LOG
(
ERROR
)
<<
"No certificate found"
;
LOG
(
ERROR
)
<<
"No certificate found"
;
return
-
1
;
return
-
1
;
}
}
util
::
auto_delete
<
X509
*>
cert_delet
er
(
cert
,
X509_free
);
auto
cert_deleter
=
util
::
def
er
(
cert
,
X509_free
);
long
verify_res
=
SSL_get_verify_result
(
ssl
);
long
verify_res
=
SSL_get_verify_result
(
ssl
);
if
(
verify_res
!=
X509_V_OK
)
{
if
(
verify_res
!=
X509_V_OK
)
{
LOG
(
ERROR
)
<<
"Certificate verification failed: "
LOG
(
ERROR
)
<<
"Certificate verification failed: "
...
@@ -864,7 +863,7 @@ int cert_lookup_tree_add_cert_from_file(CertLookupTree *lt, SSL_CTX *ssl_ctx,
...
@@ -864,7 +863,7 @@ int cert_lookup_tree_add_cert_from_file(CertLookupTree *lt, SSL_CTX *ssl_ctx,
LOG
(
ERROR
)
<<
"BIO_new failed"
;
LOG
(
ERROR
)
<<
"BIO_new failed"
;
return
-
1
;
return
-
1
;
}
}
util
::
auto_delete
<
BIO
*>
bio_delet
er
(
bio
,
BIO_vfree
);
auto
bio_deleter
=
util
::
def
er
(
bio
,
BIO_vfree
);
if
(
!
BIO_read_filename
(
bio
,
certfile
))
{
if
(
!
BIO_read_filename
(
bio
,
certfile
))
{
LOG
(
ERROR
)
<<
"Could not read certificate file '"
<<
certfile
<<
"'"
;
LOG
(
ERROR
)
<<
"Could not read certificate file '"
<<
certfile
<<
"'"
;
return
-
1
;
return
-
1
;
...
@@ -875,7 +874,7 @@ int cert_lookup_tree_add_cert_from_file(CertLookupTree *lt, SSL_CTX *ssl_ctx,
...
@@ -875,7 +874,7 @@ int cert_lookup_tree_add_cert_from_file(CertLookupTree *lt, SSL_CTX *ssl_ctx,
<<
certfile
<<
"'"
;
<<
certfile
<<
"'"
;
return
-
1
;
return
-
1
;
}
}
util
::
auto_delete
<
X509
*>
cert_delet
er
(
cert
,
X509_free
);
auto
cert_deleter
=
util
::
def
er
(
cert
,
X509_free
);
std
::
string
common_name
;
std
::
string
common_name
;
std
::
vector
<
std
::
string
>
dns_names
;
std
::
vector
<
std
::
string
>
dns_names
;
std
::
vector
<
std
::
string
>
ip_addrs
;
std
::
vector
<
std
::
string
>
ip_addrs
;
...
...
src/util.h
View file @
e4751a79
...
@@ -51,46 +51,26 @@ constexpr size_t array_size(T (&)[N])
...
@@ -51,46 +51,26 @@ constexpr size_t array_size(T (&)[N])
return
N
;
return
N
;
}
}
template
<
typename
T
>
template
<
typename
T
,
typename
F
>
class
auto_delete
{
struct
Defer
{
private:
Defer
(
T
t
,
F
f
)
T
obj_
;
:
t
(
t
),
f
(
std
::
move
(
f
))
void
(
*
deleter_
)(
T
);
{}
public:
auto_delete
(
T
obj
,
void
(
*
deleter
)(
T
))
:
obj_
(
obj
),
deleter_
(
deleter
)
{}
~
auto_delete
()
~
Defer
()
{
{
deleter_
(
obj_
);
f
(
t
);
}
}
};
template
<
typename
T
>
T
t
;
class
auto_delete_d
{
F
f
;
private:
T
obj_
;
public:
auto_delete_d
(
T
obj
)
:
obj_
(
obj
)
{}
~
auto_delete_d
()
{
delete
obj_
;
}
};
};
template
<
typename
T
,
typename
R
>
template
<
typename
T
,
typename
F
>
class
auto_delete_r
{
Defer
<
T
,
F
>
defer
(
T
&&
t
,
F
f
)
private:
{
T
obj_
;
return
Defer
<
T
,
F
>
(
std
::
forward
<
T
>
(
t
),
std
::
forward
<
F
>
(
f
));
R
(
*
deleter_
)(
T
);
}
public:
auto_delete_r
(
T
obj
,
R
(
*
deleter
)(
T
))
:
obj_
(
obj
),
deleter_
(
deleter
)
{}
~
auto_delete_r
()
{
(
void
)
deleter_
(
obj_
);
}
};
extern
const
char
DEFAULT_STRIP_CHARSET
[];
extern
const
char
DEFAULT_STRIP_CHARSET
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment