muddleftpd-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Muddleftpd-cvs] muddleftpd ./ChangeLog doc/info/muddleftpd.info...


From: Beau Kuiper
Subject: [Muddleftpd-cvs] muddleftpd ./ChangeLog doc/info/muddleftpd.info...
Date: Tue, 15 Apr 2003 06:04:35 -0400

CVSROOT:        /cvsroot/muddleftpd
Module name:    muddleftpd
Changes by:     Beau Kuiper <address@hidden>    03/04/15 06:04:35

Modified files:
        .              : ChangeLog 
        doc/info       : muddleftpd.info 
        src            : main.c utils.c 

Log message:
        Bugfix: fixed ssh hanging on logout by closing terminal like all good 
deamons should.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/muddleftpd/muddleftpd/ChangeLog.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/muddleftpd/muddleftpd/doc/info/muddleftpd.info.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/muddleftpd/muddleftpd/src/main.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/muddleftpd/muddleftpd/src/utils.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: muddleftpd/ChangeLog
diff -c muddleftpd/ChangeLog:1.5 muddleftpd/ChangeLog:1.6
*** muddleftpd/ChangeLog:1.5    Tue Nov 19 20:39:47 2002
--- muddleftpd/ChangeLog        Tue Apr 15 06:04:35 2003
***************
*** 1,3 ****
--- 1,13 ----
+ 2003-04-15  Beau Kuiper <address@hidden>
+ 
+       * src/main.c: mainprog(): added code to close all file descriptors.
+       After the server is started, it will also close the terminal file
+       desciptors, so ssh sessions are not stalled at logout.
+ 
+       * src/utils.c: fd_closeall_nonterminal(): determines the max file
+       descriptors number and attempts to close all open fds. The terminal
+       file descriptors are left untouched.
+ 
  2002-11-20  Beau Kuiper <address@hidden>
  
        * src/acl.c: transfer_config(): Added code that allows the server
Index: muddleftpd/doc/info/muddleftpd.info
diff -c muddleftpd/doc/info/muddleftpd.info:1.1 
muddleftpd/doc/info/muddleftpd.info:1.2
*** muddleftpd/doc/info/muddleftpd.info:1.1     Thu Sep 26 03:55:42 2002
--- muddleftpd/doc/info/muddleftpd.info Tue Apr 15 06:04:35 2003
***************
*** 1,4 ****
! This is info/muddleftpd.info, produced by makeinfo version 4.0 from
  info/muddleftpd.texi.
  
  INFO-DIR-SECTION Internet
--- 1,4 ----
! This is info/muddleftpd.info, produced by makeinfo version 4.2 from
  info/muddleftpd.texi.
  
  INFO-DIR-SECTION Internet
Index: muddleftpd/src/main.c
diff -c muddleftpd/src/main.c:1.1 muddleftpd/src/main.c:1.2
*** muddleftpd/src/main.c:1.1   Thu Sep 26 03:55:42 2002
--- muddleftpd/src/main.c       Tue Apr 15 06:04:35 2003
***************
*** 189,195 ****
--- 189,197 ----
  {
        int signum = 0;
        SELECTER *mainports;
+ #ifdef RLIMIT_NPROC
        struct rlimit newlimit;
+ #endif
  
        test_libc(verbose);
        
***************
*** 204,209 ****
--- 206,215 ----
        signal(SIGINT, sighandler);
  
        logerrors = TERMINAL;           
+       
+       /* close all file descriptiors */
+       fd_closeall_nonterminal();
+       
        init_pwgrfiles();
        
        ftpd_init(fconfig, verbose);
***************
*** 260,265 ****
--- 266,278 ----
                if (!runforeground)
                        /* Tell the parent the terminal can be given back! */
                        kill(getppid(), SIGHUP);
+       }
+       
+       /* close terminal file descriptors */
+       
+       if (!runforeground)
+       {
+               close(0); close(1); close(2);
        }
        
        log_addentry(MYLOG_INFO, NULL, PROGNAME" ("VERSTR") server started. 
Waiting on connections.");
Index: muddleftpd/src/utils.c
diff -c muddleftpd/src/utils.c:1.1 muddleftpd/src/utils.c:1.2
*** muddleftpd/src/utils.c:1.1  Thu Sep 26 03:55:42 2002
--- muddleftpd/src/utils.c      Tue Apr 15 06:04:35 2003
***************
*** 274,280 ****
                                break;          
                        default:
                                pathname[pos2] = pathname[pos];
!                               pos2++;
                }
                pos++;
        }
--- 274,280 ----
                                break;          
                        default:
                                pathname[pos2] = pathname[pos];
!                       pos2++;
                }
                pos++;
        }
***************
*** 1016,1018 ****
--- 1016,1035 ----
        exit(1);
  }
  
+ /*                    close file descriptors                          *
+  ************************************************************************/
+ 
+ // try to close all non-terminal file descriptors.
+ 
+ void fd_closeall_nonterminal(void)
+ {
+       int count, maxfilefd = 1024;
+ #ifdef RLIMIT_NPROC
+       struct rlimit lim;
+       
+       getrlimit(RLIMIT_NOFILE, &lim);
+       maxfilefd = lim.rlim_max;
+ #endif
+       for (count = 3; count < maxfilefd; count++)
+               close(count);
+ }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]