Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed connection hang, segfault, and unexpected warnings issues after internet connection loss. #60

Merged
merged 41 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2f1d23d
Don't increment the max reconnect counter for socket errors.
adamshapiro0 Mar 25, 2024
0626114
Reset the connection failure counter after receiving data.
adamshapiro0 Mar 25, 2024
b72f6f5
Fixed precision in PolarisClient position debug print.
adamshapiro0 Mar 25, 2024
518e233
Fixed enabling of C library trace prints.
adamshapiro0 Mar 25, 2024
c1984b3
Fixed P1_PrintData() disabled macro.
adamshapiro0 Mar 26, 2024
3968f19
Print incoming data when trace is enabled.
adamshapiro0 Mar 26, 2024
bb9a895
Fixed unexpected error on user-requested disconnect.
adamshapiro0 Mar 26, 2024
bf10a42
Added P1_GetTimeMS() and P1_GetUTCOffsetSec() helpers.
adamshapiro0 Mar 26, 2024
1beaa5a
Include the current time in polaris.c prints for debug purposes.
adamshapiro0 Mar 26, 2024
18bdaac
Don't print an error on user-initiated EINTR.
adamshapiro0 Mar 26, 2024
8c5487c
Store the total bytes received as part of the context.
adamshapiro0 Mar 26, 2024
ba48adc
Print the elapsed time on socket timeouts.
adamshapiro0 Mar 26, 2024
f32def9
Refactored socket closed check logic to handle 1029 and various warni…
adamshapiro0 Mar 26, 2024
0155d9b
Print the socket flags on connect.
adamshapiro0 Mar 26, 2024
965329b
Corrected debug message.
adamshapiro0 Oct 4, 2021
3b5f776
Include the attempt count in the max reconnects warning.
adamshapiro0 Oct 4, 2021
468edc8
Formatting cleanup.
adamshapiro0 Mar 26, 2024
4989b21
Added debug prints to OpenSocket().
adamshapiro0 Oct 4, 2021
0132c7e
Include partial API key in C++ debug print.
adamshapiro0 Mar 26, 2024
4b3fa85
Check for IPv6 returns in P1_SetAddress().
adamshapiro0 Oct 4, 2021
b4fbd70
Added debug prints to CloseSocket().
adamshapiro0 Oct 4, 2021
8cb4095
Fixed variable masking in Run() function.
adamshapiro0 Oct 12, 2022
c2d71f2
Print more details in TLS handshake failure message.
adamshapiro0 Oct 12, 2022
f5e4a63
Remove ssl context variables from Polaris context if compiled out.
adamshapiro0 Oct 21, 2021
aebad79
Print the date in polaris.c debug prints.
adamshapiro0 Mar 26, 2024
50a78fd
Added Bazel ASAN support with --config=asan.
adamshapiro0 Mar 26, 2024
71bf70e
Statically link ASAN for the benefit of unit test scripts.
adamshapiro0 Mar 26, 2024
5aee1be
Revert "Remove ssl context variables from Polaris context if compiled…
adamshapiro0 Mar 26, 2024
46b221e
Updated to the latest BoringSSL version (2024/3/25).
adamshapiro0 Mar 27, 2024
5849347
Added additional shutdown prints.
adamshapiro0 Mar 27, 2024
ce70ea2
Fixed FreeRTOS errno restoration.
adamshapiro0 Mar 27, 2024
9a9b55b
Print warnings for all socket timeouts and remote terminations.
adamshapiro0 Mar 27, 2024
c6878bd
Fixed missing socket timeout errno conditions.
adamshapiro0 Mar 27, 2024
899a4cf
Check for empty unique ID in example app.
adamshapiro0 Mar 27, 2024
d56e7ef
Set a default unique ID to match C example app.
adamshapiro0 Mar 27, 2024
dec6570
Fixed segfault when printing SSL errors after a failed HTTP response.
adamshapiro0 Mar 27, 2024
bda0bc0
Suppress socket timeout warning on user shutdown.
adamshapiro0 Mar 27, 2024
3f38ab4
Check SSL context in Polaris_Send*() functions.
adamshapiro0 Mar 28, 2024
8b2d9e0
Reuse the receive buffer to print the TLS handshake error string.
adamshapiro0 Mar 29, 2024
c865926
Minor review cleanup.
adamshapiro0 Mar 29, 2024
d1ac61b
Require a unique ID in the simple_polaris_client examples.
adamshapiro0 Mar 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ build:aarch64 --spawn_strategy=local
# instead of:
# bazel build -c opt --//c:polaris_enable_tls=False //:polaris_client
#build --flag_alias=polaris_enable_tls=//c:polaris_enable_tls

