mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-05-05 13:54:22 -04:00
happy-eyeballs: Move happy_eyeballs_destroy to a thread
On Windows, shutdown() will not interrupt a blocking connect() call, so happy_eyeballs_destroy could block until the remaining candidates timed out. As happy_eyeballs_destroy is called in the RTMP connect path, this would stall the RTMP connection and cause the winning candidate's socket to be disconnected due to a timeout.
This commit is contained in:
committed by
Ryan Foster
parent
fce534572b
commit
78ffd99ab1
@@ -650,11 +650,11 @@ int happy_eyeballs_timedwait(struct happy_eyeballs_ctx *context,
|
||||
return status;
|
||||
}
|
||||
|
||||
int happy_eyeballs_destroy(struct happy_eyeballs_ctx *context)
|
||||
static void *destroy_thread(void *param)
|
||||
{
|
||||
if (context == NULL)
|
||||
return STATUS_INVALID_ARGUMENT;
|
||||
struct happy_eyeballs_ctx *context = param;
|
||||
|
||||
os_set_thread_name("happy-eyeballs destroy thread");
|
||||
#ifdef _WIN32
|
||||
#define SHUT_RDWR SD_BOTH
|
||||
#else
|
||||
@@ -698,6 +698,21 @@ int happy_eyeballs_destroy(struct happy_eyeballs_ctx *context)
|
||||
|
||||
da_free(context->candidates);
|
||||
free(context);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int happy_eyeballs_destroy(struct happy_eyeballs_ctx *context)
|
||||
{
|
||||
if (context == NULL)
|
||||
return STATUS_INVALID_ARGUMENT;
|
||||
|
||||
/* The destroy happens asynchronously in another thread due to the
|
||||
* connect() call blocking on Windows. */
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, destroy_thread, context);
|
||||
pthread_detach(thread);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user