Lines Matching +full:ipc +full:- +full:3

19  * 3. Neither the name of the Institute nor the names of its contributors
61 struct mach_ctx *ipc; in mach_init() local
67 syncq = dispatch_queue_create("heim-ipc-syncq", NULL); in mach_init()
74 ipc = malloc(sizeof(*ipc)); in mach_init()
75 if (ipc == NULL) { in mach_init()
80 ipc->server = sport; in mach_init()
81 ipc->name = strdup(service); in mach_init()
82 if (ipc->name == NULL) { in mach_init()
83 mach_release(ipc); in mach_init()
87 *ctx = ipc; in mach_init()
97 struct mach_ctx *ipc = ctx; in mach_ipc() local
108 memcpy(requestin, request->data, request->length); in mach_ipc()
109 requestin_length = request->length; in mach_ipc()
114 dispatch_sync(syncq, ^{ sport = ipc->server; }); in mach_ipc()
125 ret = bootstrap_look_up(bootstrap_port, ipc->name, &nport); in mach_ipc()
130 if (sport != ipc->server) { in mach_ipc()
133 mach_port_deallocate(mach_task_self(), ipc->server); in mach_ipc()
134 ipc->server = nport; in mach_ipc()
154 response->data = malloc(replyout_length); in mach_ipc()
155 if (response->data == NULL) { in mach_ipc()
160 memcpy(response->data, replyout, replyout_length); in mach_ipc()
161 response->length = replyout_length; in mach_ipc()
165 response->data = malloc(replyin_length); in mach_ipc()
166 if (response->data == NULL) in mach_ipc()
168 memcpy(response->data, replyin, replyin_length); in mach_ipc()
169 response->length = replyin_length; in mach_ipc()
206 (*c->func)(c->userctx, returnvalue, &response, NULL); in mheim_ado_acall_reply()
211 dispatch_source_cancel(c->source); in mheim_ado_acall_reply()
223 struct mach_ctx *ipc = ctx; in mach_async() local
239 kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &c->mp); in mach_async()
243 c->queue = dispatch_queue_create("heim-ipc-async-client", NULL); in mach_async()
244 c->source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, c->mp, 0, c->queue); in mach_async()
245 dispatch_set_context(c->queue, c); in mach_async()
247 dispatch_source_set_event_handler(c->source, ^{ in mach_async()
248 dispatch_mig_server(c->source, in mach_async()
253 dispatch_source_set_cancel_handler(c->source, ^{ in mach_async()
254 mach_port_mod_refs(mach_task_self(), c->mp, in mach_async()
255 MACH_PORT_RIGHT_RECEIVE, -1); in mach_async()
256 dispatch_release(c->queue); in mach_async()
257 dispatch_release(c->source); in mach_async()
261 c->func = func; in mach_async()
262 c->userctx = userctx; in mach_async()
264 dispatch_resume(c->source); in mach_async()
268 memcpy(requestin, request->data, request->length); in mach_async()
269 requestin_length = request->length; in mach_async()
274 dispatch_sync(syncq, ^{ sport = ipc->server; }); in mach_async()
276 ret = mheim_ipc_call_request(sport, c->mp, in mach_async()
280 ret = bootstrap_look_up(bootstrap_port, ipc->name, &sport); in mach_async()
282 dispatch_source_cancel(c->source); in mach_async()
285 mach_port_deallocate(mach_task_self(), ipc->server); in mach_async()
286 ipc->server = sport; in mach_async()
289 dispatch_source_cancel(c->source); in mach_async()
295 dispatch_source_cancel(c->source); in mach_async()
305 struct mach_ctx *ipc = ctx; in mach_release() local
306 if (ipc->server != MACH_PORT_NULL) in mach_release()
307 mach_port_deallocate(mach_task_self(), ipc->server); in mach_release()
308 free(ipc->name); in mach_release()
309 free(ipc); in mach_release()
328 strlcpy(addr.sun_path, s->path, sizeof(addr.sun_path)); in connect_unix()
330 s->fd = socket(AF_UNIX, SOCK_STREAM, 0); in connect_unix()
331 if (s->fd < 0) in connect_unix()
333 rk_cloexec(s->fd); in connect_unix()
335 if (connect(s->fd, (struct sockaddr *)&addr, sizeof(addr)) != 0) in connect_unix()
351 s->fd = -1; in common_path_init()
353 asprintf(&s->path, "/var/run/.heim_%s-%s", service, file); in common_path_init()
382 uint32_t len = htonl(req->length); in unix_socket_ipc()
389 rep->data = NULL; in unix_socket_ipc()
390 rep->length = 0; in unix_socket_ipc()
392 if (net_write(s->fd, &len, sizeof(len)) != sizeof(len)) in unix_socket_ipc()
393 return -1; in unix_socket_ipc()
394 if (net_write(s->fd, req->data, req->length) != (ssize_t)req->length) in unix_socket_ipc()
395 return -1; in unix_socket_ipc()
397 if (net_read(s->fd, &len, sizeof(len)) != sizeof(len)) in unix_socket_ipc()
398 return -1; in unix_socket_ipc()
399 if (net_read(s->fd, &rv, sizeof(rv)) != sizeof(rv)) in unix_socket_ipc()
400 return -1; in unix_socket_ipc()
403 rep->length = ntohl(len); in unix_socket_ipc()
404 if (rep->length > 0) { in unix_socket_ipc()
405 rep->data = malloc(rep->length); in unix_socket_ipc()
406 if (rep->data == NULL) in unix_socket_ipc()
407 return -1; in unix_socket_ipc()
408 if (net_read(s->fd, rep->data, rep->length) != (ssize_t)rep->length) in unix_socket_ipc()
409 return -1; in unix_socket_ipc()
411 rep->data = NULL; in unix_socket_ipc()
420 if (s->fd >= 0) in common_release()
421 close(s->fd); in common_release()
422 free(s->path); in common_release()
450 arg.data_ptr = request->data; in door_ipc()
451 arg.data_size = request->length; in door_ipc()
462 response->data = malloc(arg.rsize); in door_ipc()
463 if (response->data == NULL) { in door_ipc()
467 memcpy(response->data, arg.rbuf, arg.rsize); in door_ipc()
468 response->length = arg.rsize; in door_ipc()
480 int (*ipc)(void *,const heim_idata *, heim_idata *, heim_icred *); member
513 prefix_len = 3; in heim_ipc_init_context()
522 c->ops = &ipcs[i]; in heim_ipc_init_context()
524 ret = (c->ops->init)(name + prefix_len + 1, &c->ctx); in heim_ipc_init_context()
542 (ctx->ops->release)(ctx->ctx); in heim_ipc_free_context()
552 return (ctx->ops->ipc)(ctx->ctx, snd, rcv, cred); in heim_ipc_call()
559 if (ctx->ops->async == NULL) { in heim_ipc_async()
564 ret = (ctx->ops->ipc)(ctx->ctx, snd, &rcv, &cred); in heim_ipc_async()
570 return (ctx->ops->async)(ctx->ctx, snd, userctx, func); in heim_ipc_async()