Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
4649f3a4
Commit
4649f3a4
authored
1 year ago
by
sphere
Browse files
Options
Downloads
Plain Diff
Merge branch '1173-next-moved-upnp-to-it-s-own-thread' into 'next'
Resolve "[NEXT] moved UPnP to it's own thread" Closes
#1173
See merge request
!2263
parents
225f0859
8073ac65
No related branches found
No related tags found
2 merge requests
!2355
fix newer versions of mixerx
,
!2263
Resolve "[NEXT] moved UPnP to it's own thread"
Pipeline
#2130
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/netcode/i_tcp.c
+31
-1
31 additions, 1 deletion
src/netcode/i_tcp.c
with
31 additions
and
1 deletion
src/netcode/i_tcp.c
+
31
−
1
View file @
4649f3a4
...
@@ -134,6 +134,7 @@ typedef union
...
@@ -134,6 +134,7 @@ typedef union
#include
"d_netfil.h"
#include
"d_netfil.h"
#include
"i_tcp.h"
#include
"i_tcp.h"
#include
"../m_argv.h"
#include
"../m_argv.h"
#include
"../i_threads.h"
#include
"../doomstat.h"
#include
"../doomstat.h"
...
@@ -263,12 +264,33 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
...
@@ -263,12 +264,33 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
#ifdef HAVE_MINIUPNPC // based on old XChat patch
#ifdef HAVE_MINIUPNPC // based on old XChat patch
static
void
I_ShutdownUPnP
(
void
);
static
void
I_ShutdownUPnP
(
void
);
static
void
I_InitUPnP
(
void
);
I_mutex
upnp_mutex
;
static
struct
UPNPUrls
urls
;
static
struct
UPNPUrls
urls
;
static
struct
IGDdatas
data
;
static
struct
IGDdatas
data
;
static
char
lanaddr
[
64
];
static
char
lanaddr
[
64
];
struct
upnpdata
{
int
upnpc_started
;
};
static
struct
upnpdata
*
upnpuser
;
static
void
init_upnpc_once
(
struct
upnpdata
*
upnpdata
);
static
void
I_InitUPnP
(
void
)
{
upnpuser
=
malloc
(
sizeof
*
upnpuser
);
upnpuser
->
upnpc_started
=
0
;
I_spawn_thread
(
"init_upnpc_once"
,
(
I_thread_fn
)
init_upnpc_once
,
upnpuser
);
}
static
inline
void
I_InitUPnP
(
void
)
static
void
init_upnpc_once
(
struct
upnpdata
*
upnpuserdata
)
{
{
if
(
upnpuserdata
->
upnpc_started
!=
0
)
return
;
I_lock_mutex
(
&
upnp_mutex
);
const
char
*
const
deviceTypes
[]
=
{
const
char
*
const
deviceTypes
[]
=
{
"urn:schemas-upnp-org:device:InternetGatewayDevice:2"
,
"urn:schemas-upnp-org:device:InternetGatewayDevice:2"
,
"urn:schemas-upnp-org:device:InternetGatewayDevice:1"
,
"urn:schemas-upnp-org:device:InternetGatewayDevice:1"
,
...
@@ -311,35 +333,43 @@ static inline void I_InitUPnP(void)
...
@@ -311,35 +333,43 @@ static inline void I_InitUPnP(void)
I_AddExitFunc
(
I_ShutdownUPnP
);
I_AddExitFunc
(
I_ShutdownUPnP
);
}
}
freeUPNPDevlist
(
devlist
);
freeUPNPDevlist
(
devlist
);
I_unlock_mutex
(
upnp_mutex
);
}
}
else
if
(
upnp_error
==
UPNPDISCOVER_SOCKET_ERROR
)
else
if
(
upnp_error
==
UPNPDISCOVER_SOCKET_ERROR
)
{
{
CONS_Printf
(
M_GetText
(
"No UPnP devices discovered
\n
"
));
CONS_Printf
(
M_GetText
(
"No UPnP devices discovered
\n
"
));
}
}
upnpuserdata
->
upnpc_started
=
1
;
}
}
static
inline
void
I_UPnP_add
(
const
char
*
addr
,
const
char
*
port
,
const
char
*
servicetype
)
static
inline
void
I_UPnP_add
(
const
char
*
addr
,
const
char
*
port
,
const
char
*
servicetype
)
{
{
I_lock_mutex
(
&
upnp_mutex
);
if
(
addr
==
NULL
)
if
(
addr
==
NULL
)
addr
=
lanaddr
;
addr
=
lanaddr
;
if
(
!
urls
.
controlURL
||
urls
.
controlURL
[
0
]
==
'\0'
)
if
(
!
urls
.
controlURL
||
urls
.
controlURL
[
0
]
==
'\0'
)
return
;
return
;
UPNP_AddPortMapping
(
urls
.
controlURL
,
data
.
first
.
servicetype
,
UPNP_AddPortMapping
(
urls
.
controlURL
,
data
.
first
.
servicetype
,
port
,
port
,
addr
,
"SRB2"
,
servicetype
,
NULL
,
NULL
);
port
,
port
,
addr
,
"SRB2"
,
servicetype
,
NULL
,
NULL
);
I_unlock_mutex
(
upnp_mutex
);
}
}
static
inline
void
I_UPnP_rem
(
const
char
*
port
,
const
char
*
servicetype
)
static
inline
void
I_UPnP_rem
(
const
char
*
port
,
const
char
*
servicetype
)
{
{
I_lock_mutex
(
&
upnp_mutex
);
if
(
!
urls
.
controlURL
||
urls
.
controlURL
[
0
]
==
'\0'
)
if
(
!
urls
.
controlURL
||
urls
.
controlURL
[
0
]
==
'\0'
)
return
;
return
;
UPNP_DeletePortMapping
(
urls
.
controlURL
,
data
.
first
.
servicetype
,
UPNP_DeletePortMapping
(
urls
.
controlURL
,
data
.
first
.
servicetype
,
port
,
servicetype
,
NULL
);
port
,
servicetype
,
NULL
);
I_unlock_mutex
(
upnp_mutex
);
}
}
static
void
I_ShutdownUPnP
(
void
)
static
void
I_ShutdownUPnP
(
void
)
{
{
I_UPnP_rem
(
serverport_name
,
"UDP"
);
I_UPnP_rem
(
serverport_name
,
"UDP"
);
I_lock_mutex
(
&
upnp_mutex
);
FreeUPNPUrls
(
&
urls
);
FreeUPNPUrls
(
&
urls
);
I_unlock_mutex
(
upnp_mutex
);
}
}
#endif
#endif
...
...
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