Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
5571f557
Commit
5571f557
authored
Jan 10, 1999
by
Niels Möller
Browse files
* io.c (blocking_read): New function.
Rev: src/io.c:1.42 Rev: src/io.h:1.27
parent
53691b93
Changes
2
Show whitespace changes
Inline
Side-by-side
src/io.c
View file @
5571f557
...
...
@@ -451,6 +451,30 @@ static void init_file(struct io_backend *b, struct lsh_fd *f, int fd)
b
->
files
=
f
;
}
/* Blocking read from a file descriptor (i.e. don't use the backend).
* The fd should *not* be in non-blocking mode. */
int
blocking_read
(
int
fd
,
struct
read_handler
*
handler
)
{
struct
fd_read
r
=
{
{
STACK_HEADER
,
do_read
},
fd
};
while
(
1
)
{
int
res
=
READ_HANDLER
(
handler
,
&
r
.
super
);
assert
(
!
(
res
&
(
LSH_HOLD
|
LSH_KILL_OTHERS
)));
if
(
res
&
(
LSH_CLOSE
|
LSH_DIE
))
{
close
(
fd
);
return
res
;
}
if
(
res
&
LSH_FAIL
)
werror
(
"blocking_read: Ignoring error %d
\n
"
,
res
);
}
}
/*
* Fill in ADDR from HOST, SERVICE and PROTOCOL.
* Supplying a null pointer for HOST means use INADDR_ANY.
...
...
src/io.h
View file @
5571f557
...
...
@@ -154,6 +154,8 @@ void init_backend(struct io_backend *b);
int
io_iter
(
struct
io_backend
*
b
);
void
io_run
(
struct
io_backend
*
b
);
int
blocking_read
(
int
fd
,
struct
read_handler
*
r
);
int
get_inaddr
(
struct
sockaddr_in
*
addr
,
const
char
*
host
,
const
char
*
service
,
...
...
Write
Preview
Supports
Markdown
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