2001-07-10 12:16:49 -07:00
|
|
|
/*
|
|
|
|
* Server-side pipe management
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998 Alexandre Julliard
|
2001-08-23 16:29:20 -07:00
|
|
|
* Copyright (C) 2001 Mike McCormack
|
|
|
|
*
|
2002-03-09 16:29:33 -07:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 05:49:52 -07:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-09 16:29:33 -07:00
|
|
|
*
|
2001-08-23 16:29:20 -07:00
|
|
|
* TODO:
|
2003-05-14 21:22:45 -07:00
|
|
|
* message mode
|
2001-07-10 12:16:49 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-04-26 12:05:15 -07:00
|
|
|
#include "wine/port.h"
|
2001-07-10 12:16:49 -07:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
2003-09-05 16:08:26 -07:00
|
|
|
#include <stdarg.h>
|
2001-07-10 12:16:49 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
2003-02-11 15:27:13 -07:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2001-07-10 12:16:49 -07:00
|
|
|
#include <sys/socket.h>
|
2003-02-11 15:27:13 -07:00
|
|
|
#endif
|
2001-07-10 12:16:49 -07:00
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
2005-03-04 05:38:36 -07:00
|
|
|
#ifdef HAVE_POLL_H
|
|
|
|
#include <poll.h>
|
|
|
|
#endif
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2005-11-28 09:32:54 -07:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2003-09-05 16:08:26 -07:00
|
|
|
#include "windef.h"
|
2005-06-08 12:11:46 -07:00
|
|
|
#include "winternl.h"
|
2007-04-16 05:51:29 -07:00
|
|
|
#include "winioctl.h"
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2003-01-29 17:26:44 -07:00
|
|
|
#include "file.h"
|
2001-07-10 12:16:49 -07:00
|
|
|
#include "handle.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "request.h"
|
2014-11-12 03:25:23 -07:00
|
|
|
#include "security.h"
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2001-08-23 16:29:20 -07:00
|
|
|
enum pipe_state
|
|
|
|
{
|
|
|
|
ps_idle_server,
|
|
|
|
ps_wait_open,
|
|
|
|
ps_connected_server,
|
2003-05-14 21:22:45 -07:00
|
|
|
ps_wait_disconnect,
|
|
|
|
ps_disconnected_server,
|
|
|
|
ps_wait_connect
|
|
|
|
};
|
|
|
|
|
2001-07-10 12:16:49 -07:00
|
|
|
struct named_pipe;
|
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
struct pipe_server
|
|
|
|
{
|
2005-02-03 03:48:23 -07:00
|
|
|
struct object obj; /* object header */
|
|
|
|
struct fd *fd; /* pipe file descriptor */
|
2007-04-18 07:26:37 -07:00
|
|
|
struct fd *ioctl_fd; /* file descriptor for ioctls when not connected */
|
2005-02-03 03:48:23 -07:00
|
|
|
struct list entry; /* entry in named pipe servers list */
|
|
|
|
enum pipe_state state; /* server state */
|
|
|
|
struct pipe_client *client; /* client that this server is connected to */
|
2003-05-14 21:22:45 -07:00
|
|
|
struct named_pipe *pipe;
|
|
|
|
struct timeout_user *flush_poll;
|
2005-06-08 12:11:46 -07:00
|
|
|
unsigned int options; /* pipe options */
|
2014-08-11 06:35:50 -07:00
|
|
|
unsigned int pipe_flags;
|
2003-05-14 21:22:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pipe_client
|
|
|
|
{
|
2005-02-03 03:48:23 -07:00
|
|
|
struct object obj; /* object header */
|
|
|
|
struct fd *fd; /* pipe file descriptor */
|
|
|
|
struct pipe_server *server; /* server that this client is connected to */
|
2005-06-08 12:11:46 -07:00
|
|
|
unsigned int flags; /* file flags */
|
2014-08-11 06:35:50 -07:00
|
|
|
unsigned int pipe_flags;
|
2001-07-10 12:16:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct named_pipe
|
|
|
|
{
|
|
|
|
struct object obj; /* object header */
|
2005-04-18 07:57:04 -07:00
|
|
|
unsigned int flags;
|
2011-09-26 04:57:15 -07:00
|
|
|
unsigned int sharing;
|
2001-07-10 12:16:49 -07:00
|
|
|
unsigned int maxinstances;
|
|
|
|
unsigned int outsize;
|
|
|
|
unsigned int insize;
|
2003-05-14 21:22:45 -07:00
|
|
|
unsigned int instances;
|
2007-04-17 11:08:59 -07:00
|
|
|
timeout_t timeout;
|
2005-02-03 03:48:23 -07:00
|
|
|
struct list servers; /* list of servers using this pipe */
|
2007-04-02 11:09:29 -07:00
|
|
|
struct async_queue *waiters; /* list of clients waiting to connect */
|
2001-07-10 12:16:49 -07:00
|
|
|
};
|
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
struct named_pipe_device
|
|
|
|
{
|
|
|
|
struct object obj; /* object header */
|
2005-12-12 06:30:06 -07:00
|
|
|
struct fd *fd; /* pseudo-fd for ioctls */
|
2005-12-05 05:09:35 -07:00
|
|
|
struct namespace *pipes; /* named pipe namespace */
|
|
|
|
};
|
|
|
|
|
2001-07-10 12:16:49 -07:00
|
|
|
static void named_pipe_dump( struct object *obj, int verbose );
|
2005-12-12 08:46:17 -07:00
|
|
|
static unsigned int named_pipe_map_access( struct object *obj, unsigned int access );
|
2007-03-22 08:47:46 -07:00
|
|
|
static struct object *named_pipe_open_file( struct object *obj, unsigned int access,
|
|
|
|
unsigned int sharing, unsigned int options );
|
2003-05-14 21:22:45 -07:00
|
|
|
static void named_pipe_destroy( struct object *obj );
|
2001-07-10 12:16:49 -07:00
|
|
|
|
|
|
|
static const struct object_ops named_pipe_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct named_pipe), /* size */
|
|
|
|
named_pipe_dump, /* dump */
|
2007-12-05 10:16:42 -07:00
|
|
|
no_get_type, /* get_type */
|
2001-07-10 12:16:49 -07:00
|
|
|
no_add_queue, /* add_queue */
|
|
|
|
NULL, /* remove_queue */
|
|
|
|
NULL, /* signaled */
|
|
|
|
NULL, /* satisfied */
|
2005-04-24 10:35:52 -07:00
|
|
|
no_signal, /* signal */
|
2001-07-10 12:16:49 -07:00
|
|
|
no_get_fd, /* get_fd */
|
2005-12-12 08:46:17 -07:00
|
|
|
named_pipe_map_access, /* map_access */
|
2007-10-03 05:10:37 -07:00
|
|
|
default_get_sd, /* get_sd */
|
|
|
|
default_set_sd, /* set_sd */
|
2005-11-22 07:55:42 -07:00
|
|
|
no_lookup_name, /* lookup_name */
|
2007-03-22 08:47:46 -07:00
|
|
|
named_pipe_open_file, /* open_file */
|
2005-06-09 08:39:52 -07:00
|
|
|
no_close_handle, /* close_handle */
|
2001-07-10 12:16:49 -07:00
|
|
|
named_pipe_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
/* server end functions */
|
|
|
|
static void pipe_server_dump( struct object *obj, int verbose );
|
|
|
|
static struct fd *pipe_server_get_fd( struct object *obj );
|
|
|
|
static void pipe_server_destroy( struct object *obj);
|
2015-05-04 20:23:08 -07:00
|
|
|
static obj_handle_t pipe_server_flush( struct fd *fd, const async_data_t *async, int blocking );
|
2007-04-10 13:26:23 -07:00
|
|
|
static enum server_fd_type pipe_server_get_fd_type( struct fd *fd );
|
2007-05-03 08:43:18 -07:00
|
|
|
static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async,
|
2015-05-04 20:02:59 -07:00
|
|
|
int blocking );
|
2003-05-14 21:22:45 -07:00
|
|
|
|
|
|
|
static const struct object_ops pipe_server_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct pipe_server), /* size */
|
|
|
|
pipe_server_dump, /* dump */
|
2007-12-05 10:16:42 -07:00
|
|
|
no_get_type, /* get_type */
|
2007-04-04 10:39:29 -07:00
|
|
|
add_queue, /* add_queue */
|
|
|
|
remove_queue, /* remove_queue */
|
2003-05-14 21:22:45 -07:00
|
|
|
default_fd_signaled, /* signaled */
|
|
|
|
no_satisfied, /* satisfied */
|
2005-04-24 10:35:52 -07:00
|
|
|
no_signal, /* signal */
|
2003-05-14 21:22:45 -07:00
|
|
|
pipe_server_get_fd, /* get_fd */
|
2007-10-02 05:20:15 -07:00
|
|
|
default_fd_map_access, /* map_access */
|
2007-10-03 05:10:37 -07:00
|
|
|
default_get_sd, /* get_sd */
|
|
|
|
default_set_sd, /* set_sd */
|
2005-11-22 07:55:42 -07:00
|
|
|
no_lookup_name, /* lookup_name */
|
2007-03-22 03:44:29 -07:00
|
|
|
no_open_file, /* open_file */
|
2006-11-02 12:52:22 -07:00
|
|
|
fd_close_handle, /* close_handle */
|
2003-05-14 21:22:45 -07:00
|
|
|
pipe_server_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct fd_ops pipe_server_fd_ops =
|
|
|
|
{
|
2007-04-10 08:07:27 -07:00
|
|
|
default_fd_get_poll_events, /* get_poll_events */
|
2003-05-14 21:22:45 -07:00
|
|
|
default_poll_event, /* poll_event */
|
2007-04-10 13:26:23 -07:00
|
|
|
pipe_server_get_fd_type, /* get_fd_type */
|
2015-05-04 20:17:45 -07:00
|
|
|
no_fd_read, /* read */
|
|
|
|
no_fd_write, /* write */
|
|
|
|
pipe_server_flush, /* flush */
|
2007-04-16 05:51:29 -07:00
|
|
|
pipe_server_ioctl, /* ioctl */
|
2005-06-08 12:11:46 -07:00
|
|
|
default_fd_queue_async, /* queue_async */
|
2007-04-10 08:07:27 -07:00
|
|
|
default_fd_reselect_async, /* reselect_async */
|
2005-06-08 12:11:46 -07:00
|
|
|
default_fd_cancel_async, /* cancel_async */
|
2003-05-14 21:22:45 -07:00
|
|
|
};
|
2003-02-18 17:33:32 -07:00
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
/* client end functions */
|
|
|
|
static void pipe_client_dump( struct object *obj, int verbose );
|
2013-08-26 02:55:04 -07:00
|
|
|
static int pipe_client_signaled( struct object *obj, struct wait_queue_entry *entry );
|
2003-05-14 21:22:45 -07:00
|
|
|
static struct fd *pipe_client_get_fd( struct object *obj );
|
|
|
|
static void pipe_client_destroy( struct object *obj );
|
2015-05-04 20:23:08 -07:00
|
|
|
static obj_handle_t pipe_client_flush( struct fd *fd, const async_data_t *async, int blocking );
|
2007-04-10 13:26:23 -07:00
|
|
|
static enum server_fd_type pipe_client_get_fd_type( struct fd *fd );
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
static const struct object_ops pipe_client_ops =
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
sizeof(struct pipe_client), /* size */
|
|
|
|
pipe_client_dump, /* dump */
|
2007-12-05 10:16:42 -07:00
|
|
|
no_get_type, /* get_type */
|
2007-04-04 10:39:29 -07:00
|
|
|
add_queue, /* add_queue */
|
|
|
|
remove_queue, /* remove_queue */
|
2009-06-09 03:11:05 -07:00
|
|
|
pipe_client_signaled, /* signaled */
|
2001-07-10 12:16:49 -07:00
|
|
|
no_satisfied, /* satisfied */
|
2005-04-24 10:35:52 -07:00
|
|
|
no_signal, /* signal */
|
2003-05-14 21:22:45 -07:00
|
|
|
pipe_client_get_fd, /* get_fd */
|
2007-10-02 05:20:15 -07:00
|
|
|
default_fd_map_access, /* map_access */
|
2007-10-03 05:10:37 -07:00
|
|
|
default_get_sd, /* get_sd */
|
|
|
|
default_set_sd, /* set_sd */
|
2005-11-22 07:55:42 -07:00
|
|
|
no_lookup_name, /* lookup_name */
|
2007-03-22 03:44:29 -07:00
|
|
|
no_open_file, /* open_file */
|
2006-11-02 12:52:22 -07:00
|
|
|
fd_close_handle, /* close_handle */
|
2003-05-14 21:22:45 -07:00
|
|
|
pipe_client_destroy /* destroy */
|
2003-01-29 17:26:44 -07:00
|
|
|
};
|
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
static const struct fd_ops pipe_client_fd_ops =
|
2003-01-29 17:26:44 -07:00
|
|
|
{
|
2005-06-08 12:11:46 -07:00
|
|
|
default_fd_get_poll_events, /* get_poll_events */
|
2001-07-10 12:16:49 -07:00
|
|
|
default_poll_event, /* poll_event */
|
2007-04-10 13:26:23 -07:00
|
|
|
pipe_client_get_fd_type, /* get_fd_type */
|
2015-05-04 20:17:45 -07:00
|
|
|
no_fd_read, /* read */
|
|
|
|
no_fd_write, /* write */
|
|
|
|
pipe_client_flush, /* flush */
|
2007-04-16 05:45:03 -07:00
|
|
|
default_fd_ioctl, /* ioctl */
|
2005-06-08 12:11:46 -07:00
|
|
|
default_fd_queue_async, /* queue_async */
|
2007-04-10 08:07:27 -07:00
|
|
|
default_fd_reselect_async, /* reselect_async */
|
2005-06-08 12:11:46 -07:00
|
|
|
default_fd_cancel_async /* cancel_async */
|
2001-07-10 12:16:49 -07:00
|
|
|
};
|
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
static void named_pipe_device_dump( struct object *obj, int verbose );
|
2007-12-05 10:16:42 -07:00
|
|
|
static struct object_type *named_pipe_device_get_type( struct object *obj );
|
2005-12-12 06:30:06 -07:00
|
|
|
static struct fd *named_pipe_device_get_fd( struct object *obj );
|
2005-12-05 05:09:35 -07:00
|
|
|
static struct object *named_pipe_device_lookup_name( struct object *obj,
|
|
|
|
struct unicode_str *name, unsigned int attr );
|
2007-03-22 03:52:40 -07:00
|
|
|
static struct object *named_pipe_device_open_file( struct object *obj, unsigned int access,
|
|
|
|
unsigned int sharing, unsigned int options );
|
2005-12-05 05:09:35 -07:00
|
|
|
static void named_pipe_device_destroy( struct object *obj );
|
2007-04-10 13:26:23 -07:00
|
|
|
static enum server_fd_type named_pipe_device_get_fd_type( struct fd *fd );
|
2015-05-04 20:02:59 -07:00
|
|
|
static obj_handle_t named_pipe_device_ioctl( struct fd *fd, ioctl_code_t code,
|
|
|
|
const async_data_t *async_data, int blocking );
|
2005-12-05 05:09:35 -07:00
|
|
|
|
|
|
|
static const struct object_ops named_pipe_device_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct named_pipe_device), /* size */
|
|
|
|
named_pipe_device_dump, /* dump */
|
2007-12-05 10:16:42 -07:00
|
|
|
named_pipe_device_get_type, /* get_type */
|
2005-12-05 05:09:35 -07:00
|
|
|
no_add_queue, /* add_queue */
|
|
|
|
NULL, /* remove_queue */
|
|
|
|
NULL, /* signaled */
|
|
|
|
no_satisfied, /* satisfied */
|
|
|
|
no_signal, /* signal */
|
2005-12-12 06:30:06 -07:00
|
|
|
named_pipe_device_get_fd, /* get_fd */
|
2007-04-18 07:32:31 -07:00
|
|
|
no_map_access, /* map_access */
|
2007-10-03 05:10:37 -07:00
|
|
|
default_get_sd, /* get_sd */
|
|
|
|
default_set_sd, /* set_sd */
|
2005-12-05 05:09:35 -07:00
|
|
|
named_pipe_device_lookup_name, /* lookup_name */
|
2007-03-22 03:52:40 -07:00
|
|
|
named_pipe_device_open_file, /* open_file */
|
2006-11-02 12:52:22 -07:00
|
|
|
fd_close_handle, /* close_handle */
|
2005-12-05 05:09:35 -07:00
|
|
|
named_pipe_device_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
2005-12-12 06:30:06 -07:00
|
|
|
static const struct fd_ops named_pipe_device_fd_ops =
|
|
|
|
{
|
2005-12-13 04:00:11 -07:00
|
|
|
default_fd_get_poll_events, /* get_poll_events */
|
|
|
|
default_poll_event, /* poll_event */
|
2007-04-10 13:26:23 -07:00
|
|
|
named_pipe_device_get_fd_type, /* get_fd_type */
|
2015-05-04 20:17:45 -07:00
|
|
|
no_fd_read, /* read */
|
|
|
|
no_fd_write, /* write */
|
|
|
|
no_fd_flush, /* flush */
|
2007-04-17 13:07:07 -07:00
|
|
|
named_pipe_device_ioctl, /* ioctl */
|
2005-12-13 04:00:11 -07:00
|
|
|
default_fd_queue_async, /* queue_async */
|
2007-04-10 08:07:27 -07:00
|
|
|
default_fd_reselect_async, /* reselect_async */
|
2005-12-13 04:00:11 -07:00
|
|
|
default_fd_cancel_async /* cancel_async */
|
2005-12-12 06:30:06 -07:00
|
|
|
};
|
|
|
|
|
2001-07-10 12:16:49 -07:00
|
|
|
static void named_pipe_dump( struct object *obj, int verbose )
|
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
struct named_pipe *pipe = (struct named_pipe *) obj;
|
2001-07-10 12:16:49 -07:00
|
|
|
assert( obj->ops == &named_pipe_ops );
|
2005-02-03 03:48:23 -07:00
|
|
|
fprintf( stderr, "Named pipe " );
|
|
|
|
dump_object_name( &pipe->obj );
|
|
|
|
fprintf( stderr, "\n" );
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
|
|
|
|
2005-12-12 08:46:17 -07:00
|
|
|
static unsigned int named_pipe_map_access( struct object *obj, unsigned int access )
|
|
|
|
{
|
|
|
|
if (access & GENERIC_READ) access |= STANDARD_RIGHTS_READ;
|
|
|
|
if (access & GENERIC_WRITE) access |= STANDARD_RIGHTS_WRITE | FILE_CREATE_PIPE_INSTANCE;
|
|
|
|
if (access & GENERIC_EXECUTE) access |= STANDARD_RIGHTS_EXECUTE;
|
|
|
|
if (access & GENERIC_ALL) access |= STANDARD_RIGHTS_ALL;
|
|
|
|
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
|
|
|
}
|
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
static void pipe_server_dump( struct object *obj, int verbose )
|
|
|
|
{
|
|
|
|
struct pipe_server *server = (struct pipe_server *) obj;
|
|
|
|
assert( obj->ops == &pipe_server_ops );
|
2005-02-03 03:48:23 -07:00
|
|
|
fprintf( stderr, "Named pipe server pipe=%p state=%d\n", server->pipe, server->state );
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_client_dump( struct object *obj, int verbose )
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
struct pipe_client *client = (struct pipe_client *) obj;
|
2005-02-03 03:48:23 -07:00
|
|
|
assert( obj->ops == &pipe_client_ops );
|
|
|
|
fprintf( stderr, "Named pipe client server=%p\n", client->server );
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
|
|
|
|
2013-08-26 02:55:04 -07:00
|
|
|
static int pipe_client_signaled( struct object *obj, struct wait_queue_entry *entry )
|
2009-06-09 03:11:05 -07:00
|
|
|
{
|
|
|
|
struct pipe_client *client = (struct pipe_client *) obj;
|
|
|
|
|
|
|
|
return client->fd && is_fd_signaled(client->fd);
|
|
|
|
}
|
|
|
|
|
2005-02-03 03:48:23 -07:00
|
|
|
static void named_pipe_destroy( struct object *obj)
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe = (struct named_pipe *) obj;
|
|
|
|
|
|
|
|
assert( list_empty( &pipe->servers ) );
|
|
|
|
assert( !pipe->instances );
|
2007-04-03 10:36:07 -07:00
|
|
|
free_async_queue( pipe->waiters );
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct fd *pipe_client_get_fd( struct object *obj )
|
|
|
|
{
|
|
|
|
struct pipe_client *client = (struct pipe_client *) obj;
|
2005-06-10 12:54:46 -07:00
|
|
|
if (client->fd)
|
2003-05-14 21:22:45 -07:00
|
|
|
return (struct fd *) grab_object( client->fd );
|
2003-04-16 19:14:04 -07:00
|
|
|
set_error( STATUS_PIPE_DISCONNECTED );
|
|
|
|
return NULL;
|
2003-02-18 17:33:32 -07:00
|
|
|
}
|
|
|
|
|
2007-04-18 07:26:37 -07:00
|
|
|
static void set_server_state( struct pipe_server *server, enum pipe_state state )
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
2007-04-18 07:26:37 -07:00
|
|
|
server->state = state;
|
2003-05-14 21:22:45 -07:00
|
|
|
|
2007-04-18 07:26:37 -07:00
|
|
|
switch(state)
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
|
|
|
case ps_connected_server:
|
|
|
|
case ps_wait_disconnect:
|
|
|
|
assert( server->fd );
|
2007-04-18 07:26:37 -07:00
|
|
|
break;
|
2003-05-14 21:22:45 -07:00
|
|
|
case ps_wait_open:
|
|
|
|
case ps_idle_server:
|
2007-04-18 07:26:37 -07:00
|
|
|
assert( !server->fd );
|
|
|
|
set_no_fd_status( server->ioctl_fd, STATUS_PIPE_LISTENING );
|
2003-05-14 21:22:45 -07:00
|
|
|
break;
|
|
|
|
case ps_disconnected_server:
|
|
|
|
case ps_wait_connect:
|
2007-04-18 07:26:37 -07:00
|
|
|
assert( !server->fd );
|
|
|
|
set_no_fd_status( server->ioctl_fd, STATUS_PIPE_DISCONNECTED );
|
2003-05-14 21:22:45 -07:00
|
|
|
break;
|
|
|
|
}
|
2007-04-18 07:26:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct fd *pipe_server_get_fd( struct object *obj )
|
|
|
|
{
|
|
|
|
struct pipe_server *server = (struct pipe_server *) obj;
|
|
|
|
|
|
|
|
return (struct fd *)grab_object( server->fd ? server->fd : server->ioctl_fd );
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void notify_empty( struct pipe_server *server )
|
|
|
|
{
|
2005-06-10 12:54:46 -07:00
|
|
|
if (!server->flush_poll)
|
2003-05-14 21:22:45 -07:00
|
|
|
return;
|
|
|
|
assert( server->state == ps_connected_server );
|
|
|
|
remove_timeout_user( server->flush_poll );
|
|
|
|
server->flush_poll = NULL;
|
2015-05-08 02:01:08 -07:00
|
|
|
fd_async_wake_up( server->fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_disconnect( struct pipe_server *server )
|
|
|
|
{
|
|
|
|
/* we may only have a server fd, if the client disconnected */
|
2005-06-10 12:54:46 -07:00
|
|
|
if (server->client)
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
|
|
|
assert( server->client->server == server );
|
|
|
|
assert( server->client->fd );
|
|
|
|
release_object( server->client->fd );
|
|
|
|
server->client->fd = NULL;
|
|
|
|
}
|
|
|
|
assert( server->fd );
|
2007-04-10 12:30:37 -07:00
|
|
|
shutdown( get_unix_fd( server->fd ), SHUT_RDWR );
|
2003-05-14 21:22:45 -07:00
|
|
|
release_object( server->fd );
|
|
|
|
server->fd = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_server_destroy( struct object *obj)
|
|
|
|
{
|
|
|
|
struct pipe_server *server = (struct pipe_server *)obj;
|
|
|
|
|
|
|
|
assert( obj->ops == &pipe_server_ops );
|
|
|
|
|
2005-06-10 12:54:46 -07:00
|
|
|
if (server->fd)
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
|
|
|
notify_empty( server );
|
|
|
|
do_disconnect( server );
|
|
|
|
}
|
|
|
|
|
2005-06-10 12:54:46 -07:00
|
|
|
if (server->client)
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
|
|
|
server->client->server = NULL;
|
|
|
|
server->client = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert( server->pipe->instances );
|
|
|
|
server->pipe->instances--;
|
|
|
|
|
2007-04-18 07:26:37 -07:00
|
|
|
if (server->ioctl_fd) release_object( server->ioctl_fd );
|
2005-02-03 03:48:23 -07:00
|
|
|
list_remove( &server->entry );
|
2003-05-14 21:22:45 -07:00
|
|
|
release_object( server->pipe );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_client_destroy( struct object *obj)
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
struct pipe_client *client = (struct pipe_client *)obj;
|
|
|
|
struct pipe_server *server = client->server;
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
assert( obj->ops == &pipe_client_ops );
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2005-06-10 12:54:46 -07:00
|
|
|
if (server)
|
2001-08-23 16:29:20 -07:00
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
notify_empty( server );
|
|
|
|
|
2005-06-10 12:54:46 -07:00
|
|
|
switch(server->state)
|
2001-08-23 16:29:20 -07:00
|
|
|
{
|
|
|
|
case ps_connected_server:
|
2003-05-14 21:22:45 -07:00
|
|
|
/* Don't destroy the server's fd here as we can't
|
|
|
|
do a successful flush without it. */
|
2007-04-18 07:26:37 -07:00
|
|
|
set_server_state( server, ps_wait_disconnect );
|
2001-08-23 16:29:20 -07:00
|
|
|
break;
|
2003-05-14 21:22:45 -07:00
|
|
|
case ps_disconnected_server:
|
2007-04-18 07:26:37 -07:00
|
|
|
set_server_state( server, ps_wait_connect );
|
2001-08-23 16:29:20 -07:00
|
|
|
break;
|
2005-02-03 03:48:23 -07:00
|
|
|
case ps_idle_server:
|
|
|
|
case ps_wait_open:
|
|
|
|
case ps_wait_disconnect:
|
|
|
|
case ps_wait_connect:
|
2003-05-14 21:22:45 -07:00
|
|
|
assert( 0 );
|
2001-08-23 16:29:20 -07:00
|
|
|
}
|
2003-05-14 21:22:45 -07:00
|
|
|
assert( server->client );
|
|
|
|
server->client = NULL;
|
|
|
|
client->server = NULL;
|
2001-08-23 16:29:20 -07:00
|
|
|
}
|
2007-04-18 07:26:37 -07:00
|
|
|
if (client->fd) release_object( client->fd );
|
2003-02-18 17:33:32 -07:00
|
|
|
}
|
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
static void named_pipe_device_dump( struct object *obj, int verbose )
|
|
|
|
{
|
|
|
|
assert( obj->ops == &named_pipe_device_ops );
|
|
|
|
fprintf( stderr, "Named pipe device\n" );
|
|
|
|
}
|
|
|
|
|
2007-12-05 10:16:42 -07:00
|
|
|
static struct object_type *named_pipe_device_get_type( struct object *obj )
|
|
|
|
{
|
|
|
|
static const WCHAR name[] = {'D','e','v','i','c','e'};
|
|
|
|
static const struct unicode_str str = { name, sizeof(name) };
|
|
|
|
return get_object_type( &str );
|
|
|
|
}
|
|
|
|
|
2005-12-12 06:30:06 -07:00
|
|
|
static struct fd *named_pipe_device_get_fd( struct object *obj )
|
|
|
|
{
|
|
|
|
struct named_pipe_device *device = (struct named_pipe_device *)obj;
|
2005-12-13 03:22:28 -07:00
|
|
|
return (struct fd *)grab_object( device->fd );
|
2005-12-12 06:30:06 -07:00
|
|
|
}
|
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
static struct object *named_pipe_device_lookup_name( struct object *obj, struct unicode_str *name,
|
|
|
|
unsigned int attr )
|
|
|
|
{
|
|
|
|
struct named_pipe_device *device = (struct named_pipe_device*)obj;
|
|
|
|
struct object *found;
|
|
|
|
|
|
|
|
assert( obj->ops == &named_pipe_device_ops );
|
|
|
|
assert( device->pipes );
|
|
|
|
|
|
|
|
if ((found = find_object( device->pipes, name, attr | OBJ_CASE_INSENSITIVE )))
|
|
|
|
name->len = 0;
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2007-03-22 03:52:40 -07:00
|
|
|
static struct object *named_pipe_device_open_file( struct object *obj, unsigned int access,
|
|
|
|
unsigned int sharing, unsigned int options )
|
|
|
|
{
|
|
|
|
return grab_object( obj );
|
|
|
|
}
|
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
static void named_pipe_device_destroy( struct object *obj )
|
|
|
|
{
|
|
|
|
struct named_pipe_device *device = (struct named_pipe_device*)obj;
|
|
|
|
assert( obj->ops == &named_pipe_device_ops );
|
2005-12-12 06:30:06 -07:00
|
|
|
if (device->fd) release_object( device->fd );
|
2006-10-09 14:34:36 -07:00
|
|
|
free( device->pipes );
|
2005-12-05 05:09:35 -07:00
|
|
|
}
|
|
|
|
|
2007-04-10 13:26:23 -07:00
|
|
|
static enum server_fd_type named_pipe_device_get_fd_type( struct fd *fd )
|
2005-12-13 04:00:11 -07:00
|
|
|
{
|
2006-11-20 06:14:04 -07:00
|
|
|
return FD_TYPE_DEVICE;
|
2005-12-13 04:00:11 -07:00
|
|
|
}
|
|
|
|
|
2006-03-22 12:32:04 -07:00
|
|
|
void create_named_pipe_device( struct directory *root, const struct unicode_str *name )
|
2005-12-05 05:09:35 -07:00
|
|
|
{
|
|
|
|
struct named_pipe_device *dev;
|
|
|
|
|
2005-12-05 06:52:02 -07:00
|
|
|
if ((dev = create_named_object_dir( root, name, 0, &named_pipe_device_ops )) &&
|
2005-12-05 05:09:35 -07:00
|
|
|
get_error() != STATUS_OBJECT_NAME_EXISTS)
|
|
|
|
{
|
2005-12-12 06:30:06 -07:00
|
|
|
dev->pipes = NULL;
|
2007-05-03 07:07:30 -07:00
|
|
|
if (!(dev->fd = alloc_pseudo_fd( &named_pipe_device_fd_ops, &dev->obj, 0 )) ||
|
2005-12-12 06:30:06 -07:00
|
|
|
!(dev->pipes = create_namespace( 7 )))
|
2005-12-05 05:09:35 -07:00
|
|
|
{
|
|
|
|
release_object( dev );
|
|
|
|
dev = NULL;
|
|
|
|
}
|
|
|
|
}
|
2006-03-22 12:32:04 -07:00
|
|
|
if (dev) make_object_static( &dev->obj );
|
2005-12-05 05:09:35 -07:00
|
|
|
}
|
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
static int pipe_data_remaining( struct pipe_server *server )
|
|
|
|
{
|
|
|
|
struct pollfd pfd;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
assert( server->client );
|
|
|
|
|
|
|
|
fd = get_unix_fd( server->client->fd );
|
2005-06-10 12:54:46 -07:00
|
|
|
if (fd < 0)
|
2003-05-14 21:22:45 -07:00
|
|
|
return 0;
|
|
|
|
pfd.fd = fd;
|
|
|
|
pfd.events = POLLIN;
|
|
|
|
pfd.revents = 0;
|
|
|
|
|
2005-06-10 12:54:46 -07:00
|
|
|
if (0 > poll( &pfd, 1, 0 ))
|
2003-05-14 21:22:45 -07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return pfd.revents&POLLIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_flushed( void *arg )
|
|
|
|
{
|
|
|
|
struct pipe_server *server = (struct pipe_server*) arg;
|
|
|
|
|
2005-06-10 12:54:46 -07:00
|
|
|
if (pipe_data_remaining( server ))
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
2007-04-17 11:08:59 -07:00
|
|
|
server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server );
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
else
|
2004-07-15 11:59:58 -07:00
|
|
|
{
|
|
|
|
server->flush_poll = NULL;
|
2015-05-08 02:01:08 -07:00
|
|
|
fd_async_wake_up( server->fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
|
2004-07-15 11:59:58 -07:00
|
|
|
}
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
|
2015-05-08 02:01:08 -07:00
|
|
|
static obj_handle_t pipe_server_flush( struct fd *fd, const async_data_t *async_data, int blocking )
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
|
|
|
struct pipe_server *server = get_fd_user( fd );
|
2015-05-04 20:23:08 -07:00
|
|
|
obj_handle_t handle = 0;
|
2015-05-08 02:01:08 -07:00
|
|
|
struct async *async;
|
2003-05-14 21:22:45 -07:00
|
|
|
|
2015-05-04 20:23:08 -07:00
|
|
|
if (!server || server->state != ps_connected_server) return 0;
|
2003-05-14 21:22:45 -07:00
|
|
|
|
2015-05-08 02:01:08 -07:00
|
|
|
if (!pipe_data_remaining( server )) return 0;
|
2003-05-14 21:22:45 -07:00
|
|
|
|
2015-05-08 02:01:08 -07:00
|
|
|
if ((async = fd_queue_async( server->fd, async_data, ASYNC_TYPE_WAIT )))
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
2015-05-08 02:01:08 -07:00
|
|
|
/* there's no unix way to be alerted when a pipe becomes empty, so resort to polling */
|
|
|
|
if (!server->flush_poll)
|
|
|
|
server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server );
|
|
|
|
if (blocking) handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
|
2015-05-08 09:02:20 -07:00
|
|
|
release_object( async );
|
2015-05-04 20:23:08 -07:00
|
|
|
set_error( STATUS_PENDING );
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
2015-05-04 20:23:08 -07:00
|
|
|
return handle;
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
|
2015-05-04 20:23:08 -07:00
|
|
|
static obj_handle_t pipe_client_flush( struct fd *fd, const async_data_t *async, int blocking )
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
|
|
|
/* FIXME: what do we have to do for this? */
|
2015-05-04 20:23:08 -07:00
|
|
|
return 0;
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
|
|
|
|
2005-06-08 12:11:46 -07:00
|
|
|
static inline int is_overlapped( unsigned int options )
|
2001-10-05 12:45:45 -07:00
|
|
|
{
|
2005-06-08 12:11:46 -07:00
|
|
|
return !(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT));
|
|
|
|
}
|
|
|
|
|
2007-04-10 13:26:23 -07:00
|
|
|
static enum server_fd_type pipe_server_get_fd_type( struct fd *fd )
|
2005-06-08 12:11:46 -07:00
|
|
|
{
|
2006-11-20 06:14:04 -07:00
|
|
|
return FD_TYPE_PIPE;
|
2005-06-08 12:11:46 -07:00
|
|
|
}
|
|
|
|
|
2007-04-10 13:26:23 -07:00
|
|
|
static enum server_fd_type pipe_client_get_fd_type( struct fd *fd )
|
2005-06-08 12:11:46 -07:00
|
|
|
{
|
2006-11-20 06:14:04 -07:00
|
|
|
return FD_TYPE_PIPE;
|
2001-10-05 12:45:45 -07:00
|
|
|
}
|
|
|
|
|
2007-05-03 08:43:18 -07:00
|
|
|
static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async_data,
|
2015-05-04 20:02:59 -07:00
|
|
|
int blocking )
|
2007-04-16 05:51:29 -07:00
|
|
|
{
|
|
|
|
struct pipe_server *server = get_fd_user( fd );
|
2007-04-18 07:26:37 -07:00
|
|
|
struct async *async;
|
2007-05-03 08:44:05 -07:00
|
|
|
obj_handle_t wait_handle = 0;
|
2007-04-16 05:51:29 -07:00
|
|
|
|
|
|
|
switch(code)
|
|
|
|
{
|
2007-04-18 07:26:37 -07:00
|
|
|
case FSCTL_PIPE_LISTEN:
|
|
|
|
switch(server->state)
|
|
|
|
{
|
|
|
|
case ps_idle_server:
|
|
|
|
case ps_wait_connect:
|
2015-05-08 01:32:06 -07:00
|
|
|
if ((async = fd_queue_async( server->ioctl_fd, async_data, ASYNC_TYPE_WAIT )))
|
2007-04-18 07:26:37 -07:00
|
|
|
{
|
2015-05-08 01:32:06 -07:00
|
|
|
if (blocking) wait_handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
|
2007-05-03 08:44:05 -07:00
|
|
|
set_server_state( server, ps_wait_open );
|
2007-04-18 07:26:37 -07:00
|
|
|
if (server->pipe->waiters) async_wake_up( server->pipe->waiters, STATUS_SUCCESS );
|
|
|
|
release_object( async );
|
|
|
|
set_error( STATUS_PENDING );
|
2007-05-03 08:44:05 -07:00
|
|
|
return wait_handle;
|
2007-04-18 07:26:37 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ps_connected_server:
|
|
|
|
set_error( STATUS_PIPE_CONNECTED );
|
|
|
|
break;
|
|
|
|
case ps_disconnected_server:
|
|
|
|
set_error( STATUS_PIPE_BUSY );
|
|
|
|
break;
|
|
|
|
case ps_wait_disconnect:
|
|
|
|
set_error( STATUS_NO_DATA_DETECTED );
|
|
|
|
break;
|
|
|
|
case ps_wait_open:
|
|
|
|
set_error( STATUS_INVALID_HANDLE );
|
|
|
|
break;
|
|
|
|
}
|
2007-05-03 08:43:18 -07:00
|
|
|
return 0;
|
2007-04-18 07:26:37 -07:00
|
|
|
|
2007-04-16 05:51:29 -07:00
|
|
|
case FSCTL_PIPE_DISCONNECT:
|
|
|
|
switch(server->state)
|
|
|
|
{
|
|
|
|
case ps_connected_server:
|
|
|
|
assert( server->client );
|
|
|
|
assert( server->client->fd );
|
|
|
|
|
|
|
|
notify_empty( server );
|
|
|
|
|
|
|
|
/* dump the client and server fds, but keep the pointers
|
|
|
|
around - client loses all waiting data */
|
|
|
|
do_disconnect( server );
|
2007-04-18 07:26:37 -07:00
|
|
|
set_server_state( server, ps_disconnected_server );
|
2007-04-16 05:51:29 -07:00
|
|
|
break;
|
|
|
|
case ps_wait_disconnect:
|
|
|
|
assert( !server->client );
|
|
|
|
do_disconnect( server );
|
2007-04-18 07:26:37 -07:00
|
|
|
set_server_state( server, ps_wait_connect );
|
2007-04-16 05:51:29 -07:00
|
|
|
break;
|
|
|
|
case ps_idle_server:
|
|
|
|
case ps_wait_open:
|
2007-04-18 07:26:37 -07:00
|
|
|
set_error( STATUS_PIPE_LISTENING );
|
|
|
|
break;
|
2007-04-16 05:51:29 -07:00
|
|
|
case ps_disconnected_server:
|
|
|
|
case ps_wait_connect:
|
2007-04-18 07:26:37 -07:00
|
|
|
set_error( STATUS_PIPE_DISCONNECTED );
|
2007-04-16 05:51:29 -07:00
|
|
|
break;
|
|
|
|
}
|
2007-05-03 08:43:18 -07:00
|
|
|
return 0;
|
2007-04-18 07:26:37 -07:00
|
|
|
|
2007-04-16 05:51:29 -07:00
|
|
|
default:
|
2015-05-04 20:02:59 -07:00
|
|
|
return default_fd_ioctl( fd, code, async_data, blocking );
|
2007-04-16 05:51:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
static struct named_pipe *create_named_pipe( struct directory *root, const struct unicode_str *name,
|
2014-11-12 03:25:23 -07:00
|
|
|
unsigned int attr, const struct security_descriptor *sd )
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2005-12-05 05:09:35 -07:00
|
|
|
struct object *obj;
|
|
|
|
struct named_pipe *pipe = NULL;
|
|
|
|
struct unicode_str new_name;
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2015-11-01 22:02:16 -07:00
|
|
|
if (!name || !name->len)
|
|
|
|
{
|
|
|
|
if ((pipe = alloc_object( &named_pipe_ops ))) clear_error();
|
|
|
|
return pipe;
|
|
|
|
}
|
2005-12-05 05:09:35 -07:00
|
|
|
|
2007-03-22 06:40:41 -07:00
|
|
|
if (!(obj = find_object_dir( root, name, attr, &new_name )))
|
|
|
|
{
|
|
|
|
set_error( STATUS_OBJECT_NAME_INVALID );
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-12-05 05:09:35 -07:00
|
|
|
if (!new_name.len)
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2005-12-05 05:09:35 -07:00
|
|
|
if (attr & OBJ_OPENIF && obj->ops == &named_pipe_ops)
|
|
|
|
set_error( STATUS_OBJECT_NAME_EXISTS );
|
|
|
|
else
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2005-12-05 05:09:35 -07:00
|
|
|
release_object( obj );
|
|
|
|
obj = NULL;
|
|
|
|
if (attr & OBJ_OPENIF)
|
|
|
|
set_error( STATUS_OBJECT_TYPE_MISMATCH );
|
|
|
|
else
|
|
|
|
set_error( STATUS_OBJECT_NAME_COLLISION );
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
2005-12-05 05:09:35 -07:00
|
|
|
return (struct named_pipe *)obj;
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
2003-02-18 17:33:32 -07:00
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
if (obj->ops != &named_pipe_device_ops)
|
2007-03-22 06:40:41 -07:00
|
|
|
set_error( STATUS_OBJECT_NAME_INVALID );
|
2005-12-05 05:09:35 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
struct named_pipe_device *dev = (struct named_pipe_device *)obj;
|
|
|
|
if ((pipe = create_object( dev->pipes, &named_pipe_ops, &new_name, NULL )))
|
|
|
|
clear_error();
|
2003-02-18 17:33:32 -07:00
|
|
|
}
|
|
|
|
|
2005-12-05 05:09:35 -07:00
|
|
|
release_object( obj );
|
|
|
|
return pipe;
|
2003-02-18 17:33:32 -07:00
|
|
|
}
|
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
static struct pipe_server *get_pipe_server_obj( struct process *process,
|
|
|
|
obj_handle_t handle, unsigned int access )
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
struct object *obj;
|
|
|
|
obj = get_handle_obj( process, handle, access, &pipe_server_ops );
|
|
|
|
return (struct pipe_server *) obj;
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
|
|
|
|
2014-08-11 06:35:50 -07:00
|
|
|
static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned int options,
|
|
|
|
unsigned int pipe_flags )
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
struct pipe_server *server;
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
server = alloc_object( &pipe_server_ops );
|
2005-06-10 12:54:46 -07:00
|
|
|
if (!server)
|
2001-07-10 12:16:49 -07:00
|
|
|
return NULL;
|
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
server->fd = NULL;
|
|
|
|
server->pipe = pipe;
|
|
|
|
server->client = NULL;
|
|
|
|
server->flush_poll = NULL;
|
2005-06-08 12:11:46 -07:00
|
|
|
server->options = options;
|
2014-08-11 06:35:50 -07:00
|
|
|
server->pipe_flags = pipe_flags;
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2005-02-03 03:48:23 -07:00
|
|
|
list_add_head( &pipe->servers, &server->entry );
|
2003-05-14 21:22:45 -07:00
|
|
|
grab_object( pipe );
|
2007-05-03 07:07:30 -07:00
|
|
|
if (!(server->ioctl_fd = alloc_pseudo_fd( &pipe_server_fd_ops, &server->obj, options )))
|
2007-04-18 07:26:37 -07:00
|
|
|
{
|
|
|
|
release_object( server );
|
2007-05-08 12:13:14 -07:00
|
|
|
return NULL;
|
2007-04-18 07:26:37 -07:00
|
|
|
}
|
|
|
|
set_server_state( server, ps_idle_server );
|
2003-05-14 21:22:45 -07:00
|
|
|
return server;
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
|
|
|
|
2014-08-11 06:35:50 -07:00
|
|
|
static struct pipe_client *create_pipe_client( unsigned int flags, unsigned int pipe_flags )
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
struct pipe_client *client;
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2003-05-14 21:22:45 -07:00
|
|
|
client = alloc_object( &pipe_client_ops );
|
2005-06-10 12:54:46 -07:00
|
|
|
if (!client)
|
2003-05-14 21:22:45 -07:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
client->fd = NULL;
|
2006-06-07 12:11:59 -07:00
|
|
|
client->server = NULL;
|
2005-06-08 12:11:46 -07:00
|
|
|
client->flags = flags;
|
2014-08-11 06:35:50 -07:00
|
|
|
client->pipe_flags = pipe_flags;
|
2003-05-14 21:22:45 -07:00
|
|
|
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
|
2007-03-23 06:03:23 -07:00
|
|
|
static struct pipe_server *find_available_server( struct named_pipe *pipe )
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
2005-02-03 03:48:23 -07:00
|
|
|
struct pipe_server *server;
|
2003-05-14 21:22:45 -07:00
|
|
|
|
2008-02-04 13:18:34 -07:00
|
|
|
/* look for pipe servers that are listening */
|
2005-02-03 03:48:23 -07:00
|
|
|
LIST_FOR_EACH_ENTRY( server, &pipe->servers, struct pipe_server, entry )
|
|
|
|
{
|
2008-02-04 13:18:34 -07:00
|
|
|
if (server->state == ps_wait_open)
|
2005-02-03 03:48:23 -07:00
|
|
|
return (struct pipe_server *)grab_object( server );
|
|
|
|
}
|
2008-02-04 13:18:34 -07:00
|
|
|
|
|
|
|
/* fall back to pipe servers that are idle */
|
|
|
|
LIST_FOR_EACH_ENTRY( server, &pipe->servers, struct pipe_server, entry )
|
|
|
|
{
|
|
|
|
if (server->state == ps_idle_server)
|
|
|
|
return (struct pipe_server *)grab_object( server );
|
|
|
|
}
|
|
|
|
|
2005-02-03 03:48:23 -07:00
|
|
|
return NULL;
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 08:47:46 -07:00
|
|
|
static struct object *named_pipe_open_file( struct object *obj, unsigned int access,
|
|
|
|
unsigned int sharing, unsigned int options )
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe = (struct named_pipe *)obj;
|
|
|
|
struct pipe_server *server;
|
|
|
|
struct pipe_client *client;
|
2011-09-29 02:20:50 -07:00
|
|
|
unsigned int pipe_sharing;
|
2007-03-22 08:47:46 -07:00
|
|
|
int fds[2];
|
|
|
|
|
2007-03-23 06:03:23 -07:00
|
|
|
if (!(server = find_available_server( pipe )))
|
2007-03-22 08:47:46 -07:00
|
|
|
{
|
|
|
|
set_error( STATUS_PIPE_NOT_AVAILABLE );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-09-29 02:20:50 -07:00
|
|
|
pipe_sharing = server->pipe->sharing;
|
|
|
|
if (((access & GENERIC_READ) && !(pipe_sharing & FILE_SHARE_READ)) ||
|
|
|
|
((access & GENERIC_WRITE) && !(pipe_sharing & FILE_SHARE_WRITE)))
|
|
|
|
{
|
|
|
|
set_error( STATUS_ACCESS_DENIED );
|
|
|
|
release_object( server );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-11 06:35:50 -07:00
|
|
|
if ((client = create_pipe_client( options, pipe->flags )))
|
2007-03-22 08:47:46 -07:00
|
|
|
{
|
|
|
|
if (!socketpair( PF_UNIX, SOCK_STREAM, 0, fds ))
|
|
|
|
{
|
|
|
|
assert( !server->fd );
|
|
|
|
|
|
|
|
/* for performance reasons, only set nonblocking mode when using
|
|
|
|
* overlapped I/O. Otherwise, we will be doing too much busy
|
|
|
|
* looping */
|
2007-04-18 07:26:37 -07:00
|
|
|
if (is_overlapped( options )) fcntl( fds[1], F_SETFL, O_NONBLOCK );
|
|
|
|
if (is_overlapped( server->options )) fcntl( fds[0], F_SETFL, O_NONBLOCK );
|
2007-03-22 08:47:46 -07:00
|
|
|
|
|
|
|
if (pipe->insize)
|
|
|
|
{
|
|
|
|
setsockopt( fds[0], SOL_SOCKET, SO_RCVBUF, &pipe->insize, sizeof(pipe->insize) );
|
|
|
|
setsockopt( fds[1], SOL_SOCKET, SO_RCVBUF, &pipe->insize, sizeof(pipe->insize) );
|
|
|
|
}
|
|
|
|
if (pipe->outsize)
|
|
|
|
{
|
|
|
|
setsockopt( fds[0], SOL_SOCKET, SO_SNDBUF, &pipe->outsize, sizeof(pipe->outsize) );
|
|
|
|
setsockopt( fds[1], SOL_SOCKET, SO_SNDBUF, &pipe->outsize, sizeof(pipe->outsize) );
|
|
|
|
}
|
|
|
|
|
2007-04-10 13:25:07 -07:00
|
|
|
client->fd = create_anonymous_fd( &pipe_client_fd_ops, fds[1], &client->obj, options );
|
|
|
|
server->fd = create_anonymous_fd( &pipe_server_fd_ops, fds[0], &server->obj, server->options );
|
2007-04-18 07:26:37 -07:00
|
|
|
if (client->fd && server->fd)
|
2007-03-22 08:47:46 -07:00
|
|
|
{
|
2010-08-23 08:09:45 -07:00
|
|
|
allow_fd_caching( client->fd );
|
|
|
|
allow_fd_caching( server->fd );
|
2009-03-02 12:34:39 -07:00
|
|
|
fd_copy_completion( server->ioctl_fd, server->fd );
|
2007-03-22 08:47:46 -07:00
|
|
|
if (server->state == ps_wait_open)
|
2007-04-18 07:28:01 -07:00
|
|
|
fd_async_wake_up( server->ioctl_fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
|
2007-04-18 07:26:37 -07:00
|
|
|
set_server_state( server, ps_connected_server );
|
2007-03-22 08:47:46 -07:00
|
|
|
server->client = client;
|
|
|
|
client->server = server;
|
|
|
|
}
|
2007-04-18 07:26:37 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
release_object( client );
|
|
|
|
client = NULL;
|
|
|
|
}
|
2007-03-22 08:47:46 -07:00
|
|
|
}
|
|
|
|
else
|
2007-04-18 07:26:37 -07:00
|
|
|
{
|
2007-03-22 08:47:46 -07:00
|
|
|
file_set_error();
|
2007-04-18 07:26:37 -07:00
|
|
|
release_object( client );
|
|
|
|
client = NULL;
|
|
|
|
}
|
2007-03-22 08:47:46 -07:00
|
|
|
}
|
|
|
|
release_object( server );
|
|
|
|
return &client->obj;
|
|
|
|
}
|
|
|
|
|
2015-05-04 20:02:59 -07:00
|
|
|
static obj_handle_t named_pipe_device_ioctl( struct fd *fd, ioctl_code_t code,
|
|
|
|
const async_data_t *async_data, int blocking )
|
2007-04-17 13:07:07 -07:00
|
|
|
{
|
|
|
|
struct named_pipe_device *device = get_fd_user( fd );
|
|
|
|
|
|
|
|
switch(code)
|
|
|
|
{
|
|
|
|
case FSCTL_PIPE_WAIT:
|
|
|
|
{
|
2015-05-04 20:02:59 -07:00
|
|
|
const FILE_PIPE_WAIT_FOR_BUFFER *buffer = get_req_data();
|
|
|
|
data_size_t size = get_req_data_size();
|
2007-05-03 08:44:32 -07:00
|
|
|
obj_handle_t wait_handle = 0;
|
2007-04-17 13:07:07 -07:00
|
|
|
struct named_pipe *pipe;
|
|
|
|
struct pipe_server *server;
|
|
|
|
struct unicode_str name;
|
|
|
|
|
|
|
|
if (size < sizeof(*buffer) ||
|
|
|
|
size < FIELD_OFFSET(FILE_PIPE_WAIT_FOR_BUFFER, Name[buffer->NameLength/sizeof(WCHAR)]))
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
2007-05-03 08:43:18 -07:00
|
|
|
return 0;
|
2007-04-17 13:07:07 -07:00
|
|
|
}
|
|
|
|
name.str = buffer->Name;
|
|
|
|
name.len = (buffer->NameLength / sizeof(WCHAR)) * sizeof(WCHAR);
|
|
|
|
if (!(pipe = (struct named_pipe *)find_object( device->pipes, &name, OBJ_CASE_INSENSITIVE )))
|
|
|
|
{
|
2014-05-30 17:44:36 -07:00
|
|
|
set_error( STATUS_OBJECT_NAME_NOT_FOUND );
|
2007-05-03 08:43:18 -07:00
|
|
|
return 0;
|
2007-04-17 13:07:07 -07:00
|
|
|
}
|
|
|
|
if (!(server = find_available_server( pipe )))
|
|
|
|
{
|
|
|
|
struct async *async;
|
|
|
|
|
2007-05-03 08:44:32 -07:00
|
|
|
if (!pipe->waiters && !(pipe->waiters = create_async_queue( NULL ))) goto done;
|
|
|
|
|
2015-05-08 01:32:06 -07:00
|
|
|
if ((async = create_async( current, pipe->waiters, async_data )))
|
2007-04-17 13:07:07 -07:00
|
|
|
{
|
|
|
|
timeout_t when = buffer->TimeoutSpecified ? buffer->Timeout.QuadPart : pipe->timeout;
|
|
|
|
async_set_timeout( async, when, STATUS_IO_TIMEOUT );
|
2015-05-08 01:32:06 -07:00
|
|
|
if (blocking) wait_handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
|
2007-04-17 13:07:07 -07:00
|
|
|
release_object( async );
|
|
|
|
set_error( STATUS_PENDING );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else release_object( server );
|
|
|
|
|
2007-05-03 08:44:32 -07:00
|
|
|
done:
|
2007-04-17 13:07:07 -07:00
|
|
|
release_object( pipe );
|
2007-05-03 08:44:32 -07:00
|
|
|
return wait_handle;
|
2007-04-17 13:07:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2015-05-04 20:02:59 -07:00
|
|
|
return default_fd_ioctl( fd, code, async_data, blocking );
|
2007-04-17 13:07:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-10 12:16:49 -07:00
|
|
|
DECL_HANDLER(create_named_pipe)
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe;
|
2003-05-14 21:22:45 -07:00
|
|
|
struct pipe_server *server;
|
2005-11-18 09:31:18 -07:00
|
|
|
struct unicode_str name;
|
2005-12-05 05:09:35 -07:00
|
|
|
struct directory *root = NULL;
|
2014-11-12 03:25:23 -07:00
|
|
|
const struct security_descriptor *sd;
|
2016-01-15 02:15:31 -07:00
|
|
|
const struct object_attributes *objattr = get_req_object_attributes( &sd, &name );
|
|
|
|
|
|
|
|
if (!objattr) return;
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2011-10-12 05:50:40 -07:00
|
|
|
if (!req->sharing || (req->sharing & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
|
|
|
|
(!(req->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE) && (req->flags & NAMED_PIPE_MESSAGE_STREAM_READ)))
|
2011-09-26 04:57:38 -07:00
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-12 03:25:23 -07:00
|
|
|
if (objattr->rootdir && !(root = get_directory_obj( current->process, objattr->rootdir, 0 )))
|
2005-12-05 05:09:35 -07:00
|
|
|
return;
|
|
|
|
|
2016-01-15 01:53:34 -07:00
|
|
|
pipe = create_named_pipe( root, &name, objattr->attributes | OBJ_OPENIF, sd );
|
2005-12-05 05:09:35 -07:00
|
|
|
|
|
|
|
if (root) release_object( root );
|
|
|
|
if (!pipe) return;
|
2001-07-10 12:16:49 -07:00
|
|
|
|
2005-11-21 09:27:03 -07:00
|
|
|
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
|
2001-08-27 12:03:42 -07:00
|
|
|
{
|
2005-12-05 05:09:35 -07:00
|
|
|
/* initialize it if it didn't already exist */
|
|
|
|
pipe->instances = 0;
|
2007-04-02 11:09:29 -07:00
|
|
|
pipe->waiters = NULL;
|
2005-12-05 05:09:35 -07:00
|
|
|
list_init( &pipe->servers );
|
2001-08-27 12:03:42 -07:00
|
|
|
pipe->insize = req->insize;
|
|
|
|
pipe->outsize = req->outsize;
|
|
|
|
pipe->maxinstances = req->maxinstances;
|
|
|
|
pipe->timeout = req->timeout;
|
2014-08-11 06:35:50 -07:00
|
|
|
pipe->flags = req->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE;
|
2011-09-26 04:57:15 -07:00
|
|
|
pipe->sharing = req->sharing;
|
2001-08-27 12:03:42 -07:00
|
|
|
}
|
2003-05-14 21:22:45 -07:00
|
|
|
else
|
|
|
|
{
|
2005-06-10 12:54:46 -07:00
|
|
|
if (pipe->maxinstances <= pipe->instances)
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
2005-11-01 14:37:30 -07:00
|
|
|
set_error( STATUS_INSTANCE_NOT_AVAILABLE );
|
2003-05-14 21:22:45 -07:00
|
|
|
release_object( pipe );
|
|
|
|
return;
|
|
|
|
}
|
2011-09-26 04:57:29 -07:00
|
|
|
if (pipe->sharing != req->sharing)
|
2003-05-14 21:22:45 -07:00
|
|
|
{
|
|
|
|
set_error( STATUS_ACCESS_DENIED );
|
|
|
|
release_object( pipe );
|
|
|
|
return;
|
|
|
|
}
|
2006-05-26 03:10:11 -07:00
|
|
|
clear_error(); /* clear the name collision */
|
2003-05-14 21:22:45 -07:00
|
|
|
}
|
2001-08-27 12:03:42 -07:00
|
|
|
|
2014-08-11 06:35:50 -07:00
|
|
|
server = create_pipe_server( pipe, req->options, req->flags );
|
2005-06-10 12:54:46 -07:00
|
|
|
if (server)
|
2001-07-10 12:16:49 -07:00
|
|
|
{
|
2016-01-15 01:53:34 -07:00
|
|
|
reply->handle = alloc_handle( current->process, server, req->access, objattr->attributes );
|
2003-05-14 21:22:45 -07:00
|
|
|
server->pipe->instances++;
|
2014-11-12 03:25:23 -07:00
|
|
|
if (sd) default_set_sd( &server->obj, sd, OWNER_SECURITY_INFORMATION |
|
|
|
|
GROUP_SECURITY_INFORMATION |
|
|
|
|
DACL_SECURITY_INFORMATION |
|
|
|
|
SACL_SECURITY_INFORMATION );
|
2003-05-14 21:22:45 -07:00
|
|
|
release_object( server );
|
2001-07-10 12:16:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
release_object( pipe );
|
|
|
|
}
|
|
|
|
|
2001-08-27 12:03:42 -07:00
|
|
|
DECL_HANDLER(get_named_pipe_info)
|
|
|
|
{
|
2003-05-14 21:22:45 -07:00
|
|
|
struct pipe_server *server;
|
2006-05-26 03:10:11 -07:00
|
|
|
struct pipe_client *client = NULL;
|
2001-08-27 12:03:42 -07:00
|
|
|
|
2006-05-26 03:10:11 -07:00
|
|
|
server = get_pipe_server_obj( current->process, req->handle, FILE_READ_ATTRIBUTES );
|
2005-06-10 12:54:46 -07:00
|
|
|
if (!server)
|
2006-05-26 03:10:11 -07:00
|
|
|
{
|
2011-09-29 02:20:42 -07:00
|
|
|
if (get_error() != STATUS_OBJECT_TYPE_MISMATCH)
|
|
|
|
return;
|
|
|
|
|
2006-05-26 03:10:11 -07:00
|
|
|
clear_error();
|
|
|
|
client = (struct pipe_client *)get_handle_obj( current->process, req->handle,
|
2011-09-29 02:20:42 -07:00
|
|
|
0, &pipe_client_ops );
|
2006-05-26 03:10:11 -07:00
|
|
|
if (!client) return;
|
|
|
|
server = client->server;
|
|
|
|
}
|
2001-08-27 12:03:42 -07:00
|
|
|
|
2014-08-11 06:35:50 -07:00
|
|
|
reply->flags = client ? client->pipe_flags : server->pipe_flags;
|
2015-11-22 23:23:45 -07:00
|
|
|
if (server)
|
|
|
|
{
|
|
|
|
reply->sharing = server->pipe->sharing;
|
|
|
|
reply->maxinstances = server->pipe->maxinstances;
|
|
|
|
reply->instances = server->pipe->instances;
|
|
|
|
reply->insize = server->pipe->insize;
|
|
|
|
reply->outsize = server->pipe->outsize;
|
|
|
|
}
|
2001-08-27 12:03:42 -07:00
|
|
|
|
2006-05-26 03:10:11 -07:00
|
|
|
if (client)
|
|
|
|
release_object(client);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
reply->flags |= NAMED_PIPE_SERVER_END;
|
|
|
|
release_object(server);
|
|
|
|
}
|
2001-08-27 12:03:42 -07:00
|
|
|
}
|
2014-08-11 08:06:49 -07:00
|
|
|
|
|
|
|
DECL_HANDLER(set_named_pipe_info)
|
|
|
|
{
|
|
|
|
struct pipe_server *server;
|
|
|
|
struct pipe_client *client = NULL;
|
|
|
|
|
|
|
|
server = get_pipe_server_obj( current->process, req->handle, FILE_WRITE_ATTRIBUTES );
|
|
|
|
if (!server)
|
|
|
|
{
|
|
|
|
if (get_error() != STATUS_OBJECT_TYPE_MISMATCH)
|
|
|
|
return;
|
|
|
|
|
|
|
|
clear_error();
|
|
|
|
client = (struct pipe_client *)get_handle_obj( current->process, req->handle,
|
|
|
|
0, &pipe_client_ops );
|
|
|
|
if (!client) return;
|
2015-11-22 23:24:07 -07:00
|
|
|
if (!(server = client->server))
|
|
|
|
{
|
|
|
|
release_object( client );
|
|
|
|
return;
|
|
|
|
}
|
2014-08-11 08:06:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_READ | NAMED_PIPE_NONBLOCKING_MODE)) ||
|
|
|
|
((req->flags & NAMED_PIPE_MESSAGE_STREAM_READ) && !(server->pipe->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE)))
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
}
|
|
|
|
else if (client)
|
|
|
|
{
|
|
|
|
client->pipe_flags = server->pipe->flags | req->flags;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
server->pipe_flags = server->pipe->flags | req->flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client)
|
|
|
|
release_object(client);
|
|
|
|
else
|
|
|
|
release_object(server);
|
|
|
|
}
|