Lines Matching defs:uctx

92 	struct uds_ctx *uctx;
95 uctx = malloc(sizeof(*uctx));
96 if (uctx == NULL)
100 if ((ret = uds_addr(addr, &uctx->uc_sun)) != 0) {
101 free(uctx);
105 uctx->uc_fd = socket(AF_UNIX, SOCK_STREAM, 0);
106 if (uctx->uc_fd == -1) {
108 free(uctx);
112 uctx->uc_side = side;
113 uctx->uc_owner = 0;
114 uctx->uc_magic = UDS_CTX_MAGIC;
115 *ctxp = uctx;
137 struct uds_ctx *uctx = ctx;
139 PJDLOG_ASSERT(uctx != NULL);
140 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
141 PJDLOG_ASSERT(uctx->uc_side == UDS_SIDE_CLIENT);
142 PJDLOG_ASSERT(uctx->uc_fd >= 0);
145 if (connect(uctx->uc_fd, (struct sockaddr *)&uctx->uc_sun,
146 sizeof(uctx->uc_sun)) == -1) {
156 struct uds_ctx *uctx = ctx;
158 PJDLOG_ASSERT(uctx != NULL);
159 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
160 PJDLOG_ASSERT(uctx->uc_side == UDS_SIDE_CLIENT);
161 PJDLOG_ASSERT(uctx->uc_fd >= 0);
170 struct uds_ctx *uctx;
177 uctx = *ctxp;
179 (void)unlink(uctx->uc_sun.sun_path);
180 if (bind(uctx->uc_fd, (struct sockaddr *)&uctx->uc_sun,
181 sizeof(uctx->uc_sun)) == -1) {
183 uds_close(uctx);
186 uctx->uc_owner = getpid();
187 if (listen(uctx->uc_fd, 8) == -1) {
189 uds_close(uctx);
199 struct uds_ctx *uctx = ctx;
204 PJDLOG_ASSERT(uctx != NULL);
205 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
206 PJDLOG_ASSERT(uctx->uc_side == UDS_SIDE_SERVER_LISTEN);
207 PJDLOG_ASSERT(uctx->uc_fd >= 0);
214 newuctx->uc_fd = accept(uctx->uc_fd,
232 struct uds_ctx *uctx = ctx;
234 PJDLOG_ASSERT(uctx != NULL);
235 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
236 PJDLOG_ASSERT(uctx->uc_fd >= 0);
238 return (proto_common_send(uctx->uc_fd, data, size, fd));
244 struct uds_ctx *uctx = ctx;
246 PJDLOG_ASSERT(uctx != NULL);
247 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
248 PJDLOG_ASSERT(uctx->uc_fd >= 0);
250 return (proto_common_recv(uctx->uc_fd, data, size, fdp));
256 const struct uds_ctx *uctx = ctx;
258 PJDLOG_ASSERT(uctx != NULL);
259 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
261 return (uctx->uc_fd);
267 const struct uds_ctx *uctx = ctx;
271 PJDLOG_ASSERT(uctx != NULL);
272 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
276 if (getsockname(uctx->uc_fd, (struct sockaddr *)&sun, &sunlen) == -1) {
291 const struct uds_ctx *uctx = ctx;
295 PJDLOG_ASSERT(uctx != NULL);
296 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
300 if (getpeername(uctx->uc_fd, (struct sockaddr *)&sun, &sunlen) == -1) {
315 struct uds_ctx *uctx = ctx;
317 PJDLOG_ASSERT(uctx != NULL);
318 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
320 if (uctx->uc_fd >= 0)
321 close(uctx->uc_fd);
326 if (uctx->uc_side == UDS_SIDE_SERVER_LISTEN &&
327 uctx->uc_owner == getpid()) {
328 PJDLOG_ASSERT(uctx->uc_sun.sun_path[0] != '\0');
329 if (unlink(uctx->uc_sun.sun_path) == -1) {
332 uctx->uc_sun.sun_path);
335 uctx->uc_owner = 0;
336 uctx->uc_magic = 0;
337 free(uctx);