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
;
39 proxy(fd_set
*active
, fd_set
*perm
)
44 while (temp
!= NULL
) {
45 if (FD_ISSET(temp
->source
, active
)) {
46 if (copy_between_ports(temp
->source
, temp
->target
, temp
) < 0) {
47 /* We need better handling here. */
48 FD_CLR(temp
->source
, perm
);
49 FD_CLR(temp
->target
, perm
);
50 if (temp
->next
== NULL
) {
55 chan_remove(temp
->prev
);
59 if (FD_ISSET(temp
->target
, active
)) {
60 if (copy_between_ports(temp
->target
, temp
->source
, temp
) < 0) {
61 /* We need better handling here. */
62 FD_CLR(temp
->source
, perm
);
63 FD_CLR(temp
->target
, perm
);
64 if (temp
->next
== NULL
) {
69 chan_remove(temp
->prev
);
80 chan_remove(Channels
*temp
)
82 unregister_sock(temp
->source
);
83 unregister_sock(temp
->target
);
87 if (temp
->foreign_address_str
!= NULL
)
88 free(temp
->foreign_address_str
);
90 if (temp
->prev
== NULL
) {
91 if (temp
->next
== NULL
) {
100 if (temp
->next
== NULL
) {
101 temp
->prev
->next
= NULL
;
104 temp
->prev
->next
= temp
->next
;
105 temp
->next
->prev
= temp
->prev
;
109 statistics
.nmb_relay_worker_conns_cur
--;
117 temp
= (Channels
*)malloc(sizeof(Channels
));
123 memset(temp
, 0, sizeof(Channels
));