This commit was manufactured by cvs2svn to create branch 'fedora'.
[linux-2.6.git] / net / tux / postpone.c
1 /*
2  * TUX - Integrated Application Protocols Layer and Object Cache
3  *
4  * Copyright (C) 2000, 2001, Ingo Molnar <mingo@redhat.com>
5  *
6  * postpone.c: postpone/continue userspace requests
7  */
8
9 #include <net/tux.h>
10
11 /****************************************************************
12  *      This program is free software; you can redistribute it and/or modify
13  *      it under the terms of the GNU General Public License as published by
14  *      the Free Software Foundation; either version 2, or (at your option)
15  *      any later version.
16  *
17  *      This program is distributed in the hope that it will be useful,
18  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *      GNU General Public License for more details.
21  *
22  *      You should have received a copy of the GNU General Public License
23  *      along with this program; if not, write to the Free Software
24  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  *
26  ****************************************************************/
27
28 void postpone_request (tux_req_t *req)
29 {
30         if (!req->usermode)
31                 TUX_BUG();
32         INC_STAT(nr_postpone_pending);
33         req->postponed = 1;
34 }
35
36 /*
37  * Continue a postponed request. The request will show up in the
38  * userspace queue and will be handled by the fast thread.
39  * A request can only be postponed in a TUX process, but can be
40  * continued from any process that has access to the socket file
41  * descriptor.
42  */
43 int continue_request (int fd)
44 {
45         threadinfo_t *ti;
46         struct socket *sock;
47         tux_req_t *req;
48         int err;
49
50         sock = sockfd_lookup(fd, &err);
51         if (!sock || !sock->sk)
52                 goto out;
53         req = sock->sk->sk_user_data;
54
55         err = -EINVAL;
56         if (!req)
57                 goto out_put;
58         ti = req->ti;
59         if (!req->postponed)
60                 goto out_unlock_put;
61         if (!req->usermode)
62                 TUX_BUG();
63
64         req->postponed = 0;
65         DEC_STAT(nr_postpone_pending);
66
67         Dprintk("continuing postponed req %p.\n", req);
68         add_req_to_workqueue(req);
69
70 out_unlock_put:
71         err = 0;
72 out_put:
73         fput(sock->file);
74 out:
75         return err;
76 }
77