Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
a753e50e
Commit
a753e50e
authored
May 20, 2000
by
Per Hedbor
Browse files
Options
Downloads
Patches
Plain Diff
Reallocate fds_to_close when needed.
Rev: src/fd_control.c:1.28
parent
c0d65d17
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fd_control.c
+22
-7
22 additions, 7 deletions
src/fd_control.c
with
22 additions
and
7 deletions
src/fd_control.c
+
22
−
7
View file @
a753e50e
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include
"error.h"
#include
"error.h"
#include
"fdlib.h"
#include
"fdlib.h"
RCSID
(
"$Id: fd_control.c,v 1.2
7 1999/09/14 21:07:20 hubbe
Exp $"
);
RCSID
(
"$Id: fd_control.c,v 1.2
8 2000/05/20 02:21:47 per
Exp $"
);
#else
/* TESTING */
#else
/* TESTING */
...
@@ -73,9 +73,8 @@ int set_nonblocking(int fd,int which)
...
@@ -73,9 +73,8 @@ int set_nonblocking(int fd,int which)
{
{
int
ret
;
int
ret
;
#ifdef PIKE_DEBUG
#ifdef PIKE_DEBUG
if
(
fd
<
0
||
fd
>
MAX_OPEN_FILEDESCRIPTORS
)
if
(
fd
<
0
)
fatal
(
"Filedescriptor %d out of range [0,%d).
\n
"
,
fatal
(
"Filedescriptor %d out of range [0,inf).
\n
"
,
fd
);
fd
,
MAX_OPEN_FILEDESCRIPTORS
);
#endif
#endif
do
do
...
@@ -110,7 +109,7 @@ int query_nonblocking(int fd)
...
@@ -110,7 +109,7 @@ int query_nonblocking(int fd)
{
{
int
ret
;
int
ret
;
#ifdef PIKE_DEBUG
#ifdef PIKE_DEBUG
if
(
fd
<
0
||
fd
>
MAX_OPEN_FILEDESCRIPTORS
)
if
(
fd
<
0
)
fatal
(
"Filedescriptor out of range.
\n
"
);
fatal
(
"Filedescriptor out of range.
\n
"
);
#endif
#endif
...
@@ -140,8 +139,23 @@ int query_nonblocking(int fd)
...
@@ -140,8 +139,23 @@ int query_nonblocking(int fd)
#endif
/* FD_CLOEXEC */
#endif
/* FD_CLOEXEC */
#ifdef HAVE_BROKEN_F_SETFD
#ifdef HAVE_BROKEN_F_SETFD
static
int
fds_to_close
[
MAX_OPEN_FILEDESCRIPTORS
];
static
int
*
fds_to_close
;
static
int
num_fds_to_close
=
0
;
static
int
fds_to_close_size
=
0
;
#define ASSURE_FDS_TO_CLOSE_SIZE(X) \
do{while(fds_to_close_size-1 < X) grow_fds_to_close();}while(0)
static
void
grow_fds_to_close
(
)
{
if
(
!
fds_to_close_size
)
fds_to_close_size
=
1
;
fds_to_close_size
*=
2
;
fds_to_close
=
realloc
(
fds_to_close
,
sizeof
(
int
)
*
fds_to_close_size
);
if
(
!
fds_to_close
)
fatal
(
"Out of memory in fd_control::grow_fds_to_close()
\n
"
"Tried to allocate %d fd_datum structs
\n
"
,
fds_to_close_size
);
MEMSET
(
fds
+
(
fds_size
/
2
),
0
,
fds_to_close_size
*
sizeof
(
int
)
/
2
);
}
void
do_close_on_exec
(
void
)
void
do_close_on_exec
(
void
)
{
{
...
@@ -170,6 +184,7 @@ int set_close_on_exec(int fd, int which)
...
@@ -170,6 +184,7 @@ int set_close_on_exec(int fd, int which)
return
(
0
);
/* Already marked */
return
(
0
);
/* Already marked */
}
}
}
}
ASSURE_FDS_TO_CLOSE_SIZE
((
num_fds_to_close
+
1
));
fds_to_close
[
num_fds_to_close
++
]
=
fd
;
fds_to_close
[
num_fds_to_close
++
]
=
fd
;
return
(
0
);
return
(
0
);
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment