Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
60e31637
Commit
60e31637
authored
Mar 14, 2017
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
io/fdpass: add flag to close fd after sending.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
4f6d604c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
ccan/io/fdpass/fdpass.c
ccan/io/fdpass/fdpass.c
+4
-0
ccan/io/fdpass/fdpass.h
ccan/io/fdpass/fdpass.h
+6
-5
ccan/io/fdpass/test/run.c
ccan/io/fdpass/test/run.c
+1
-1
No files found.
ccan/io/fdpass/fdpass.c
View file @
60e31637
...
...
@@ -12,17 +12,21 @@ static int do_fd_send(int fd, struct io_plan_arg *arg)
return
0
;
return
-
1
;
}
if
(
arg
->
u2
.
s
)
close
(
arg
->
u1
.
s
);
return
1
;
}
struct
io_plan
*
io_send_fd_
(
struct
io_conn
*
conn
,
int
fd
,
bool
fdclose
,
struct
io_plan
*
(
*
next
)(
struct
io_conn
*
,
void
*
),
void
*
next_arg
)
{
struct
io_plan_arg
*
arg
=
io_plan_arg
(
conn
,
IO_OUT
);
arg
->
u1
.
s
=
fd
;
arg
->
u2
.
s
=
fdclose
;
return
io_set_plan
(
conn
,
IO_OUT
,
do_fd_send
,
next
,
next_arg
);
}
...
...
ccan/io/fdpass/fdpass.h
View file @
60e31637
...
...
@@ -7,6 +7,7 @@
* io_send_fd - output plan to send a file descriptor
* @conn: the connection that plan is for.
* @fd: the file descriptor to pass.
* @fdclose: true to close fd after successful sending.
* @next: function to call output is done.
* @arg: @next argument
*
...
...
@@ -22,17 +23,17 @@
* Example:
* static struct io_plan *fd_to_conn(struct io_conn *conn, int fd)
* {
* // Write fd, then close.
* return io_send_fd(conn, fd, io_close_cb, NULL);
* // Write fd, then close
conn
.
* return io_send_fd(conn, fd,
false,
io_close_cb, NULL);
* }
*/
#define io_send_fd(conn, fd,
next, arg)
\
io_send_fd_((conn), (fd),
\
#define io_send_fd(conn, fd,
fdclose, next, arg)
\
io_send_fd_((conn), (fd),
(fdclose),
\
typesafe_cb_preargs(struct io_plan *, void *, \
(next), (arg), struct io_conn *), \
(arg))
struct
io_plan
*
io_send_fd_
(
struct
io_conn
*
conn
,
int
fd
,
int
fd
,
bool
fdclose
,
struct
io_plan
*
(
*
next
)(
struct
io_conn
*
,
void
*
),
void
*
arg
);
...
...
ccan/io/fdpass/test/run.c
View file @
60e31637
...
...
@@ -28,7 +28,7 @@ static struct io_plan *try_writing(struct io_conn *conn, int *pfd)
static
struct
io_plan
*
send_fd
(
struct
io_conn
*
conn
,
int
*
pfd
)
{
return
io_send_fd
(
conn
,
pfd
[
0
],
try_writing
,
pfd
);
return
io_send_fd
(
conn
,
pfd
[
0
],
tr
ue
,
tr
y_writing
,
pfd
);
}
int
main
(
void
)
...
...
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