diff -N -c -r -X exclude_files squid-1.0.beta7/src/ftp.c squid-1.0.beta7.henrik/src/ftp.c *** squid-1.0.beta7/src/ftp.c Thu May 9 01:23:24 1996 --- squid-1.0.beta7.henrik/src/ftp.c Mon May 13 19:16:18 1996 *************** *** 15,20 **** --- 15,21 ---- static char ftpBinary[] = "I"; static char localhost[] = "127.0.0.1"; static int ftpget_server_pipe = -1; + static int ftpget_port; typedef struct _Ftpdata { StoreEntry *entry; *************** *** 511,517 **** debug(9, 5, "ftpConnInProgress: FD %d\n", fd); ! if (comm_connect(fd, localhost, CACHE_FTP_PORT) != COMM_OK) { switch (errno) { case EINPROGRESS: case EALREADY: --- 512,518 ---- debug(9, 5, "ftpConnInProgress: FD %d\n", fd); ! if (comm_connect(fd, localhost, ftpget_port) != COMM_OK) { switch (errno) { case EINPROGRESS: case EALREADY: *************** *** 572,578 **** (void *) data); /* Now connect ... */ ! if ((status = comm_connect(data->ftp_fd, localhost, CACHE_FTP_PORT))) { if (status != EINPROGRESS) { squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); comm_close(data->ftp_fd); --- 573,579 ---- (void *) data); /* Now connect ... */ ! if ((status = comm_connect(data->ftp_fd, localhost, ftpget_port))) { if (status != EINPROGRESS) { squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); comm_close(data->ftp_fd); *************** *** 611,616 **** --- 612,618 ---- { static time_t last_restart = 0; comm_close(fd); + ftpget_port++; if (squid_curtime - last_restart < 2) { debug(9, 0, "ftpget server failing too rapidly\n"); debug(9, 0, "WARNING: FTP access is disabled!\n"); *************** *** 644,649 **** --- 646,653 ---- char pbuf[128]; char *ftpget = getFtpProgram(); + ftpget_port=CACHE_FTP_PORT+getAsciiPortNum(); + if (pipe(p) < 0) { debug(9, 0, "ftpInitialize: pipe: %s\n", xstrerror()); return -1; *************** *** 662,667 **** --- 666,675 ---- COMM_SELECT_EXCEPT, (PF) ftpServerClosed, (void *) NULL); + comm_set_select_handler(p[1], + COMM_SELECT_READ, + (PF) ftpServerClosed, + (void *) NULL); ftpget_server_pipe = p[1]; return 0; } *************** *** 676,682 **** /* inherit stdin,stdout,stderr */ for (fd = 3; fd < fdstat_biggest_fd(); fd++) (void) close(fd); ! sprintf(pbuf, "%d", CACHE_FTP_PORT); execlp(ftpget, ftpget, "-S", pbuf, NULL); debug(9, 0, "ftpInitialize: %s: %s\n", ftpget, xstrerror()); _exit(1); --- 684,690 ---- /* inherit stdin,stdout,stderr */ for (fd = 3; fd < fdstat_biggest_fd(); fd++) (void) close(fd); ! sprintf(pbuf, "%d", ftpget_port); execlp(ftpget, ftpget, "-S", pbuf, NULL); debug(9, 0, "ftpInitialize: %s: %s\n", ftpget, xstrerror()); _exit(1);