os: drop self-limiting resources
It's only rarely used and can be easily achieved by generic means, eg. via ulimit or supervisor settings. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									b7b526024a
								
							
						
					
					
						commit
						6a01f488c8
					
				| 
						 | 
					@ -153,10 +153,6 @@ try_raising_nofile_limit(void)
 | 
				
			||||||
#ifdef RLIMIT_NOFILE
 | 
					#ifdef RLIMIT_NOFILE
 | 
				
			||||||
    struct rlimit rlim;
 | 
					    struct rlimit rlim;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Only fiddle with the limit if not set explicitly from the command line */
 | 
					 | 
				
			||||||
    if (limitNoFile >= 0)
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
 | 
					    if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
 | 
				
			||||||
        ErrorF("Failed to get the current nofile limit: %s\n", strerror(errno));
 | 
					        ErrorF("Failed to get the current nofile limit: %s\n", strerror(errno));
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -323,21 +323,6 @@ platform and configuration specific.
 | 
				
			||||||
.SH SERVER DEPENDENT OPTIONS
 | 
					.SH SERVER DEPENDENT OPTIONS
 | 
				
			||||||
Some X servers accept the following options:
 | 
					Some X servers accept the following options:
 | 
				
			||||||
.TP 8
 | 
					.TP 8
 | 
				
			||||||
.B \-ld \fIkilobytes\fP
 | 
					 | 
				
			||||||
sets the data space limit of the server to the specified number of kilobytes.
 | 
					 | 
				
			||||||
A value of zero makes the data size as large as possible.  The default value
 | 
					 | 
				
			||||||
of \-1 leaves the data space limit unchanged.
 | 
					 | 
				
			||||||
.TP 8
 | 
					 | 
				
			||||||
.B \-lf \fIfiles\fP
 | 
					 | 
				
			||||||
sets the number-of-open-files limit of the server to the specified number.
 | 
					 | 
				
			||||||
A value of zero makes the limit as large as possible.  The default value
 | 
					 | 
				
			||||||
of \-1 leaves the limit unchanged.
 | 
					 | 
				
			||||||
.TP 8
 | 
					 | 
				
			||||||
.B \-ls \fIkilobytes\fP
 | 
					 | 
				
			||||||
sets the stack space limit of the server to the specified number of kilobytes.
 | 
					 | 
				
			||||||
A value of zero makes the stack size as large as possible.  The default value
 | 
					 | 
				
			||||||
of \-1 leaves the stack space limit unchanged.
 | 
					 | 
				
			||||||
.TP 8
 | 
					 | 
				
			||||||
.B \-maxclients
 | 
					.B \-maxclients
 | 
				
			||||||
.BR 64 | 128 | 256 | 512
 | 
					.BR 64 | 128 | 256 | 512
 | 
				
			||||||
Set the maximum number of clients allowed to connect to the X server.
 | 
					Set the maximum number of clients allowed to connect to the X server.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -205,10 +205,6 @@ void CloseDownConnection(ClientPtr client);
 | 
				
			||||||
extern int LimitClients;
 | 
					extern int LimitClients;
 | 
				
			||||||
extern Bool PartialNetwork;
 | 
					extern Bool PartialNetwork;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int limitDataSpace;
 | 
					 | 
				
			||||||
extern int limitStackSpace;
 | 
					 | 
				
			||||||
extern int limitNoFile;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern Bool CoreDump;
 | 
					extern Bool CoreDump;
 | 
				
			||||||
extern Bool NoListenAll;
 | 
					extern Bool NoListenAll;
 | 
				
			||||||
extern Bool AllowByteSwappedClients;
 | 
					extern Bool AllowByteSwappedClients;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										50
									
								
								os/osinit.c
								
								
								
								
							
							
						
						
									
										50
									
								
								os/osinit.c
								
								
								
								
							| 
						 | 
					@ -77,16 +77,6 @@ SOFTWARE.
 | 
				
			||||||
#define ADMPATH "/usr/adm/X%smsgs"
 | 
					#define ADMPATH "/usr/adm/X%smsgs"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef RLIMIT_DATA
 | 
					 | 
				
			||||||
int limitDataSpace = -1;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_STACK
 | 
					 | 
				
			||||||
int limitStackSpace = -1;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_NOFILE
 | 
					 | 
				
			||||||
int limitNoFile = -1;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* The actual user defined max number of clients */
 | 
					/* The actual user defined max number of clients */
 | 
				
			||||||
