changeset 35336:9c334690f765

stream ftp: Revise file descriptor usage * Set unbound descriptor variables to -1 * Always test >= 0 to see if a variable refers to a valid descriptor
author al
date Tue, 20 Nov 2012 22:19:45 +0000
parents 85003f7fa621
children 6641819c8f45
files stream/stream_ftp.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_ftp.c	Tue Nov 20 22:18:25 2012 +0000
+++ b/stream/stream_ftp.c	Tue Nov 20 22:19:45 2012 +0000
@@ -60,7 +60,7 @@
   NULL,
   NULL,
 
-  0,
+  -1,
   0,0,
   NULL
 };
@@ -359,7 +359,7 @@
 
     // First close the fd
     closesocket(s->fd);
-    s->fd = 0;
+    s->fd = -1;
 
     // Send send the telnet sequence needed to make the server react
 
@@ -395,14 +395,14 @@
 
   if(!p) return;
 
-  if(s->fd > 0) {
+  if(s->fd >= 0) {
     closesocket(s->fd);
-    s->fd = 0;
+    s->fd = -1;
   }
 
   FtpSendCmd("QUIT",p,NULL);
 
-  if(p->handle) closesocket(p->handle);
+  if(p->handle >= 0) closesocket(p->handle);
   free(p->buf);
 
   m_struct_free(&stream_opts,p);