summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:53:03 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:53:03 +0000
commit2de438e735598f6adde5926659754ce9a6aff2cf (patch)
tree79e887dafd2086369237a63959b123e1a0363745 /methods
parent6d5dd02a49b18017c296c2d76bc6bb1d9f1ef6ac (diff)
Fixed stupid rebinding of the socket
Author: jgg Date: 1999-03-15 08:22:13 GMT Fixed stupid rebinding of the socket
Diffstat (limited to 'methods')
-rw-r--r--methods/ftp.cc36
1 files changed, 19 insertions, 17 deletions
diff --git a/methods/ftp.cc b/methods/ftp.cc
index ace70cc79..8f186f9d6 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: ftp.cc,v 1.3 1999/03/15 08:10:26 jgg Exp $
+// $Id: ftp.cc,v 1.4 1999/03/15 08:22:13 jgg Exp $
/* ######################################################################
HTTP Aquire Method - This is the FTP aquire method for APT.
@@ -591,24 +591,23 @@ bool FTPConn::CreateDataFd()
}
// Port mode :<
- if (DataListenFd == -1)
- {
- // Get a socket
- if ((DataListenFd = socket(AF_INET,SOCK_STREAM,0)) < 0)
- return _error->Errno("socket","Could not create a socket");
-
- // Bind and listen
- sockaddr_in Addr;
- memset(&Addr,0,sizeof(Addr));
- if (bind(DataListenFd,(sockaddr *)&Addr,sizeof(Addr)) < 0)
- return _error->Errno("bind","Could not bind a socket");
- if (listen(DataListenFd,1) < 0)
- return _error->Errno("listen","Could not listen on the socket");
- SetNonBlock(DataListenFd,true);
- }
+ close(DataListenFd);
+ DataListenFd = -1;
+
+ // Get a socket
+ if ((DataListenFd = socket(AF_INET,SOCK_STREAM,0)) < 0)
+ return _error->Errno("socket","Could not create a socket");
- // Determine the name to send to the remote
+ // Bind and listen
sockaddr_in Addr;
+ memset(&Addr,0,sizeof(Addr));
+ if (bind(DataListenFd,(sockaddr *)&Addr,sizeof(Addr)) < 0)
+ return _error->Errno("bind","Could not bind a socket");
+ if (listen(DataListenFd,1) < 0)
+ return _error->Errno("listen","Could not listen on the socket");
+ SetNonBlock(DataListenFd,true);
+
+ // Determine the name to send to the remote
sockaddr_in Addr2;
socklen_t Jnk = sizeof(Addr);
if (getsockname(DataListenFd,(sockaddr *)&Addr,&Jnk) < 0)
@@ -660,6 +659,9 @@ bool FTPConn::Finalize()
if (DataFd < 0)
return _error->Errno("accept","Unable to accept connection");
+ close(DataListenFd);
+ DataListenFd = -1;
+
return true;
}
/*}}}*/