int LimitClients = LIMITCLIENTS;
 | 
					int LimitClients = LIMITCLIENTS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -266,46 +256,6 @@ OsInit(void)
 | 
				
			||||||
        if (getpgrp() == 0)
 | 
					        if (getpgrp() == 0)
 | 
				
			||||||
            setpgid(0, 0);
 | 
					            setpgid(0, 0);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef RLIMIT_DATA
 | 
					 | 
				
			||||||
        if (limitDataSpace >= 0) {
 | 
					 | 
				
			||||||
            struct rlimit rlim;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (!getrlimit(RLIMIT_DATA, &rlim)) {
 | 
					 | 
				
			||||||
                if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max))
 | 
					 | 
				
			||||||
                    rlim.rlim_cur = limitDataSpace;
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                    rlim.rlim_cur = rlim.rlim_max;
 | 
					 | 
				
			||||||
                (void) setrlimit(RLIMIT_DATA, &rlim);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_STACK
 | 
					 | 
				
			||||||
        if (limitStackSpace >= 0) {
 | 
					 | 
				
			||||||
            struct rlimit rlim;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (!getrlimit(RLIMIT_STACK, &rlim)) {
 | 
					 | 
				
			||||||
                if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max))
 | 
					 | 
				
			||||||
                    rlim.rlim_cur = limitStackSpace;
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                    rlim.rlim_cur = rlim.rlim_max;
 | 
					 | 
				
			||||||
                (void) setrlimit(RLIMIT_STACK, &rlim);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_NOFILE
 | 
					 | 
				
			||||||
        if (limitNoFile >= 0) {
 | 
					 | 
				
			||||||
            struct rlimit rlim;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (!getrlimit(RLIMIT_NOFILE, &rlim)) {
 | 
					 | 
				
			||||||
                if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max))
 | 
					 | 
				
			||||||
                    rlim.rlim_cur = limitNoFile;
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                    rlim.rlim_cur = rlim.rlim_max;
 | 
					 | 
				
			||||||
                (void) setrlimit(RLIMIT_NOFILE, &rlim);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        LockServer();
 | 
					        LockServer();
 | 
				
			||||||
        been_here = TRUE;
 | 
					        been_here = TRUE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										39
									
								
								os/utils.c
								
								
								
								
							
							
						
						
									
										39
									
								
								os/utils.c
								
								
								
								
							| 
						 | 
					@ -302,15 +302,6 @@ UseMsg(void)
 | 
				
			||||||
    ErrorF("+iglx                  Allow creating indirect GLX contexts\n");
 | 
					    ErrorF("+iglx                  Allow creating indirect GLX contexts\n");
 | 
				
			||||||
    ErrorF("-iglx                  Prohibit creating indirect GLX contexts (default)\n");
 | 
					    ErrorF("-iglx                  Prohibit creating indirect GLX contexts (default)\n");
 | 
				
			||||||
    ErrorF("-I                     ignore all remaining arguments\n");
 | 
					    ErrorF("-I                     ignore all remaining arguments\n");
 | 
				
			||||||
#ifdef RLIMIT_DATA
 | 
					 | 
				
			||||||
    ErrorF("-ld int                limit data space to N Kb\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_NOFILE
 | 
					 | 
				
			||||||
    ErrorF("-lf int                limit number of open files to N\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_STACK
 | 
					 | 
				
			||||||
    ErrorF("-ls int                limit stack space to N Kb\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    LockServerUseMsg();
 | 
					    LockServerUseMsg();
 | 
				
			||||||
    ErrorF("-maxclients n          set maximum number of clients (power of two)\n");
 | 
					    ErrorF("-maxclients n          set maximum number of clients (power of two)\n");
 | 
				
			||||||
    ErrorF("-nolisten string       don't listen on protocol\n");
 | 
					    ErrorF("-nolisten string       don't listen on protocol\n");
 | 
				
			||||||
| 
						 | 
					@ -574,36 +565,6 @@ ProcessCommandLine(int argc, char *argv[])
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
                UseMsg();
 | 
					                UseMsg();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
#ifdef RLIMIT_DATA
 | 
					 | 
				
			||||||
        else if (strcmp(argv[i], "-ld") == 0) {
 | 
					 | 
				
			||||||
            if (++i < argc) {
 | 
					 | 
				
			||||||
                limitDataSpace = atoi(argv[i]);
 | 
					 | 
				
			||||||
                if (limitDataSpace > 0)
 | 
					 | 
				
			||||||
                    limitDataSpace *= 1024;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                UseMsg();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_NOFILE
 | 
					 | 
				
			||||||
        else if (strcmp(argv[i], "-lf") == 0) {
 | 
					 | 
				
			||||||
            if (++i < argc)
 | 
					 | 
				
			||||||
                limitNoFile = atoi(argv[i]);
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                UseMsg();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef RLIMIT_STACK
 | 
					 | 
				
			||||||
        else if (strcmp(argv[i], "-ls") == 0) {
 | 
					 | 
				
			||||||
            if (++i < argc) {
 | 
					 | 
				
			||||||
                limitStackSpace = atoi(argv[i]);
 | 
					 | 
				
			||||||
                if (limitStackSpace > 0)
 | 
					 | 
				
			||||||
                    limitStackSpace *= 1024;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                UseMsg();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef LOCK_SERVER
 | 
					#ifdef LOCK_SERVER
 | 
				
			||||||
        else if (strcmp(argv[i], "-nolock") == 0) {
 | 
					        else if (strcmp(argv[i], "-nolock") == 0) {
 | 
				
			||||||
#if !defined(WIN32) && !defined(__CYGWIN__)
 | 
					#if !defined(WIN32) && !defined(__CYGWIN__)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue