Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9add9f9

Browse files
committed
Don't actively violate the system limit of maximum open files (RLIMIT_NOFILE).
This avoids irritating kernel logs (if system overstep violations are enabled)and also the grsecurity alert when starting PostgreSQL.original patch by Jacek DrobieckiReferences:http://archives.postgresql.org/pgsql-bugs/2004-05/msg00103.phphttp://bugs.debian.org/cgi-bin/bugreport.cgi?bug=248967
1 parenta2e9de7 commit9add9f9

File tree

1 file changed

+24
-1
lines changed
  • src/backend/storage/file

1 file changed

+24
-1
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.147 2009/01/12 05:10:44 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.148 2009/03/04 09:12:49 petere Exp $
1111
*
1212
* NOTES:
1313
*
@@ -45,6 +45,9 @@
4545
#include<sys/stat.h>
4646
#include<unistd.h>
4747
#include<fcntl.h>
48+
#ifdefHAVE_SYS_RESOURCE_H
49+
#include<sys/resource.h>/* for getrlimit */
50+
#endif
4851

4952
#include"miscadmin.h"
5053
#include"access/xact.h"
@@ -361,15 +364,35 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
361364
intused=0;
362365
inthighestfd=0;
363366
intj;
367+
#ifdefHAVE_GETRLIMIT
368+
structrlimitrlim;
369+
intgetrlimit_status;
370+
#endif
364371

365372
size=1024;
366373
fd= (int*)palloc(size*sizeof(int));
367374

375+
#ifdefHAVE_GETRLIMIT
376+
# ifdefRLIMIT_NOFILE/* most platforms use RLIMIT_NOFILE */
377+
getrlimit_status=getrlimit(RLIMIT_NOFILE,&rlim);
378+
# else/* but BSD doesn't ... */
379+
getrlimit_status=getrlimit(RLIMIT_OFILE,&rlim);
380+
# endif/* RLIMIT_NOFILE */
381+
if (getrlimit_status!=0)
382+
ereport(WARNING, (errmsg("getrlimit failed: %m")));
383+
#endif/* HAVE_GETRLIMIT */
384+
368385
/* dup until failure or probe limit reached */
369386
for (;;)
370387
{
371388
intthisfd;
372389

390+
#ifdefHAVE_GETRLIMIT
391+
/* don't go beyond RLIMIT_NOFILE; causes irritating kernel logs on some platforms */
392+
if (getrlimit_status==0&&highestfd >=rlim.rlim_cur-1)
393+
break;
394+
#endif
395+
373396
thisfd=dup(0);
374397
if (thisfd<0)
375398
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp