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
eaf0b478
Commit
eaf0b478
authored
Jan 04, 1999
by
Niels Möller
Browse files
Use write_raw() and write_Raw_with_poll().
Rev: src/blocking_write.c:1.9 Rev: src/blocking_write.h:1.6
parent
9bbc0cab
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/blocking_write.c
View file @
eaf0b478
...
...
@@ -4,61 +4,38 @@
#include
"blocking_write.h"
#include
"io.h"
#include
"xalloc.h"
#include
"werror.h"
#include
<string.h>
/* CLASS:
(class
(name blocking_write)
(super abstract_write)
(vars
(fd . int)
(write . (pointer (function int int UINT32 "UINT8 *")))))
*/
#ifdef HAVE_UNISTD_H
#include
<unistd.h>
#endif
#include
<errno.h>
#define CLASS_DEFINE
#include
"blocking_write.h.x"
#undef CLASS_DEFINE
#include
"blocking_write.c.x"
static
int
do_blocking_write
(
struct
abstract_write
*
w
,
struct
lsh_string
*
packet
)
{
CAST
(
blocking_write
,
closure
,
w
);
UINT32
left
=
packet
->
length
;
UINT8
*
p
=
packet
->
data
;
while
(
left
)
{
int
written
=
write
(
closure
->
fd
,
p
,
left
);
if
(
(
written
<
0
)
&&
(
errno
==
EINTR
)
)
continue
;
if
(
written
<=
0
)
{
werror
(
"blocking_write: writ failed (errno = %d): %s
\n
"
,
errno
,
strerror
(
errno
));
return
LSH_FAIL
;
}
left
-=
written
;
p
+=
written
;
}
int
success
=
closure
->
write
(
closure
->
fd
,
packet
->
length
,
packet
->
data
);
lsh_string_free
(
packet
);
return
LSH_OK
;
return
success
?
LSH_OK
:
LSH_FAIL
|
LSH_DIE
;
}
struct
abstract_write
*
make_blocking_write
(
int
fd
)
struct
abstract_write
*
make_blocking_write
(
int
fd
,
int
with_nonblocking
)
{
NEW
(
blocking_write
,
closure
);
closure
->
super
.
write
=
do_blocking_write
;
closure
->
write
=
(
with_nonblocking
?
write_raw_with_poll
:
write_raw
);
closure
->
fd
=
fd
;
return
&
closure
->
super
;
}
src/blocking_write.h
View file @
eaf0b478
...
...
@@ -7,18 +7,6 @@
#include
"abstract_io.h"
#define CLASS_DECLARE
#include
"blocking_write.h.x"
#undef CLASS_DECLARE
/* CLASS:
(class
(name blocking_write)
(super abstract_write)
(vars
(fd . int)))
*/
struct
abstract_write
*
make_blocking_write
(
int
fd
);
struct
abstract_write
*
make_blocking_write
(
int
fd
,
int
with_nonblocking
);
#endif
/* LSH_BLOCKING_WRITE_H_INCLUDED */
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