~ubuntu-branches/ubuntu/oneiric/squid3/oneiric-security

« back to all changes in this revision

Viewing changes to src/unlinkd.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2007-05-13 16:03:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070513160316-2h6kn6h1z0q1fvyo
Tags: 3.0.PRE6-1
* New upstream release
  - Removed patches integrated upsteam:
    + 04-m68k-ftbfs

* debian/rules
  - Enable delay pools (Closes: #410785)
  - Enable cache digests (Closes: #416631)
  - Enable ICAP client
  - Raised Max Filedescriptor limit to 65536

* debian/control
  - Added real package dependency for httpd in squid3-cgi

* debian/patches/02-makefile-defaults
  - Fix default configuration file for cachemgr.cgi (Closes: #416630)

* debian/squid3.postinst
  - Fixed bashish in postinst (Closes: #411797)

* debian/patches/05-helpers-typo
  - Added upstream patch fixing compilation error in src/helpers.cc

* debian/patches/06-mem-obj-reference
  - Added upstream patch fixing a mem_obj reference in src/store.cc

* debian/patches/07-close-icap-connections
  - Added upstream patch fixing icap connection starvation

* debian/squid3.rc
  - Added LSB-compliant description to rc script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
 
 * $Id: unlinkd.cc,v 1.58 2006/09/10 03:49:05 adrian Exp $
 
3
 * $Id: unlinkd.cc,v 1.64 2007/04/30 16:56:09 wessels Exp $
4
4
 *
5
5
 * DEBUG: section 2     Unlink Daemon
6
6
 * AUTHOR: Duane Wessels
34
34
 */
35
35
 
36
36
#include "squid.h"
37
 
 
38
 
#ifdef UNLINK_DAEMON
39
 
 
40
 
/* This is the external unlinkd process */
41
 
 
42
 
#define UNLINK_BUF_LEN 1024
43
 
 
44
 
int
45
 
main(int argc, char *argv[])
46
 
{
47
 
    char buf[UNLINK_BUF_LEN];
48
 
    char *t;
49
 
    int x;
50
 
    setbuf(stdin, NULL);
51
 
    setbuf(stdout, NULL);
52
 
    close(2);
53
 
    open(_PATH_DEVNULL, O_RDWR);
54
 
 
55
 
    while (fgets(buf, UNLINK_BUF_LEN, stdin)) {
56
 
        if ((t = strchr(buf, '\n')))
57
 
            *t = '\0';
58
 
 
59
 
#if USE_TRUNCATE
60
 
 
61
 
        x = truncate(buf, 0);
62
 
 
63
 
#else
64
 
 
65
 
        x = unlink(buf);
66
 
 
67
 
#endif
68
 
 
69
 
        if (x < 0)
70
 
            printf("ERR\n");
71
 
        else
72
 
            printf("OK\n");
73
 
    }
74
 
 
75
 
    exit(0);
76
 
}
77
 
 
78
 
#else /* UNLINK_DAEMON */
79
 
 
80
37
#include "SquidTime.h"
81
38
#include "fde.h"
 
39
#include "xusleep.h"
82
40
 
83
41
/* This code gets linked to Squid */
84
42
 
105
63
    }
106
64
 
107
65
    /*
108
 
    * If the queue length is greater than our limit, then
109
 
    * we pause for up to 100ms, hoping that unlinkd
110
 
    * has some feedback for us.  Maybe it just needs a slice
111
 
    * of the CPU's time.
112
 
    */
 
66
     * If the queue length is greater than our limit, then we pause
 
67
     * for a small amount of time, hoping that unlinkd has some
 
68
     * feedback for us.  Maybe it just needs a slice of the CPU's
 
69
     * time.
 
70
     */
113
71
    if (queuelen >= UNLINKD_QUEUE_LIMIT) {
114
 
 
 
72
#if defined(USE_EPOLL) || defined(USE_KQUEUE)
 
73
        /*
 
74
         * DPW 2007-04-23
 
75
         * We can't use fd_set when using epoll() or kqueue().  In
 
76
         * these cases we block for 10 ms.
 
77
         */
 
78
        xusleep(10000);
 
79
#else
 
80
        /*
 
81
         * DPW 2007-04-23
 
82
         * When we can use select, block for up to 100 ms.
 
83
         */
115
84
        struct timeval to;
116
85
        fd_set R;
117
86
        FD_ZERO(&R);
119
88
        to.tv_sec = 0;
120
89
        to.tv_usec = 100000;
121
90
        select(unlinkd_rfd + 1, &R, NULL, NULL, &to);
 
91
#endif
122
92
    }
123
93
 
124
94
    /*
151
121
    x = write(unlinkd_wfd, buf, l);
152
122
 
153
123
    if (x < 0) {
154
 
        debug(2, 1) ("unlinkdUnlink: write FD %d failed: %s\n",
155
 
                     unlinkd_wfd, xstrerror());
 
124
        debugs(2, 1, "unlinkdUnlink: write FD " << unlinkd_wfd << " failed: " << xstrerror());
156
125
        safeunlink(path, 0);
157
126
        return;
158
127
    } else if (x != l) {
159
 
        debug(2, 1) ("unlinkdUnlink: FD %d only wrote %d of %d bytes\n",
160
 
                     unlinkd_wfd, x, l);
 
128
        debugs(2, 1, "unlinkdUnlink: FD " << unlinkd_wfd << " only wrote " << x << " of " << l << " bytes");
161
129
        safeunlink(path, 0);
162
130
        return;
163
131
    }
227
195
{
228
196
    const char *args[2];
229
197
 
230
 
    struct timeval slp;
231
198
    args[0] = "(unlinkd)";
232
199
    args[1] = NULL;
233
200
    pid = ipcCreate(
251
218
    if (pid < 0)
252
219
        fatal("Failed to create unlinkd subprocess");
253
220
 
254
 
    slp.tv_sec = 0;
255
 
 
256
 
    slp.tv_usec = 250000;
257
 
 
258
 
    select(0, NULL, NULL, NULL, &slp);
 
221
    xusleep(250000);
259
222
 
260
223
    fd_note(unlinkd_wfd, "squid -> unlinkd");
261
224
 
277
240
    if (FD_PIPE == fd_table[unlinkd_wfd].type)
278
241
        commUnsetNonBlocking(unlinkd_wfd);
279
242
 
280
 
    debug(2, 1) ("Unlinkd pipe opened on FD %d\n", unlinkd_wfd);
 
243
    debugs(2, 1, "Unlinkd pipe opened on FD " << unlinkd_wfd);
281
244
 
282
245
#ifdef _SQUID_MSWIN_
283
246
 
284
 
    debug(2, 4) ("Unlinkd handle: 0x%x, PID: %d\n", (unsigned)hIpc, pid);
 
247
    debugs(2, 4, "Unlinkd handle: 0x" << std::hex << hIpc << std::dec << ", PID: " << pid);
285
248
 
286
249
#endif
287
250
 
288
251
}
289
 
 
290
 
#endif /* ndef UNLINK_DAEMON */