Skip to content

Commit

Permalink
Merge pull request #1591 from private-octopus/sock-loop-wakeup
Browse files Browse the repository at this point in the history
Sock loop wakeup
  • Loading branch information
huitema authored Dec 9, 2023
2 parents af2f604 + c090338 commit deb0ac6
Show file tree
Hide file tree
Showing 7 changed files with 938 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ if(BUILD_TESTING AND picoquic_BUILD_TESTS)
COMMAND picoquic_ct -S ${PROJECT_SOURCE_DIR} -n -r)
add_test(NAME picohttp_ct
COMMAND picohttp_ct -S ${PROJECT_SOURCE_DIR} -n -r)

add_executable(thread_test
thread_tester/thread_test.c)
target_link_libraries(thread_test PRIVATE picoquic-log picoquic-core)
target_include_directories(thread_test PRIVATE loglib picoquic)
set_picoquic_compile_settings(thread_test)

endif()

# get all project files for formatting
Expand Down
15 changes: 15 additions & 0 deletions picoquic.sln
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerfAndStressTest", "PerfAn
{998765EE-64DF-49C1-8471-A79E2DA7CD21} = {998765EE-64DF-49C1-8471-A79E2DA7CD21}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "thread_tester", "thread_tester\thread_tester.vcxproj", "{57341DB3-B498-4E7B-9CB2-E897A562C15F}"
ProjectSection(ProjectDependencies) = postProject
{B3DDD196-3D03-4396-97BD-E5DE733E9D24} = {B3DDD196-3D03-4396-97BD-E5DE733E9D24}
{63E1E6B7-DB5F-4EDC-8AC8-7E9F5990D11F} = {63E1E6B7-DB5F-4EDC-8AC8-7E9F5990D11F}
{998765EE-64DF-49C1-8471-A79E2DA7CD21} = {998765EE-64DF-49C1-8471-A79E2DA7CD21}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baton_app", "baton_app\baton_app.vcxproj", "{C0F21D3F-ECC3-4AB5-A3E3-E2D48965EBA5}"
ProjectSection(ProjectDependencies) = postProject
{C8F3740E-56FB-4BE7-9D8C-30A954846146} = {C8F3740E-56FB-4BE7-9D8C-30A954846146}
Expand Down Expand Up @@ -184,6 +191,14 @@ Global
{436B580F-B0E8-4EB8-A987-08218D863316}.Release|x64.Build.0 = Release|x64
{436B580F-B0E8-4EB8-A987-08218D863316}.Release|x86.ActiveCfg = Release|Win32
{436B580F-B0E8-4EB8-A987-08218D863316}.Release|x86.Build.0 = Release|Win32
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Debug|x64.ActiveCfg = Debug|x64
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Debug|x64.Build.0 = Debug|x64
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Debug|x86.ActiveCfg = Debug|Win32
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Debug|x86.Build.0 = Debug|Win32
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Release|x64.ActiveCfg = Release|x64
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Release|x64.Build.0 = Release|x64
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Release|x86.ActiveCfg = Release|Win32
{57341DB3-B498-4E7B-9CB2-E897A562C15F}.Release|x86.Build.0 = Release|Win32
{C0F21D3F-ECC3-4AB5-A3E3-E2D48965EBA5}.Debug|x64.ActiveCfg = Debug|x64
{C0F21D3F-ECC3-4AB5-A3E3-E2D48965EBA5}.Debug|x64.Build.0 = Debug|x64
{C0F21D3F-ECC3-4AB5-A3E3-E2D48965EBA5}.Debug|x86.ActiveCfg = Debug|Win32
Expand Down
1 change: 1 addition & 0 deletions picoquic/picoquic_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ typedef struct st_picoquic_event_t {
#endif

int picoquic_create_thread(picoquic_thread_t* thread, picoquic_thread_fn thread_fn, void* arg);
int picoquic_wait_thread(picoquic_thread_t thread);
void picoquic_delete_thread(picoquic_thread_t* thread);

int picoquic_create_mutex(picoquic_mutex_t* mutex);
Expand Down
14 changes: 14 additions & 0 deletions picoquic/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,19 @@ int picoquic_create_thread(picoquic_thread_t * thread, picoquic_thread_fn thread
return ret;
}

int picoquic_wait_thread(picoquic_thread_t thread)
{
int ret = 0;
#ifdef _WINDOWS
if (WaitForSingleObject(thread, INFINITE) == WAIT_TIMEOUT) {
ret = -1;
}
#else
ret = pthread_join(thread, NULL);
#endif
return ret;
}

void picoquic_delete_thread(picoquic_thread_t * thread)
{
#ifdef _WINDOWS
Expand All @@ -1033,6 +1046,7 @@ void picoquic_delete_thread(picoquic_thread_t * thread)
#endif
}


int picoquic_create_mutex(picoquic_mutex_t * mutex)
{
#ifdef _WINDOWS
Expand Down
Loading

0 comments on commit deb0ac6

Please sign in to comment.