diff options
author | pjd <pjd@FreeBSD.org> | 2011-02-02 15:46:28 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2011-02-02 15:46:28 +0000 |
commit | 1267c20f911e08de277a22060d9bc42148f9afc0 (patch) | |
tree | 14572a6733b1467ecd161cefb488eb923dad681b /sbin/hastd/proto_uds.c | |
parent | 3acb629cd228ce6366df06b502aea7ca95055b91 (diff) | |
download | FreeBSD-src-1267c20f911e08de277a22060d9bc42148f9afc0.zip FreeBSD-src-1267c20f911e08de277a22060d9bc42148f9afc0.tar.gz |
Add proto_connect_wait() to wait for connection to finish.
If timeout argument to proto_connect() is -1, then the caller needs to use
this new function to wait for connection.
This change is in preparation for capsicum, where sandboxed worker wants
to ask main process to connect in worker's behalf and pass descriptor
to the worker. Because we don't want the main process to wait for the
connection, it will start async connection and pass descriptor to the
worker who will be responsible for waiting for the connection to finish.
MFC after: 1 week
Diffstat (limited to 'sbin/hastd/proto_uds.c')
-rw-r--r-- | sbin/hastd/proto_uds.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sbin/hastd/proto_uds.c b/sbin/hastd/proto_uds.c index 58b968e..0d3151a 100644 --- a/sbin/hastd/proto_uds.c +++ b/sbin/hastd/proto_uds.c @@ -131,7 +131,7 @@ uds_connect(void *ctx, int timeout) PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC); PJDLOG_ASSERT(uctx->uc_side == UDS_SIDE_CLIENT); PJDLOG_ASSERT(uctx->uc_fd >= 0); - PJDLOG_ASSERT(timeout >= 0); + PJDLOG_ASSERT(timeout >= -1); if (connect(uctx->uc_fd, (struct sockaddr *)&uctx->uc_sun, sizeof(uctx->uc_sun)) < 0) { @@ -142,6 +142,20 @@ uds_connect(void *ctx, int timeout) } static int +uds_connect_wait(void *ctx, int timeout) +{ + struct uds_ctx *uctx = ctx; + + PJDLOG_ASSERT(uctx != NULL); + PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC); + PJDLOG_ASSERT(uctx->uc_side == UDS_SIDE_CLIENT); + PJDLOG_ASSERT(uctx->uc_fd >= 0); + PJDLOG_ASSERT(timeout >= 0); + + return (0); +} + +static int uds_server(const char *addr, void **ctxp) { struct uds_ctx *uctx; @@ -330,6 +344,7 @@ static struct hast_proto uds_proto = { .hp_name = "uds", .hp_client = uds_client, .hp_connect = uds_connect, + .hp_connect_wait = uds_connect_wait, .hp_server = uds_server, .hp_accept = uds_accept, .hp_send = uds_send, |