/* handle a socket event */ static void master_socket_poll_event( struct fd *fd, int event ) { struct master_socket *sock = get_fd_user( fd ); assert( master_socket->obj.ops == &master_socket_ops ); assert( sock == master_socket ); /* there is only one master socket */ if (event & (POLLERR | POLLHUP)) { /* this is not supposed to happen */ fprintf( stderr, "wineserver: Error on master socket\n" ); release_object( sock ); } else if (event & POLLIN) { struct sockaddr_un dummy; unsigned int len = sizeof(dummy); int client = accept( get_unix_fd( master_socket->fd ), (struct sockaddr *) &dummy, &len ); if (client == -1) return; if (sock->timeout) { remove_timeout_user( sock->timeout ); sock->timeout = NULL; } fcntl( client, F_SETFL, O_NONBLOCK ); create_process( client, NULL, 0 ); } }
/* forced shutdown, used for wineserver -k */ void shutdown_master_socket(void) { kill_all_processes(); shutdown_stage = 2; if (shutdown_timeout) { remove_timeout_user( shutdown_timeout ); shutdown_timeout = NULL; } close_master_socket( 2 * -TICKS_PER_SEC ); /* for SIGKILL timeouts */ }
/* close the master socket and stop waiting for new clients */ void close_master_socket( timeout_t timeout ) { if (master_socket) { release_object( master_socket ); master_socket = NULL; } if (master_timeout) /* cancel previous timeout */ remove_timeout_user( master_timeout ); master_timeout = add_timeout_user( timeout, close_socket_timeout, NULL ); }
static void async_destroy( struct object *obj ) { struct async *async = (struct async *)obj; assert( obj->ops == &async_ops ); list_remove( &async->queue_entry ); async_reselect( async ); if (async->timeout) remove_timeout_user( async->timeout ); if (async->event) release_object( async->event ); release_object( async->queue ); release_object( async->thread ); }
static void async_destroy( struct object *obj ) { struct async *async = (struct async *)obj; assert( obj->ops == &async_ops ); list_remove( &async->process_entry ); if (async->queue) { list_remove( &async->queue_entry ); async_reselect( async ); } else if (async->fd) release_object( async->fd ); if (async->timeout) remove_timeout_user( async->timeout ); if (async->completion) release_object( async->completion ); if (async->event) release_object( async->event ); if (async->iosb) release_object( async->iosb ); release_object( async->thread ); }