# Enable address sanitizer (ASAN).
#
# When using, you may also wish to disable optimizations (`-c dbg` or
# `--copt=-O0`). This may significantly impact performance, but may be
# necessary to pinpoint certain errors in highly optimized sections of code.
build:asan --copt=-g --copt=-fsanitize=address --linkopt=-fsanitize=address --linkopt=-static-libasan
11 changes: 3 additions & 8 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,8 @@ def dependencies():
maybe(
git_repository,
name = "boringssl",
commit = "87f3087d6343b89142d1191388a5885d74459df2",
# Patch out -Werror to avoid error on GCC 11. The new warning that is
# triggering an error is a conversion between `const uint8_t s[32]` and
# `const uint8_t *s` in curve25519.c (-Werror=array-parameter=).
patch_args = ["-p1"],
patches = ["boringssl.patch"],
# 2020/4/7
# 2024/3/25
commit = "54f64295218630fd869b3a079d9dfb5abfe61324",
remote = "https://boringssl.googlesource.com/boringssl",
shallow_since = "1586306564 +0000",
shallow_since = "1711401451 +0000",
)
6 changes: 6 additions & 0 deletions c/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Enable address sanitizer (ASAN).
#
# When using, you may also wish to disable optimizations (`-c dbg` or
# `--copt=-O0`). This may significantly impact performance, but may be
# necessary to pinpoint certain errors in highly optimized sections of code.
build:asan --copt=-g --copt=-fsanitize=address --linkopt=-fsanitize=address --linkopt=-static-libasan
3 changes: 2 additions & 1 deletion c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ endif()
# Polaris client C library - all messages and supporting code.
add_library(polaris_client
src/point_one/polaris/polaris.c
src/point_one/polaris/polaris_internal.c)
src/point_one/polaris/polaris_internal.c
src/point_one/polaris/portability.c)
target_include_directories(polaris_client PUBLIC ${PROJECT_SOURCE_DIR}/src)
if (MSVC)
target_compile_definitions(polaris_client PRIVATE BUILDING_DLL)
Expand Down
3 changes: 2 additions & 1 deletion c/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SRC_DIR=src

SOURCES=$(SRC_DIR)/point_one/polaris/polaris.c \
$(SRC_DIR)/point_one/polaris/polaris_internal.c
$(SRC_DIR)/point_one/polaris/polaris_internal.c \
$(SRC_DIR)/point_one/polaris/portability.c

OBJECTS=$(patsubst %.c,%.o,$(SOURCES))

Expand Down
11 changes: 3 additions & 8 deletions c/bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ def dependencies():
maybe(
git_repository,
name = "boringssl",
commit = "87f3087d6343b89142d1191388a5885d74459df2",
# Patch out -Werror to avoid error on GCC 11. The new warning that is
# triggering an error is a conversion between `const uint8_t s[32]` and
# `const uint8_t *s` in curve25519.c (-Werror=array-parameter=).
patch_args = ["-p1"],
patches = ["boringssl.patch"],
# 2020/4/7
# 2024/3/25
commit = "54f64295218630fd869b3a079d9dfb5abfe61324",
remote = "https://boringssl.googlesource.com/boringssl",
shallow_since = "1586306564 +0000",
shallow_since = "1711401451 +0000",
)
20 changes: 16 additions & 4 deletions c/examples/simple_polaris_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@ void HandleSignal(int sig) {
int main(int argc, const char* argv[]) {
if (argc < 2 || argc > 4) {
P1_fprintf(stderr,
"Usage: %s API_KEY [UNIQUE_ID] [LOG_LEVEL (1=debug, 2=trace)]\n",
"Usage: %s API_KEY UNIQUE_ID [LOG_LEVEL (1=debug, 2=trace)]\n",
argv[0]);
return 1;
}

const char* api_key = argv[1];
const char* unique_id = argc > 2 ? argv[2] : "device12345";
if (strlen(api_key) == 0) {
P1_fprintf(stderr,
"You must supply a Polaris API key to connect to the server.\n");
return 1;
}

const char* unique_id = argv[2];
if (strlen(unique_id) == 0) {
P1_fprintf(stderr, "You must supply a unique ID for this connection.\n");
return 1;
}

int log_level = argc > 3 ? atoi(argv[3]) : POLARIS_LOG_LEVEL_INFO;
Polaris_SetLogLevel(log_level);
Expand Down Expand Up @@ -66,6 +76,7 @@ int main(int argc, const char* argv[]) {
// Send a position update to Polaris. Position updates are used to select an
// appropriate corrections stream, and should be updated periodically as the
// receiver moves.
P1_printf("Setting initial position.\n");
if (Polaris_SendLLAPosition(&context, 37.773971, -122.430996, -0.02) !=
POLARIS_SUCCESS) {
Polaris_Disconnect(&context);
Expand All @@ -80,9 +91,10 @@ int main(int argc, const char* argv[]) {
signal(SIGTERM, HandleSignal);

Polaris_Run(&context, 30000);
Polaris_Free(&context);

P1_printf("Finished.\n");
P1_printf("Finished running. Cleaning up.\n");
Polaris_Free(&context);

P1_printf("Exiting.\n");
return 0;
}
12 changes: 0 additions & 12 deletions c/external/boringssl.patch

This file was deleted.

Loading
Loading