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
37cb94d1
Commit
37cb94d1
authored
Jan 27, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Use clock_gettime instead of gettimeofday if available
parent
c235800a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
10 deletions
+38
-10
configure.ac
configure.ac
+11
-0
src/Makefile.am
src/Makefile.am
+2
-1
src/spdycat.cc
src/spdycat.cc
+3
-3
src/spdylay_ssl.cc
src/spdylay_ssl.cc
+20
-6
src/spdylay_ssl.h
src/spdylay_ssl.h
+2
-0
No files found.
configure.ac
View file @
37cb94d1
...
@@ -72,6 +72,9 @@ AM_CONDITIONAL([HAVE_STDCXX_11],
...
@@ -72,6 +72,9 @@ AM_CONDITIONAL([HAVE_STDCXX_11],
# Additional libraries required for tests.
# Additional libraries required for tests.
TESTS_LIBS=
TESTS_LIBS=
# Additional libraries required for programs under src directory.
SRC_LIBS=
LIBS_OLD=$LIBS
LIBS_OLD=$LIBS
# Search for dlsym function, which is used in tests. Linux needs -ldl,
# Search for dlsym function, which is used in tests. Linux needs -ldl,
# but netbsd does not need it.
# but netbsd does not need it.
...
@@ -79,6 +82,13 @@ AC_SEARCH_LIBS([dlsym], [dl])
...
@@ -79,6 +82,13 @@ AC_SEARCH_LIBS([dlsym], [dl])
TESTS_LIBS=$LIBS $TESTS_LIBS
TESTS_LIBS=$LIBS $TESTS_LIBS
LIBS=$LIBS_OLD
LIBS=$LIBS_OLD
LIBS_OLD=$LIBS
AC_SEARCH_LIBS([clock_gettime], [rt],
[AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
[Define to 1 if you have the `clock_gettime`.])])
SRC_LIBS=$LIBS $SRC_LIBS
LIBS=$LIBS_OLD
# zlib
# zlib
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3])
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3])
LIBS="$ZLIB_LIBS $LIBS"
LIBS="$ZLIB_LIBS $LIBS"
...
@@ -242,6 +252,7 @@ if test "x$maintainer_mode" != "xno"; then
...
@@ -242,6 +252,7 @@ if test "x$maintainer_mode" != "xno"; then
fi
fi
AC_SUBST([TESTS_LIBS])
AC_SUBST([TESTS_LIBS])
AC_SUBST([SRC_LIBS])
AC_CONFIG_FILES([
AC_CONFIG_FILES([
Makefile
Makefile
...
...
src/Makefile.am
View file @
37cb94d1
...
@@ -26,7 +26,8 @@ if ENABLE_SRC
...
@@ -26,7 +26,8 @@ if ENABLE_SRC
AM_CFLAGS
=
-Wall
AM_CFLAGS
=
-Wall
AM_CPPFLAGS
=
-Wall
-I
$(srcdir)
/../lib/includes
-I
$(builddir)
/../lib/includes
\
AM_CPPFLAGS
=
-Wall
-I
$(srcdir)
/../lib/includes
-I
$(builddir)
/../lib/includes
\
@OPENSSL_CFLAGS@ @XML_CPPFLAGS@ @LIBEVENT_OPENSSL_CFLAGS@ @DEFS@
@OPENSSL_CFLAGS@ @XML_CPPFLAGS@ @LIBEVENT_OPENSSL_CFLAGS@ @DEFS@
AM_LDFLAGS
=
@OPENSSL_LIBS@ @XML_LIBS@ @LIBEVENT_OPENSSL_LIBS@
-pthread
AM_LDFLAGS
=
@OPENSSL_LIBS@ @XML_LIBS@ @LIBEVENT_OPENSSL_LIBS@ @SRC_LIBS@
\
-pthread
LDADD
=
$(top_builddir)
/lib/libspdylay.la
LDADD
=
$(top_builddir)
/lib/libspdylay.la
bin_PROGRAMS
=
spdycat spdyd
bin_PROGRAMS
=
spdycat spdyd
...
...
src/spdycat.cc
View file @
37cb94d1
...
@@ -105,7 +105,7 @@ struct RequestStat {
...
@@ -105,7 +105,7 @@ struct RequestStat {
void
record_time
(
timeval
*
tv
)
void
record_time
(
timeval
*
tv
)
{
{
get
timeofday
(
tv
,
0
);
get
_time
(
tv
);
}
}
bool
has_uri_field
(
const
http_parser_url
&
u
,
http_parser_url_fields
field
)
bool
has_uri_field
(
const
http_parser_url
&
u
,
http_parser_url_fields
field
)
...
@@ -601,7 +601,7 @@ int spdy_evloop(int fd, SSL *ssl, int spdy_version, SpdySession& spdySession,
...
@@ -601,7 +601,7 @@ int spdy_evloop(int fd, SSL *ssl, int spdy_version, SpdySession& spdySession,
timeval
tv1
,
tv2
;
timeval
tv1
,
tv2
;
while
(
!
sc
.
finish
())
{
while
(
!
sc
.
finish
())
{
if
(
config
.
timeout
!=
-
1
)
{
if
(
config
.
timeout
!=
-
1
)
{
get
timeofday
(
&
tv1
,
0
);
get
_time
(
&
tv1
);
}
}
int
nfds
=
poll
(
pollfds
,
npollfds
,
timeout
);
int
nfds
=
poll
(
pollfds
,
npollfds
,
timeout
);
if
(
nfds
==
-
1
)
{
if
(
nfds
==
-
1
)
{
...
@@ -627,7 +627,7 @@ int spdy_evloop(int fd, SSL *ssl, int spdy_version, SpdySession& spdySession,
...
@@ -627,7 +627,7 @@ int spdy_evloop(int fd, SSL *ssl, int spdy_version, SpdySession& spdySession,
break
;
break
;
}
}
if
(
config
.
timeout
!=
-
1
)
{
if
(
config
.
timeout
!=
-
1
)
{
get
timeofday
(
&
tv2
,
0
);
get
_time
(
&
tv2
);
timeout
-=
time_delta
(
tv2
,
tv1
);
timeout
-=
time_delta
(
tv2
,
tv1
);
if
(
timeout
<=
0
)
{
if
(
timeout
<=
0
)
{
std
::
cerr
<<
"Requests to "
<<
spdySession
.
hostport
<<
" timed out."
std
::
cerr
<<
"Requests to "
<<
spdySession
.
hostport
<<
" timed out."
...
...
src/spdylay_ssl.cc
View file @
37cb94d1
...
@@ -299,7 +299,7 @@ int nonblock_connect_to(const std::string& host, uint16_t port, int timeout)
...
@@ -299,7 +299,7 @@ int nonblock_connect_to(const std::string& host, uint16_t port, int timeout)
struct
timeval
tv1
,
tv2
;
struct
timeval
tv1
,
tv2
;
struct
pollfd
pfd
=
{
fd
,
POLLOUT
,
0
};
struct
pollfd
pfd
=
{
fd
,
POLLOUT
,
0
};
if
(
timeout
!=
-
1
)
{
if
(
timeout
!=
-
1
)
{
get
timeofday
(
&
tv1
,
0
);
get
_time
(
&
tv1
);
}
}
r
=
poll
(
&
pfd
,
1
,
timeout
);
r
=
poll
(
&
pfd
,
1
,
timeout
);
if
(
r
==
0
)
{
if
(
r
==
0
)
{
...
@@ -308,7 +308,7 @@ int nonblock_connect_to(const std::string& host, uint16_t port, int timeout)
...
@@ -308,7 +308,7 @@ int nonblock_connect_to(const std::string& host, uint16_t port, int timeout)
return
-
1
;
return
-
1
;
}
else
{
}
else
{
if
(
timeout
!=
-
1
)
{
if
(
timeout
!=
-
1
)
{
get
timeofday
(
&
tv2
,
0
);
get
_time
(
&
tv2
);
timeout
-=
time_delta
(
tv2
,
tv1
);
timeout
-=
time_delta
(
tv2
,
tv1
);
if
(
timeout
<=
0
)
{
if
(
timeout
<=
0
)
{
return
-
2
;
return
-
2
;
...
@@ -828,7 +828,7 @@ int ssl_nonblock_handshake(SSL *ssl, int fd, int& timeout)
...
@@ -828,7 +828,7 @@ int ssl_nonblock_handshake(SSL *ssl, int fd, int& timeout)
timeval
tv1
,
tv2
;
timeval
tv1
,
tv2
;
while
(
1
)
{
while
(
1
)
{
if
(
timeout
!=
-
1
)
{
if
(
timeout
!=
-
1
)
{
get
timeofday
(
&
tv1
,
0
);
get
_time
(
&
tv1
);
}
}
int
rv
=
poll
(
&
pfd
,
1
,
timeout
);
int
rv
=
poll
(
&
pfd
,
1
,
timeout
);
if
(
rv
==
0
)
{
if
(
rv
==
0
)
{
...
@@ -843,7 +843,7 @@ int ssl_nonblock_handshake(SSL *ssl, int fd, int& timeout)
...
@@ -843,7 +843,7 @@ int ssl_nonblock_handshake(SSL *ssl, int fd, int& timeout)
return
-
1
;
return
-
1
;
}
else
if
(
rv
<
0
)
{
}
else
if
(
rv
<
0
)
{
if
(
timeout
!=
-
1
)
{
if
(
timeout
!=
-
1
)
{
get
timeofday
(
&
tv2
,
0
);
get
_time
(
&
tv2
);
timeout
-=
time_delta
(
tv2
,
tv1
);
timeout
-=
time_delta
(
tv2
,
tv1
);
if
(
timeout
<=
0
)
{
if
(
timeout
<=
0
)
{
return
-
2
;
return
-
2
;
...
@@ -892,12 +892,12 @@ timeval base_tv;
...
@@ -892,12 +892,12 @@ timeval base_tv;
void
reset_timer
()
void
reset_timer
()
{
{
get
timeofday
(
&
base_tv
,
0
);
get
_time
(
&
base_tv
);
}
}
void
get_timer
(
timeval
*
tv
)
void
get_timer
(
timeval
*
tv
)
{
{
get
timeofday
(
tv
,
0
);
get
_time
(
tv
);
tv
->
tv_usec
-=
base_tv
.
tv_usec
;
tv
->
tv_usec
-=
base_tv
.
tv_usec
;
tv
->
tv_sec
-=
base_tv
.
tv_sec
;
tv
->
tv_sec
-=
base_tv
.
tv_sec
;
if
(
tv
->
tv_usec
<
0
)
{
if
(
tv
->
tv_usec
<
0
)
{
...
@@ -906,4 +906,18 @@ void get_timer(timeval* tv)
...
@@ -906,4 +906,18 @@ void get_timer(timeval* tv)
}
}
}
}
int
get_time
(
timeval
*
tv
)
{
int
rv
;
#ifdef HAVE_CLOCK_GETTIME
timespec
ts
;
rv
=
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
tv
->
tv_sec
=
ts
.
tv_sec
;
tv
->
tv_usec
=
ts
.
tv_nsec
/
1000
;
#else // !HAVE_CLOCK_GETTIME
rv
=
gettimeofday
(
&
base_tv
,
0
);
#endif // !HAVE_CLOCK_GETTIME
return
rv
;
}
}
// namespace spdylay
}
// namespace spdylay
src/spdylay_ssl.h
View file @
37cb94d1
...
@@ -150,6 +150,8 @@ void reset_timer();
...
@@ -150,6 +150,8 @@ void reset_timer();
void
get_timer
(
timeval
*
tv
);
void
get_timer
(
timeval
*
tv
);
int
get_time
(
timeval
*
tv
);
void
print_timer
();
void
print_timer
();
enum
{
enum
{
...
...
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