2001-07-10 21:16:49 +02:00
|
|
|
/*
|
|
|
|
* Server-side pipe management
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998 Alexandre Julliard
|
2001-08-24 01:29:20 +02:00
|
|
|
* Copyright (C) 2001 Mike McCormack
|
|
|
|
*
|
2002-03-10 00:29:33 +01: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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
2001-08-24 01:29:20 +02:00
|
|
|
* TODO:
|
|
|
|
* improve error handling
|
2001-07-10 21:16:49 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-04-26 21:05:15 +02:00
|
|
|
#include "wine/port.h"
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
2003-02-11 23:27:13 +01:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2001-07-10 21:16:49 +02:00
|
|
|
#include <sys/socket.h>
|
2003-02-11 23:27:13 +01:00
|
|
|
#endif
|
2001-07-10 21:16:49 +02:00
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "winbase.h"
|
|
|
|
|
2003-01-30 01:26:44 +01:00
|
|
|
#include "file.h"
|
2001-07-10 21:16:49 +02:00
|
|
|
#include "handle.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "request.h"
|
|
|
|
|
2001-08-24 01:29:20 +02:00
|
|
|
enum pipe_state
|
|
|
|
{
|
|
|
|
ps_none,
|
|
|
|
ps_idle_server,
|
|
|
|
ps_wait_open,
|
|
|
|
ps_wait_connect,
|
|
|
|
ps_connected_server,
|
|
|
|
ps_connected_client,
|
|
|
|
ps_disconnected
|
|
|
|
};
|
|
|
|
|
2001-07-10 21:16:49 +02:00
|
|
|
struct named_pipe;
|
|
|
|
|
|
|
|
struct pipe_user
|
|
|
|
{
|
|
|
|
struct object obj;
|
2003-02-19 01:33:32 +01:00
|
|
|
struct fd *fd;
|
2001-08-24 01:29:20 +02:00
|
|
|
enum pipe_state state;
|
|
|
|
struct pipe_user *other;
|
2001-07-10 21:16:49 +02:00
|
|
|
struct named_pipe *pipe;
|
|
|
|
struct pipe_user *next;
|
|
|
|
struct pipe_user *prev;
|
2002-01-12 22:16:13 +01:00
|
|
|
struct thread *thread;
|
2001-11-07 21:14:45 +01:00
|
|
|
void *func;
|
|
|
|
void *overlapped;
|
2001-07-10 21:16:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct named_pipe
|
|
|
|
{
|
|
|
|
struct object obj; /* object header */
|
|
|
|
unsigned int pipemode;
|
|
|
|
unsigned int maxinstances;
|
|
|
|
unsigned int outsize;
|
|
|
|
unsigned int insize;
|
|
|
|
unsigned int timeout;
|
|
|
|
struct pipe_user *users;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void named_pipe_dump( struct object *obj, int verbose );
|
|
|
|
static void named_pipe_destroy( struct object *obj);
|
|
|
|
|
|
|
|
static const struct object_ops named_pipe_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct named_pipe), /* size */
|
|
|
|
named_pipe_dump, /* dump */
|
|
|
|
no_add_queue, /* add_queue */
|
|
|
|
NULL, /* remove_queue */
|
|
|
|
NULL, /* signaled */
|
|
|
|
NULL, /* satisfied */
|
|
|
|
no_get_fd, /* get_fd */
|
|
|
|
named_pipe_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
|
|
|
static void pipe_user_dump( struct object *obj, int verbose );
|
2003-02-19 01:33:32 +01:00
|
|
|
static struct fd *pipe_user_get_fd( struct object *obj );
|
2001-07-10 21:16:49 +02:00
|
|
|
static void pipe_user_destroy( struct object *obj);
|
2003-02-19 01:33:32 +01:00
|
|
|
|
|
|
|
static int pipe_user_get_poll_events( struct fd *fd );
|
2003-02-14 21:27:09 +01:00
|
|
|
static int pipe_user_get_info( struct fd *fd, struct get_file_info_reply *reply, int *flags );
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
static const struct object_ops pipe_user_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct pipe_user), /* size */
|
|
|
|
pipe_user_dump, /* dump */
|
2003-01-30 01:26:44 +01:00
|
|
|
default_fd_add_queue, /* add_queue */
|
|
|
|
default_fd_remove_queue, /* remove_queue */
|
|
|
|
default_fd_signaled, /* signaled */
|
2001-07-10 21:16:49 +02:00
|
|
|
no_satisfied, /* satisfied */
|
2003-02-19 01:33:32 +01:00
|
|
|
pipe_user_get_fd, /* get_fd */
|
2003-01-30 01:26:44 +01:00
|
|
|
pipe_user_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct fd_ops pipe_user_fd_ops =
|
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
pipe_user_get_poll_events, /* get_poll_events */
|
2001-07-10 21:16:49 +02:00
|
|
|
default_poll_event, /* poll_event */
|
|
|
|
no_flush, /* flush */
|
2001-10-05 21:45:45 +02:00
|
|
|
pipe_user_get_info, /* get_file_info */
|
2003-01-30 01:26:44 +01:00
|
|
|
no_queue_async /* queue_async */
|
2001-07-10 21:16:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void named_pipe_dump( struct object *obj, int verbose )
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe = (struct named_pipe *)obj;
|
|
|
|
assert( obj->ops == &named_pipe_ops );
|
|
|
|
fprintf( stderr, "named pipe %p\n" ,pipe);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pipe_user_dump( struct object *obj, int verbose )
|
|
|
|
{
|
|
|
|
struct pipe_user *user = (struct pipe_user *)obj;
|
|
|
|
assert( obj->ops == &pipe_user_ops );
|
2001-08-24 01:29:20 +02:00
|
|
|
fprintf( stderr, "named pipe user %p (state %d)\n", user, user->state );
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void named_pipe_destroy( struct object *obj)
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe = (struct named_pipe *)obj;
|
|
|
|
assert( !pipe->users );
|
|
|
|
}
|
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
static void notify_waiter( struct pipe_user *user, unsigned int status)
|
|
|
|
{
|
|
|
|
if(user->thread && user->func && user->overlapped)
|
|
|
|
{
|
|
|
|
/* queue a system APC, to notify a waiting thread */
|
2003-04-05 00:26:34 +02:00
|
|
|
thread_queue_apc(user->thread, NULL, user->func, APC_ASYNC, 1,
|
|
|
|
user->overlapped, (void *)status, NULL);
|
2001-11-07 21:14:45 +01:00
|
|
|
}
|
2002-01-12 22:16:13 +01:00
|
|
|
if (user->thread) release_object(user->thread);
|
2001-11-07 21:14:45 +01:00
|
|
|
user->thread = NULL;
|
|
|
|
user->func = NULL;
|
|
|
|
user->overlapped=NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
static struct fd *pipe_user_get_fd( struct object *obj )
|
|
|
|
{
|
|
|
|
struct pipe_user *user = (struct pipe_user *)obj;
|
2003-04-17 04:14:04 +02:00
|
|
|
if (user->fd) return (struct fd *)grab_object( user->fd );
|
|
|
|
set_error( STATUS_PIPE_DISCONNECTED );
|
|
|
|
return NULL;
|
2003-02-19 01:33:32 +01:00
|
|
|
}
|
|
|
|
|
2001-07-10 21:16:49 +02:00
|
|
|
static void pipe_user_destroy( struct object *obj)
|
|
|
|
{
|
|
|
|
struct pipe_user *user = (struct pipe_user *)obj;
|
|
|
|
|
|
|
|
assert( obj->ops == &pipe_user_ops );
|
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
if(user->overlapped)
|
|
|
|
notify_waiter(user,STATUS_HANDLES_CLOSED);
|
|
|
|
|
2001-08-24 01:29:20 +02:00
|
|
|
if(user->other)
|
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
release_object( user->other->fd );
|
|
|
|
user->other->fd = NULL;
|
2001-08-24 01:29:20 +02:00
|
|
|
switch(user->other->state)
|
|
|
|
{
|
|
|
|
case ps_connected_server:
|
|
|
|
user->other->state = ps_idle_server;
|
|
|
|
break;
|
|
|
|
case ps_connected_client:
|
|
|
|
user->other->state = ps_disconnected;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr,"connected pipe has strange state %d!\n",
|
|
|
|
user->other->state);
|
|
|
|
}
|
|
|
|
user->other->other=NULL;
|
|
|
|
user->other = NULL;
|
|
|
|
}
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
/* remove user from pipe's user list */
|
|
|
|
if (user->next) user->next->prev = user->prev;
|
|
|
|
if (user->prev) user->prev->next = user->next;
|
|
|
|
else user->pipe->users = user->next;
|
2002-01-12 22:16:13 +01:00
|
|
|
if (user->thread) release_object(user->thread);
|
2001-07-10 21:16:49 +02:00
|
|
|
release_object(user->pipe);
|
2003-02-19 01:33:32 +01:00
|
|
|
if (user->fd) release_object( user->fd );
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pipe_user_get_poll_events( struct fd *fd )
|
|
|
|
{
|
|
|
|
return POLLIN | POLLOUT; /* FIXME */
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
|
|
|
|
2003-02-14 21:27:09 +01:00
|
|
|
static int pipe_user_get_info( struct fd *fd, struct get_file_info_reply *reply, int *flags )
|
2001-10-05 21:45:45 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
if (reply)
|
2001-10-05 21:45:45 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->type = FILE_TYPE_PIPE;
|
|
|
|
reply->attr = 0;
|
|
|
|
reply->access_time = 0;
|
|
|
|
reply->write_time = 0;
|
|
|
|
reply->size_high = 0;
|
|
|
|
reply->size_low = 0;
|
|
|
|
reply->links = 0;
|
|
|
|
reply->index_high = 0;
|
|
|
|
reply->index_low = 0;
|
|
|
|
reply->serial = 0;
|
2001-10-05 21:45:45 +02:00
|
|
|
}
|
2002-01-09 21:30:51 +01:00
|
|
|
*flags = 0;
|
2001-10-05 21:45:45 +02:00
|
|
|
return FD_TYPE_DEFAULT;
|
|
|
|
}
|
|
|
|
|
2001-07-10 21:16:49 +02:00
|
|
|
static struct named_pipe *create_named_pipe( const WCHAR *name, size_t len )
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe;
|
|
|
|
|
2002-10-03 01:49:30 +02:00
|
|
|
if ((pipe = create_named_object( sync_namespace, &named_pipe_ops, name, len )))
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
|
|
|
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
|
|
|
{
|
|
|
|
/* initialize it if it didn't already exist */
|
|
|
|
pipe->users = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pipe;
|
|
|
|
}
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
static struct named_pipe *open_named_pipe( const WCHAR *name, size_t len )
|
|
|
|
{
|
|
|
|
struct object *obj;
|
|
|
|
|
|
|
|
if ((obj = find_object( sync_namespace, name, len )))
|
|
|
|
{
|
|
|
|
if (obj->ops == &named_pipe_ops) return (struct named_pipe *)obj;
|
|
|
|
release_object( obj );
|
|
|
|
set_error( STATUS_OBJECT_TYPE_MISMATCH );
|
|
|
|
}
|
|
|
|
else set_error( STATUS_OBJECT_NAME_NOT_FOUND );
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-05-30 22:12:58 +02:00
|
|
|
static struct pipe_user *get_pipe_user_obj( struct process *process, obj_handle_t handle,
|
2001-07-10 21:16:49 +02:00
|
|
|
unsigned int access )
|
|
|
|
{
|
|
|
|
return (struct pipe_user *)get_handle_obj( process, handle, access, &pipe_user_ops );
|
|
|
|
}
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
static struct pipe_user *create_pipe_user( struct named_pipe *pipe )
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
|
|
|
struct pipe_user *user;
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
user = alloc_object( &pipe_user_ops );
|
2001-07-10 21:16:49 +02:00
|
|
|
if(!user)
|
|
|
|
return NULL;
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
user->fd = NULL;
|
2001-07-10 21:16:49 +02:00
|
|
|
user->pipe = pipe;
|
2001-08-24 01:29:20 +02:00
|
|
|
user->state = ps_none;
|
|
|
|
user->other = NULL;
|
2001-11-07 21:14:45 +01:00
|
|
|
user->thread = NULL;
|
|
|
|
user->func = NULL;
|
|
|
|
user->overlapped = NULL;
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
/* add to list of pipe users */
|
|
|
|
if ((user->next = pipe->users)) user->next->prev = user;
|
|
|
|
user->prev = NULL;
|
|
|
|
pipe->users = user;
|
|
|
|
|
|
|
|
grab_object(pipe);
|
|
|
|
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
|
2001-08-24 01:29:20 +02:00
|
|
|
static struct pipe_user *find_partner(struct named_pipe *pipe, enum pipe_state state)
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
|
|
|
struct pipe_user *x;
|
|
|
|
|
|
|
|
for(x = pipe->users; x; x=x->next)
|
|
|
|
{
|
2001-08-24 01:29:20 +02:00
|
|
|
if(x->state==state)
|
2001-07-10 21:16:49 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-08-24 01:29:20 +02:00
|
|
|
if(!x)
|
|
|
|
return NULL;
|
|
|
|
|
2001-07-10 21:16:49 +02:00
|
|
|
return (struct pipe_user *)grab_object( x );
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_HANDLER(create_named_pipe)
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe;
|
|
|
|
struct pipe_user *user;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->handle = 0;
|
|
|
|
pipe = create_named_pipe( get_req_data(), get_req_data_size() );
|
2001-07-10 21:16:49 +02:00
|
|
|
if(!pipe)
|
|
|
|
return;
|
|
|
|
|
2001-08-27 21:03:42 +02:00
|
|
|
if (get_error() != STATUS_OBJECT_NAME_COLLISION)
|
|
|
|
{
|
|
|
|
pipe->insize = req->insize;
|
|
|
|
pipe->outsize = req->outsize;
|
|
|
|
pipe->maxinstances = req->maxinstances;
|
|
|
|
pipe->timeout = req->timeout;
|
|
|
|
pipe->pipemode = req->pipemode;
|
|
|
|
}
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
user = create_pipe_user( pipe );
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
if(user)
|
|
|
|
{
|
2001-08-24 01:29:20 +02:00
|
|
|
user->state = ps_idle_server;
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->handle = alloc_handle( current->process, user, GENERIC_READ|GENERIC_WRITE, 0 );
|
2001-07-10 21:16:49 +02:00
|
|
|
release_object( user );
|
|
|
|
}
|
|
|
|
|
|
|
|
release_object( pipe );
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_HANDLER(open_named_pipe)
|
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
struct pipe_user *user, *partner;
|
2001-07-10 21:16:49 +02:00
|
|
|
struct named_pipe *pipe;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->handle = 0;
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
if (!(pipe = open_named_pipe( get_req_data(), get_req_data_size() )))
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
set_error( STATUS_NO_SUCH_FILE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(partner = find_partner(pipe, ps_wait_open)))
|
|
|
|
{
|
|
|
|
release_object(pipe);
|
|
|
|
set_error( STATUS_PIPE_NOT_AVAILABLE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((user = create_pipe_user( pipe )))
|
|
|
|
{
|
|
|
|
int fds[2];
|
2001-08-24 01:29:20 +02:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
if(!socketpair(PF_UNIX, SOCK_STREAM, 0, fds))
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
2003-03-12 23:38:14 +01:00
|
|
|
user->fd = create_anonymous_fd( &pipe_user_fd_ops, fds[1], &user->obj );
|
|
|
|
partner->fd = create_anonymous_fd( &pipe_user_fd_ops, fds[0], &partner->obj );
|
2003-02-19 01:33:32 +01:00
|
|
|
if (user->fd && partner->fd)
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
notify_waiter(partner,STATUS_SUCCESS);
|
|
|
|
partner->state = ps_connected_server;
|
|
|
|
partner->other = user;
|
|
|
|
user->state = ps_connected_client;
|
|
|
|
user->other = partner;
|
|
|
|
reply->handle = alloc_handle( current->process, user, req->access, 0 );
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
|
|
|
}
|
2003-02-19 01:33:32 +01:00
|
|
|
else file_set_error();
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
release_object( user );
|
|
|
|
}
|
|
|
|
release_object( partner );
|
|
|
|
release_object( pipe );
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DECL_HANDLER(connect_named_pipe)
|
|
|
|
{
|
2001-08-24 01:29:20 +02:00
|
|
|
struct pipe_user *user, *partner;
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
user = get_pipe_user_obj(current->process, req->handle, 0);
|
|
|
|
if(!user)
|
|
|
|
return;
|
|
|
|
|
2001-08-24 01:29:20 +02:00
|
|
|
if( user->state != ps_idle_server )
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
|
|
|
set_error(STATUS_PORT_ALREADY_SET);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-24 01:29:20 +02:00
|
|
|
user->state = ps_wait_open;
|
2002-01-12 22:16:13 +01:00
|
|
|
user->thread = (struct thread *)grab_object(current);
|
2001-11-07 21:14:45 +01:00
|
|
|
user->func = req->func;
|
|
|
|
user->overlapped = req->overlapped;
|
2001-08-24 01:29:20 +02:00
|
|
|
|
|
|
|
/* notify all waiters that a pipe just became available */
|
|
|
|
while( (partner = find_partner(user->pipe,ps_wait_connect)) )
|
|
|
|
{
|
2001-11-07 21:14:45 +01:00
|
|
|
notify_waiter(partner,STATUS_SUCCESS);
|
2001-08-24 01:29:20 +02:00
|
|
|
release_object(partner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
release_object(user);
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_HANDLER(wait_named_pipe)
|
|
|
|
{
|
|
|
|
struct named_pipe *pipe;
|
2003-02-19 01:33:32 +01:00
|
|
|
struct pipe_user *partner;
|
2001-08-24 01:29:20 +02:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
if (!(pipe = open_named_pipe( get_req_data(), get_req_data_size() )))
|
2001-08-24 01:29:20 +02:00
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
set_error( STATUS_PIPE_NOT_AVAILABLE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( (partner = find_partner(pipe,ps_wait_open)) )
|
|
|
|
{
|
|
|
|
/* this should use notify_waiter,
|
|
|
|
but no pipe_user object exists now... */
|
|
|
|
thread_queue_apc(current,NULL,req->func,
|
2003-04-05 00:26:34 +02:00
|
|
|
APC_ASYNC, 1, req->overlapped, STATUS_SUCCESS, NULL);
|
2003-02-19 01:33:32 +01:00
|
|
|
release_object(partner);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct pipe_user *user;
|
2001-08-24 01:29:20 +02:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
if( (user = create_pipe_user( pipe )) )
|
2001-08-24 01:29:20 +02:00
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
user->state = ps_wait_connect;
|
|
|
|
user->thread = (struct thread *)grab_object(current);
|
|
|
|
user->func = req->func;
|
|
|
|
user->overlapped = req->overlapped;
|
|
|
|
/* don't release it */
|
2001-08-24 01:29:20 +02:00
|
|
|
}
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
2003-02-19 01:33:32 +01:00
|
|
|
release_object(pipe);
|
2001-08-24 01:29:20 +02:00
|
|
|
}
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2001-08-24 01:29:20 +02:00
|
|
|
DECL_HANDLER(disconnect_named_pipe)
|
|
|
|
{
|
|
|
|
struct pipe_user *user;
|
|
|
|
|
|
|
|
user = get_pipe_user_obj(current->process, req->handle, 0);
|
|
|
|
if(!user)
|
|
|
|
return;
|
|
|
|
if( (user->state == ps_connected_server) &&
|
|
|
|
(user->other->state == ps_connected_client) )
|
|
|
|
{
|
2003-02-19 01:33:32 +01:00
|
|
|
release_object( user->other->fd );
|
|
|
|
user->other->fd = NULL;
|
2001-08-24 01:29:20 +02:00
|
|
|
user->other->state = ps_disconnected;
|
|
|
|
user->other->other = NULL;
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
release_object( user->fd );
|
|
|
|
user->fd = NULL;
|
2001-08-24 01:29:20 +02:00
|
|
|
user->state = ps_idle_server;
|
|
|
|
user->other = NULL;
|
|
|
|
}
|
2001-07-10 21:16:49 +02:00
|
|
|
release_object(user);
|
|
|
|
}
|
2001-08-27 21:03:42 +02:00
|
|
|
|
|
|
|
DECL_HANDLER(get_named_pipe_info)
|
|
|
|
{
|
|
|
|
struct pipe_user *user;
|
|
|
|
|
|
|
|
user = get_pipe_user_obj(current->process, req->handle, 0);
|
|
|
|
if(!user)
|
|
|
|
return;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->flags = user->pipe->pipemode;
|
|
|
|
reply->maxinstances = user->pipe->maxinstances;
|
|
|
|
reply->insize = user->pipe->insize;
|
|
|
|
reply->outsize = user->pipe->outsize;
|
2001-08-27 21:03:42 +02:00
|
|
|
|
|
|
|
release_object(user);
|
|
|
|
}
|