Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
5edfe797
Commit
5edfe797
authored
Aug 26, 2011
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using _beginthread() for starting threads on Windows
parent
6d70e5c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
mongoose.c
mongoose.c
+10
-18
No files found.
mongoose.c
View file @
5edfe797
...
...
@@ -221,6 +221,12 @@ typedef int SOCKET;
#define MAX_CGI_ENVIR_VARS 64
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#ifdef _WIN32
static
pthread_t
pthread_self
(
void
)
{
return
GetCurrentThreadId
();
}
#endif // _WIN32
#if defined(DEBUG)
#define DEBUG_TRACE(x) do { \
flockfile
(
stdout
);
\
...
...
@@ -863,10 +869,6 @@ static int pthread_cond_destroy(pthread_cond_t *cv) {
return
CloseHandle
(
cv
->
signal
)
&&
CloseHandle
(
cv
->
broadcast
)
?
0
:
-
1
;
}
static
pthread_t
pthread_self
(
void
)
{
return
GetCurrentThreadId
();
}
// For Windows, change all slashes to backslashes in path names.
static
void
change_slashes_to_backslashes
(
char
*
path
)
{
int
i
;
...
...
@@ -1104,18 +1106,8 @@ struct dirent * readdir(DIR *dir) {
#define set_close_on_exec(fd) // No FD_CLOEXEC on Windows
static
int
start_thread
(
struct
mg_context
*
ctx
,
mg_thread_func_t
func
,
void
*
param
)
{
HANDLE
hThread
;
ctx
=
NULL
;
// Unused
hThread
=
CreateThread
(
NULL
,
0
,
(
LPTHREAD_START_ROUTINE
)
func
,
param
,
0
,
NULL
);
if
(
hThread
!=
NULL
)
{
(
void
)
CloseHandle
(
hThread
);
}
return
hThread
==
NULL
?
-
1
:
0
;
static
int
start_thread
(
struct
mg_context
*
ctx
,
mg_thread_func_t
f
,
void
*
p
)
{
return
_beginthread
((
void
(
__cdecl
*
)(
void
*
))
f
,
0
,
p
)
==
-
1L
?
-
1
:
0
;
}
static
HANDLE
dlopen
(
const
char
*
dll_name
,
int
flags
)
{
...
...
@@ -3454,7 +3446,7 @@ static int set_ports_option(struct mg_context *ctx) {
// handshake will figure out that the client is down and
// will close the server end.
// Thanks to Igor Klopov who suggested the patch.
setsockopt
(
sock
,
SOL_SOCKET
,
SO_KEEPALIVE
,
&
on
,
setsockopt
(
sock
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
on
,
sizeof
(
on
))
!=
0
||
bind
(
sock
,
&
so
.
lsa
.
u
.
sa
,
so
.
lsa
.
len
)
!=
0
||
listen
(
sock
,
100
)
!=
0
)
{
...
...
@@ -3783,7 +3775,7 @@ static void close_socket_gracefully(SOCKET sock) {
// ephemeral port exhaust problem under high QPS.
linger
.
l_onoff
=
1
;
linger
.
l_linger
=
1
;
setsockopt
(
sock
,
SOL_SOCKET
,
SO_LINGER
,
&
linger
,
sizeof
(
linger
));
setsockopt
(
sock
,
SOL_SOCKET
,
SO_LINGER
,
(
void
*
)
&
linger
,
sizeof
(
linger
));
// Send FIN to the client
(
void
)
shutdown
(
sock
,
SHUT_WR
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment