~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/win32.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
1
/*
3
 
 * $Id: win32.cc,v 1.25 2006/09/13 19:05:11 serassio Exp $
 
2
 * $Id$
4
3
 *
5
4
 * Windows support
6
5
 * AUTHOR: Guido Serassio <serassio@squid-cache.org>
22
21
 *  it under the terms of the GNU General Public License as published by
23
22
 *  the Free Software Foundation; either version 2 of the License, or
24
23
 *  (at your option) any later version.
25
 
 *  
 
24
 *
26
25
 *  This program is distributed in the hope that it will be useful,
27
26
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
27
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
28
 *  GNU General Public License for more details.
30
 
 *  
 
29
 *
31
30
 *  You should have received a copy of the GNU General Public License
32
31
 *  along with this program; if not, write to the Free Software
33
32
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
56
55
    int new_socket;
57
56
    fde *F = NULL;
58
57
 
59
 
    struct sockaddr_in serv_addr;
60
 
    int len = sizeof(serv_addr);
61
 
    u_short handle1_port;
 
58
    IpAddress localhost;
 
59
    IpAddress handle0;
 
60
    IpAddress handle1;
 
61
    struct addrinfo *AI = NULL;
 
62
 
 
63
    localhost.SetLocalhost();
 
64
 
 
65
    /* INET6: back-compatible: localhost pipes default to IPv4 unless set otherwise.
 
66
     *        it is blocked by untested helpers on many admins configs
 
67
     *        if this proves to be wrong it can die easily.
 
68
     */
 
69
    localhost.SetIPv4();
62
70
 
63
71
    handles[0] = handles[1] = -1;
64
72
 
65
73
    statCounter.syscalls.sock.sockets++;
66
74
 
67
 
    if ((new_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
 
75
    handle0 = localhost;
 
76
    handle0.SetPort(0);
 
77
    handle0.GetAddrInfo(AI);
 
78
 
 
79
    if ((new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol)) < 0)
68
80
        return -1;
69
81
 
70
 
    memset((void *) &serv_addr, 0, sizeof(serv_addr));
71
 
 
72
 
    serv_addr.sin_family = AF_INET;
73
 
 
74
 
    serv_addr.sin_port = htons(0);
75
 
 
76
 
    serv_addr.sin_addr = local_addr;
77
 
 
78
 
    if (bind(new_socket, (SOCKADDR *) & serv_addr, len) < 0 ||
79
 
            listen(new_socket, 1) < 0 || getsockname(new_socket, (SOCKADDR *) & serv_addr, &len) < 0 ||
80
 
            (handles[1] = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
 
82
    if (bind(new_socket, AI->ai_addr, AI->ai_addrlen) < 0 ||
 
83
            listen(new_socket, 1) < 0 || getsockname(new_socket, AI->ai_addr, &(AI->ai_addrlen) ) < 0 ||
 
84
            (handles[1] = socket(AI->ai_family, AI->ai_socktype, 0)) < 0) {
81
85
        closesocket(new_socket);
82
86
        return -1;
83
87
    }
84
88
 
85
 
    handle1_port = ntohs(serv_addr.sin_port);
86
 
 
87
 
    if (connect(handles[1], (SOCKADDR *) & serv_addr, len) < 0 ||
88
 
            (handles[0] = accept(new_socket, (SOCKADDR *) & serv_addr, &len)) < 0) {
 
89
    handle0 = *AI; // retrieve the new details returned by connect()
 
90
 
 
91
    handle1.SetPort(handle1.GetPort());
 
92
    handle1.GetAddrInfo(AI);
 
93
 
 
94
    if (connect(handles[1], AI->ai_addr, AI->ai_addrlen) < 0 ||
 
95
            (handles[0] = accept(new_socket, AI->ai_addr, &(AI->ai_addrlen)) ) < 0) {
89
96
        closesocket(handles[1]);
90
97
        handles[1] = -1;
91
98
        closesocket(new_socket);
95
102
    closesocket(new_socket);
96
103
 
97
104
    F = &fd_table[handles[0]];
98
 
    F->local_addr = local_addr;
99
 
    F->local_port = ntohs(serv_addr.sin_port);
 
105
    F->local_addr = handle0;
100
106
 
101
107
    F = &fd_table[handles[1]];
102
 
    F->local_addr = local_addr;
103
 
    xstrncpy(F->ipaddr, inet_ntoa(local_addr), 16);
104
 
    F->remote_port = handle1_port;
 
108
    F->local_addr = localhost;
 
109
    handle1.NtoA(F->ipaddr, MAX_IPSTRLEN);
 
110
    F->remote_port = handle1.GetPort();
105
111
 
106
112
    return 0;
107
113
}
124
130
            FILETIME ftCreate, ftExit, ftKernel, ftUser;
125
131
 
126
132
            if (GetProcessTimes(hProcess, &ftCreate, &ftExit, &ftKernel, &ftUser)) {
127
 
                int64_t *ptUser = (int64_t *)&ftUser;
 
133
                int64_t *ptUser = (int64_t *)&ftUser;
128
134
                int64_t tUser64 = *ptUser / 10;
129
 
                int64_t *ptKernel = (int64_t *)&ftKernel;
 
135
                int64_t *ptKernel = (int64_t *)&ftKernel;
130
136
                int64_t tKernel64 = *ptKernel / 10;
131
137
                usage->ru_utime.tv_sec =(long)(tUser64 / 1000000);
132
138
                usage->ru_stime.tv_sec =(long)(tKernel64 / 1000000);
155
161
 
156
162
 
157
163
int Win32__WSAFDIsSet(int fd, fd_set FAR * set
158
 
                         )
 
164
                     )
159
165
{
160
166
    fde *F = &fd_table[fd];
161
167
    SOCKET s = F->win32.handle;
162
168
 
163
 
    return __WSAFDIsSet(s, set
164
 
                           );
 
169
    return __WSAFDIsSet(s, set);
165
170
}
166
171
 
167
172
LONG CALLBACK WIN32_ExceptionHandler(EXCEPTION_POINTERS* ep)