4 * This file is a part of the revinetd project
6 * Revinetd is copyright (c) 2003-2008 by Steven M. Gill
7 * and distributed under the GPL.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
29 #include "statistics.h"
31 static const char cvsid
[] = "$Id: proxy.c,v 1.8 2008/08/28 03:24:59 necrotaur Exp $";
33 extern Statistics statistics
;
36 proxy(fd_set
*active
, fd_set
*perm
)
41 while (temp
!= NULL
) {
42 if (FD_ISSET(temp
->source
, active
)) {
43 if (copy_between_ports(temp
->source
, temp
->target
) < 0) {
44 /* We need better handling here. */
45 FD_CLR(temp
->source
, perm
);
46 FD_CLR(temp
->target
, perm
);
47 if (temp
->next
== NULL
) {
52 chan_remove(temp
->prev
);
56 if (FD_ISSET(temp
->target
, active
)) {
57 if (copy_between_ports(temp
->target
, temp
->source
) < 0) {
58 /* We need better handling here. */
59 FD_CLR(temp
->source
, perm
);
60 FD_CLR(temp
->target
, perm
);
61 if (temp
->next
== NULL
) {
66 chan_remove(temp
->prev
);
77 chan_remove(Channels
*temp
)
79 unregister_sock(temp
->source
);
80 unregister_sock(temp
->target
);
85 if (temp
->prev
== NULL
) {
86 if (temp
->next
== NULL
) {
95 if (temp
->next
== NULL
) {
96 temp
->prev
->next
= NULL
;
99 temp
->prev
->next
= temp
->next
;
100 temp
->next
->prev
= temp
->prev
;
104 statistics
.nmb_relay_worker_conns_cur
--;
112 temp
= (Channels
*)malloc(sizeof(Channels
));
118 memset(temp
, 0, sizeof(Channels
));