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
32b34c4b
Commit
32b34c4b
authored
Dec 22, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'kazuho/issues/133' of
https://github.com/kazuho/nghttp2
into kazuho-kazuho/issues/133
parents
e559168b
45d0d731
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
12 deletions
+58
-12
src/nghttp.cc
src/nghttp.cc
+58
-12
No files found.
src/nghttp.cc
View file @
32b34c4b
...
...
@@ -2082,17 +2082,63 @@ int run(char **uris, int n) {
struct
stat
data_stat
;
if
(
!
config
.
datafile
.
empty
())
{
data_fd
=
open
(
config
.
datafile
.
c_str
(),
O_RDONLY
|
O_BINARY
);
if
(
data_fd
==
-
1
)
{
std
::
cerr
<<
"[ERROR] Could not open file "
<<
config
.
datafile
<<
std
::
endl
;
return
1
;
}
if
(
fstat
(
data_fd
,
&
data_stat
)
==
-
1
)
{
close
(
data_fd
);
std
::
cerr
<<
"[ERROR] Could not stat file "
<<
config
.
datafile
<<
std
::
endl
;
return
1
;
if
(
config
.
datafile
==
"-"
)
{
if
(
fstat
(
0
,
&
data_stat
)
==
0
&&
(
data_stat
.
st_mode
&
S_IFMT
)
==
S_IFREG
)
{
// use STDIN if it is a regular file
data_fd
=
0
;
}
else
{
// copy the contents of STDIN to a temporary file
char
tempfn
[]
=
"/tmp/nghttp.temp.XXXXXX"
;
data_fd
=
mkstemp
(
tempfn
);
if
(
data_fd
==
-
1
)
{
std
::
cerr
<<
"[ERROR] Could not create a temporary file in /tmp"
<<
std
::
endl
;
return
1
;
}
if
(
unlink
(
tempfn
)
!=
0
)
{
std
::
cerr
<<
"[WARNING] failed to unlink temporary file:"
<<
tempfn
<<
std
::
endl
;
}
while
(
1
)
{
char
buf
[
1024
];
ssize_t
rret
,
wret
;
while
((
rret
=
read
(
0
,
buf
,
sizeof
(
buf
)))
==
-
1
&&
errno
==
EINTR
)
;
if
(
rret
==
0
)
break
;
if
(
rret
==
-
1
)
{
std
::
cerr
<<
"[ERROR] I/O error while reading from STDIN"
<<
std
::
endl
;
return
1
;
}
while
((
wret
=
write
(
data_fd
,
buf
,
rret
))
==
-
1
&&
errno
==
EINTR
)
;
if
(
wret
!=
rret
)
{
std
::
cerr
<<
"[ERROR] I/O error while writing to temporary file"
<<
std
::
endl
;
return
1
;
}
}
if
(
fstat
(
data_fd
,
&
data_stat
)
==
-
1
)
{
close
(
data_fd
);
std
::
cerr
<<
"[ERROR] Could not stat temporary file"
<<
std
::
endl
;
return
1
;
}
}
}
else
{
data_fd
=
open
(
config
.
datafile
.
c_str
(),
O_RDONLY
|
O_BINARY
);
if
(
data_fd
==
-
1
)
{
std
::
cerr
<<
"[ERROR] Could not open file "
<<
config
.
datafile
<<
std
::
endl
;
return
1
;
}
if
(
fstat
(
data_fd
,
&
data_stat
)
==
-
1
)
{
close
(
data_fd
);
std
::
cerr
<<
"[ERROR] Could not stat file "
<<
config
.
datafile
<<
std
::
endl
;
return
1
;
}
}
data_prd
.
source
.
fd
=
data_fd
;
data_prd
.
read_callback
=
file_read_callback
;
...
...
@@ -2369,7 +2415,7 @@ int main(int argc, char **argv) {
config
.
stat
=
true
;
break
;
case
'd'
:
config
.
datafile
=
strcmp
(
"-"
,
optarg
)
==
0
?
"/dev/stdin"
:
optarg
;
config
.
datafile
=
optarg
;
break
;
case
'm'
:
config
.
multiply
=
strtoul
(
optarg
,
nullptr
,
10
);
...
...
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