diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2013-03-15 13:31:28 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2013-03-15 13:31:28 +0000 |
commit | 1d22f3f9a148b1b39ce3c6618e04e34f7458413a (patch) | |
tree | 7ffc618c02d173046aff5005f330976195305671 | |
parent | f74b8d7a0b2d790bb78dae1b624025bf013c05ab (diff) |
camield requested backout of rev 1.26, and indeed ftp-proxy does not
need it.
-rw-r--r-- | usr.sbin/ftp-proxy/ftp-proxy.c | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/usr.sbin/ftp-proxy/ftp-proxy.c b/usr.sbin/ftp-proxy/ftp-proxy.c index 936ba06c106..288e6b56673 100644 --- a/usr.sbin/ftp-proxy/ftp-proxy.c +++ b/usr.sbin/ftp-proxy/ftp-proxy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp-proxy.c,v 1.27 2013/03/11 17:40:11 deraadt Exp $ */ +/* $OpenBSD: ftp-proxy.c,v 1.28 2013/03/15 13:31:27 benno Exp $ */ /* * Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl> @@ -60,9 +60,6 @@ #define sstosa(ss) ((struct sockaddr *)(ss)) -#define FD_RESERVE 5 -volatile int con_inflight = 0; - enum { CMD_NONE = 0, CMD_PORT, CMD_EPRT, CMD_PASV, CMD_EPSV }; struct session { @@ -97,8 +94,6 @@ int drop_privs(void); void end_session(struct session *); void exit_daemon(void); int get_line(char *, size_t *); -int accept_reserve(int sockfd, struct sockaddr *addr, socklen_t *addrlen, - int reserve, volatile int *counter); void handle_connection(const int, short, void *); void handle_signal(int, short, void *); struct session * init_session(void); @@ -295,14 +290,8 @@ end_session(struct session *s) if (s->server_bufev && s->server_fd != -1) evbuffer_write(s->server_bufev->output, s->server_fd); - if (s->client_fd != -1) { + if (s->client_fd != -1) close(s->client_fd); - if (s->server_fd == -1) { - con_inflight--; - logmsg(LOG_DEBUG, "%s: inflight decremented, now %d", - __func__, con_inflight); - } - } if (s->server_fd != -1) close(s->server_fd); @@ -381,25 +370,6 @@ get_line(char *buf, size_t *valid) return ((int)linelen); } -int -accept_reserve(int sockfd, struct sockaddr *addr, socklen_t *addrlen, - int reserve, volatile int *counter) -{ - int ret; - if (getdtablecount() + reserve + - *counter >= getdtablesize()) { - errno = EMFILE; - return -1; - } - - if ((ret = accept(sockfd, addr, addrlen)) > -1) { - (*counter)++; - logmsg(LOG_DEBUG, "%s: inflight incremented, now %d",__func__, - *counter); - } - return ret; -} - void handle_connection(const int listen_fd, short event, void *arg) { @@ -422,8 +392,7 @@ handle_connection(const int listen_fd, short event, void *arg) */ client_sa = sstosa(&tmp_ss); len = sizeof(struct sockaddr_storage); - if ((client_fd = accept_reserve(listen_fd, client_sa, &len, - FD_RESERVE, &con_inflight)) < 0) { + if ((client_fd = accept(listen_fd, client_sa, &len)) < 0) { logmsg(LOG_CRIT, "accept() failed: %s", strerror(errno)); /* @@ -446,9 +415,6 @@ handle_connection(const int listen_fd, short event, void *arg) logmsg(LOG_ERR, "client limit (%d) reached, refusing " "connection from %s", max_sessions, sock_ntop(client_sa)); close(client_fd); - con_inflight--; - logmsg(LOG_DEBUG, "%s: inflight decremented, now %d",__func__, - con_inflight); return; } @@ -457,9 +423,6 @@ handle_connection(const int listen_fd, short event, void *arg) if (s == NULL) { logmsg(LOG_CRIT, "init_session failed"); close(client_fd); - con_inflight--; - logmsg(LOG_DEBUG, "%s: inflight decremented, now %d",__func__, - con_inflight); return; } s->client_fd = client_fd; @@ -528,10 +491,6 @@ handle_connection(const int listen_fd, short event, void *arg) s->id, sock_ntop(server_sa), strerror(errno)); goto fail; } - con_inflight--; - logmsg(LOG_DEBUG, "%s: connected, inflight decremented, now %d",__func__, - con_inflight); - len = sizeof(struct sockaddr_storage); if ((getsockname(s->server_fd, proxy_to_server_sa, &len)) < 0) { @@ -1170,4 +1129,3 @@ usage(void) " [-t timeout]\n", __progname); exit(1); } - |