Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
1dbbd0fc
Commit
1dbbd0fc
authored
17 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Use pthread_attr_destroy() to avoid stepping on a different threads stack
size.
parent
beac09d6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xpdev/threadwrap.c
+11
-13
11 additions, 13 deletions
src/xpdev/threadwrap.c
with
11 additions
and
13 deletions
src/xpdev/threadwrap.c
+
11
−
13
View file @
1dbbd0fc
...
...
@@ -59,23 +59,19 @@ ulong _beginthread(void( *start_address )( void * )
,
unsigned
stack_size
,
void
*
arglist
)
{
pthread_t
thread
;
static
pthread_attr_t
attr
;
static
size_t
default_stack
;
static
int
attr_initialized
=
0
;
if
(
!
attr_initialized
)
{
pthread_attr_init
(
&
attr
);
/* initialize attribute structure */
/* set thread attributes to PTHREAD_CREATE_DETACHED which will ensure
that thread resources are freed on exit() */
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
pthread_attr_getstacksize
(
&
attr
,
&
default_stack
);
attr_initialized
=
1
;
}
pthread_attr_t
attr
;
size_t
default_stack
;
pthread_attr_init
(
&
attr
);
/* initialize attribute structure */
/* set thread attributes to PTHREAD_CREATE_DETACHED which will ensure
that thread resources are freed on exit() */
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
/* Default stack size in BSD is too small for JS stuff */
/* Force to at least 256k */
#define XPDEV_MIN_THREAD_STACK_SIZE (256*1024)
if
(
stack_size
==
0
&&
default_stack
<
XPDEV_MIN_THREAD_STACK_SIZE
)
if
(
stack_size
==
0
&&
pthread_attr_getstacksize
(
&
attr
,
&
default_stack
)
==
0
&&
default_stack
<
XPDEV_MIN_THREAD_STACK_SIZE
)
stack_size
=
XPDEV_MIN_THREAD_STACK_SIZE
;
if
(
stack_size
!=
0
)
...
...
@@ -92,8 +88,10 @@ ulong _beginthread(void( *start_address )( void * )
/* POSIX defines this arg as "void *(*start_address)" */
,(
void
*
(
*
)(
void
*
))
start_address
,
arglist
)
==
0
)
pthread_attr_destroy
(
&
attr
);
return
((
int
)
thread
/* thread handle */
);
pthread_attr_destroy
(
&
attr
);
return
(
-
1
);
/* error */
}
#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