ACL_MBOX *acl_mbox_create(void) { ACL_MBOX *mbox; ACL_SOCKET fds[2]; if (acl_sane_socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { acl_msg_error("%s(%d), %s: acl_duplex_pipe error %s", __FILE__, __LINE__, __FUNCTION__, acl_last_serror()); return NULL; } mbox = (ACL_MBOX *) acl_mymalloc(sizeof(ACL_MBOX)); mbox->in = acl_vstream_fdopen(fds[0], O_RDONLY, sizeof(__key), 0, ACL_VSTREAM_TYPE_SOCK); mbox->out = acl_vstream_fdopen(fds[1], O_WRONLY, sizeof(__key), 0, ACL_VSTREAM_TYPE_SOCK); mbox->nsend = 0; mbox->nread = 0; mbox->ypipe = acl_ypipe_new(); mbox->lock = (acl_pthread_mutex_t *) acl_mycalloc(1, sizeof(acl_pthread_mutex_t)); if (acl_pthread_mutex_init(mbox->lock, NULL) != 0) acl_msg_fatal("%s(%d), %s: acl_pthread_mutex_init error", __FILE__, __LINE__, __FUNCTION__); return mbox; }
int acl_duplex_pipe(ACL_FILE_HANDLE fds[2]) { #if defined(HAS_DUPLEX_PIPE) return (acl_pipe(fds)); #else return (acl_sane_socketpair(AF_UNIX, SOCK_STREAM, 0, fds)); #endif }