Re: Suse ftp-proxy v. 1.9.2.2 - Dropping unfinished connections
Marius Tomaschewski <[email protected]> Thu, 10 Aug 2006 12:01:17 +0200
| Newsgroups | gmane.linux.suse.proxy-suite |
|---|---|
| Organization | MaT@Home |
| Message-ID | <[email protected]> |
--cvVnyQ+4j833TQvp
Content-Type: multipart/mixed; boundary="mP3DRpeJDSE+ciuQ"
Content-Disposition: inline
--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, Aug 09, 2006 at 03:42:12PM +0200, Karel Kohout (DHL CZ) wrote:
> Hello,
Hi!
> We have a problem with our FTP proxy. It is dropping unfinished connectio=
ns
> exactly after 900 seconds (which is the set IDLE timeout). Any idea what =
is
> causing this, or how to this fix this issue? Thank you
Which system do you use? This usually happens on solaris...
(What happens sometimes is, select reports "data ready to
read", but FIONREAD ioctl reports 0 bytes).
You can try out the attached patch (...UseRecvBufSize.dif)
and set e.g. following in the config file:
UseRecvBufSize 4096
It will change to just use this receive buffer size and avoid
to ask via FIONREAD ioctl how many bytes are avaliable to read.
!!! Note, I just hacked it down - it is completelly untested !!!
Let us (this list) know if it works for you or not.
The another patch (...x86_64.dif) fixes some int types for
64bit platforms - just for completness.
Bye,
Marius.
--
=C2=B0 --- Marius Tomaschewski <[email protected]>, Germany --- =C2=B0
The number of UNIX installations has grown to 10, with
more expected.
- The Unix Programmer's Manual, 2nd Edition, June 1972
--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="proxy-suite-1.9.2.4_x86_64.dif"
Content-Transfer-Encoding: quoted-printable
--- common/com-socket.c
+++ common/com-socket.c
@@ -311,7 +311,8 @@
char peer[PEER_LEN] =3D {0};
char dest[PEER_LEN] =3D {0};
struct sockaddr_in saddr;
- int nsock, len;
+ int nsock;
+ socklen_t len;
=20
/*
** Let the show begin ...
@@ -1014,10 +1015,11 @@
** connection (e.g. FTP passive client or active server).
*/
if (hls->peer[0] =3D=3D '\0') {
- memset(&saddr, 0, sizeof(saddr));
- len =3D sizeof(saddr);
+ socklen_t slen =3D sizeof(saddr);
+
+ memset(&saddr, 0, slen);
nsock =3D accept(hls->sock,
- (struct sockaddr *) &saddr, &len);
+ (struct sockaddr *) &saddr, &slen);
if (nsock < 0) {
hls->ernr =3D errno;
syslog_error("can't accept %s", hls->ctyp);
@@ -1836,7 +1838,8 @@
u_int32_t socket_sck2addr(int sock, int peer, u_int16_t *port)
{
struct sockaddr_in saddr;
- int len, r;
+ socklen_t len;
+ int r;
char *s;
=20
/*
--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="proxy-suite-1.9.2.4_UseRecvBufSize.dif"
Content-Transfer-Encoding: quoted-printable
--- common/com-socket.c
+++ common/com-socket.c 2006/08/10 09:46:01
@@ -177,6 +177,7 @@ int deny_severity =3D LOG_WARNING;
#endif
=20
static int maxrecv_bufsiz =3D -1; /* max receive buffer size */
+static int userecv_bufsiz =3D -1; /* receive buffer size to use */
=20
/* ------------------------------------------------------------ **
**
@@ -230,6 +231,11 @@ int socket_listen(u_int32_t addr, u_int1
if(maxrecv_bufsiz < 0)
maxrecv_bufsiz =3D 0;
}
+ if(userecv_bufsiz < 0) {
+ userecv_bufsiz =3D config_int(NULL, "UseRecvBufSize", 0);
+ if(userecv_bufsiz < 0)
+ userecv_bufsiz =3D 0;
+ }
}
=20
/*
@@ -403,6 +409,11 @@ HLS *socket_init(int sock)
if(maxrecv_bufsiz < 0)
maxrecv_bufsiz =3D 0;
}
+ if(userecv_bufsiz < 0) {
+ userecv_bufsiz =3D config_int(NULL, "UseRecvBufSize", 0);
+ if(userecv_bufsiz < 0)
+ userecv_bufsiz =3D 0;
+ }
}
=20
hls =3D (HLS *) misc_alloc(FL, sizeof(HLS));
@@ -1049,19 +1060,24 @@ static void socket_ll_read(HLS *hls)
/*
** Get the number of bytes waiting to be read
*/
- len =3D 0;
- if( (cnt=3Dioctl(hls->sock, FIONREAD, &len)) < 0) {
- hls->ernr =3D errno;
- syslog_error("can't get num of bytes: %s %d=3D%s",
- hls->ctyp, hls->sock, hls->peer);
- close(hls->sock);
- hls->sock =3D -1;
- return;
- }
+ if(userecv_bufsiz > 0) {
+ len =3D userecv_bufsiz;
+ } else {
+ len =3D 0;
+
+ if( (cnt=3Dioctl(hls->sock, FIONREAD, &len)) < 0) {
+ hls->ernr =3D errno;
+ syslog_error("can't get num of bytes: %s %d=3D%s",
+ hls->ctyp, hls->sock, hls->peer);
+ close(hls->sock);
+ hls->sock =3D -1;
+ return;
+ }
#if defined(COMPILE_DEBUG)
- debug(4, "ll_read: FIONREAD reported %d bytes for %s %d=3D%s",
- len, hls->ctyp, hls->sock, hls->peer);
+ debug(4, "ll_read: FIONREAD reported %d bytes for %s %d=3D%s",
+ len, hls->ctyp, hls->sock, hls->peer);
#endif
+ }
=20
/*
** Check if the socket has been closed
@@ -1118,13 +1134,38 @@ static void socket_ll_read(HLS *hls)
=20
if (cnt !=3D len) {
if(cnt > 0) {
+ if( userecv_bufsiz <=3D 0) {
+ /*
+ ** hmm... seems to be solaris, isn't? :-)
+ */
+ syslog_write(T_DBG,
+ "recvd %d bytes while %d reported: %s %d=3D%s",
+ cnt, len, hls->ctyp, hls->sock, hls->peer);
+ }
/*
- ** hmm... seems to be solaris, isn't? :-)
+ ** try to realloc to smaller buffer,
+ ** to not to waste memory.
*/
- syslog_write(T_DBG,
- "recvd %d bytes while %d reported: %s %d=3D%s",
- cnt, len, hls->ctyp, hls->sock, hls->peer);
- } else {
+ tmp =3D (BUF *) realloc(buf, sizeof(BUF) + cnt);
+ if( tmp) {
+ tmp->len =3D cnt;
+ buf =3D tmp;
+ }
+ }
+ else if( userecv_bufsiz > 0) {
+ /*
+ ** OK, EOF recived
+ */
+#if defined(COMPILE_DEBUG)
+ debug(1, "closed: %s %d=3D%s, len=3D%d, cnt=3D%d",
+ hls->ctyp, hls->sock, hls->peer, len, cnt);
+#endif
+ close(hls->sock);
+ hls->sock =3D -1;
+ misc_free(FL, buf);
+ return;
+ }
+ else {
/*
** report as error because we use FIONREAD
** above and handle EOF's (len =3D 0) there...
--mP3DRpeJDSE+ciuQ--
--cvVnyQ+4j833TQvp
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFE2wPt/vnSa5SpxwQRAgTjAKDSE6GAQ3/PKm96n56CVv8W1TzRcACffL6A
UOd4rUewB/ioBoxeS/XCKTs=
=uoV9
-----END PGP SIGNATURE-----
--cvVnyQ+4j833TQvp--